# ListInventoryCounts

## Overview

ListInventoryCounts lists inventory count documents filtered by status, type, or date range. It returns summary-level records without count lines — use GetInventoryCount for full detail. Results are ordered by planned date descending.

## Business Rules

- Accepts optional filters:
  - `status` — filter by count status (e.g., draft, in-progress, completed, cancelled)
  - `countType` — filter by count type (e.g., full, cycle, ad-hoc)
  - `warehouseId` — filter by warehouse
  - `dateFrom` — filter counts with planned date on or after this date
  - `dateTo` — filter counts with planned date on or before this date
- Returns InventoryCount records **without** nested count lines
- Results are ordered by `plannedDate` descending (most recent first)
- Returns an empty list if no matching records exist

## Process Flow

```mermaid
flowchart TD
    A[Receive optional filters] --> B[Build query from provided filters]
    B --> C{status provided?}
    C -->|Yes| D[Add status filter]
    C -->|No| E{countType provided?}
    D --> E
    E -->|Yes| F[Add countType filter]
    E -->|No| G{warehouseId provided?}
    F --> G
    G -->|Yes| H[Add warehouseId filter]
    G -->|No| I{dateFrom or dateTo provided?}
    H --> I
    I -->|Yes| J[Add date range filter]
    I -->|No| K[Order by plannedDate descending]
    J --> K
    K --> L{Records found?}
    L -->|Yes| M[Return list of InventoryCount records]
    L -->|No| N[Return empty list]
```

## External Dependencies

- None

## Error Scenarios

- Returns empty list if no matching records exist

## Test Cases

- lists counts by status
- lists counts by type
- lists counts by warehouse
- lists counts by date range
- returns empty list when no matches
- orders by planned date descending
