# RejectCountLine

## Permission Scope

inventoryControl

## Overview

rejectCountLine rejects a count line, optionally requesting a recount. The line can be transitioned to either REJECTED (terminal) or RECOUNT (allows re-recording of the counted quantity) status.

## Business Rules

- Count line must be in PENDING status
- Can optionally set the line to RECOUNT status instead of REJECTED
- RECOUNT status allows the line to be re-recorded

## Process Flow

```mermaid
flowchart TD
    A[Receive reject request] --> B{Count line exists?}
    B -->|No| C[Return error: COUNT_LINE_NOT_FOUND]
    B -->|Yes| D{Line status PENDING?}
    D -->|No| E[Return error: COUNT_LINE_NOT_PENDING]
    D -->|Yes| F{Recount requested?}
    F -->|Yes| G[Update status to RECOUNT]
    F -->|No| H[Update status to REJECTED]
    G --> I[Return updated line]
    H --> I
```

## External Dependencies

- None

## Error Scenarios

- **COUNT_LINE_NOT_FOUND**: Referenced count line does not exist
- **COUNT_LINE_NOT_PENDING**: Count line is not in PENDING status

## Test Cases

- returns error when not found
- returns error when not pending
- rejects line
- sets line to RECOUNT status
