# InventoryCount

## Description

InventoryCount represents a physical inventory counting session used to verify system stock quantities against actual quantities on hand. Counts can be full (entire warehouse) or cycle (specific locations). The count follows a lifecycle from PLANNED through IN_PROGRESS to COMPLETED, with the option to cancel from either PLANNED or IN_PROGRESS states.

Starting a count captures a snapshot of system quantities and optionally freezes stock movements for the counted locations. Completion unfreezes movements and finalizes the session.

## Domain Model Definitions

### Model type

Stateful

#### State Transitions

```mermaid
stateDiagram-v2
    [*] --> Planned: createInventoryCount
    Planned --> InProgress: startInventoryCount
    InProgress --> Completed: completeInventoryCount
    Planned --> Cancelled: cancelInventoryCount
    InProgress --> Cancelled: cancelInventoryCount
```

### Command Definitions

- [createInventoryCount](../commands/CreateInventoryCount.md) - Create a new inventory count session in PLANNED status
- [startInventoryCount](../commands/StartInventoryCount.md) - Start the count, capturing system quantity snapshots and optionally freezing stock
- [completeInventoryCount](../commands/CompleteInventoryCount.md) - Complete the count session after all lines are resolved
- [cancelInventoryCount](../commands/CancelInventoryCount.md) - Cancel a planned or in-progress count session

### Query Definitions

- [getInventoryCount](../queries/GetInventoryCount.md) - Retrieve an inventory count session by id
- [listInventoryCounts](../queries/ListInventoryCounts.md) - List inventory count sessions with optional filters

### Models

- InventoryCount

### Invariants

- Cannot be finalized until all count lines are in a terminal status (APPROVED or REJECTED)
- Freezing stock blocks movements for the counted locations during the count
- Unfreezing resumes movements after completion
- A snapshot captures system quantities at the start of the count

### Relationships

- **Has many InventoryCountLine**: Each count session contains lines for individual item-location combinations
- **References Warehouse (optional)**: A full count may target an entire warehouse
- **References StorageLocation (optional)**: A cycle count may target specific storage locations
