# ApproveCountLine

## Permission Scope

inventoryControl

## Overview

approveCountLine approves a count line variance, transitioning it from PENDING to APPROVED status. When the variance is non-zero, an inventory adjustment is automatically generated with the reason "inventory-count" to reconcile the difference. Zero-variance lines are approved without generating an adjustment.

## Business Rules

- Count line must be in PENDING status
- Approving a line with non-zero variance generates an inventory adjustment with reason "inventory-count"
- Zero-variance lines are approved without generating an adjustment
- Can also auto-approve lines within a configured tolerance

## Process Flow

```mermaid
flowchart TD
    A[Receive approve 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[Approve count line]
    F --> G{Variance ≠ 0?}
    G -->|Yes| H[Generate inventory adjustment]
    H --> I[Return approved line]
    G -->|No| I
```

## External Dependencies

- None (generates [InventoryAdjustment](../models/InventoryAdjustment.md) internally)

## 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
- approves line
- generates adjustment for non-zero variance
- zero variance approved without adjustment
