# ListStockMovements

## Overview

ListStockMovements lists stock movements filtered by status, movement type, warehouse, or date range. It returns summary-level records without movement lines — use GetStockMovement for full detail. Results are ordered by creation date descending.

## Business Rules

- Accepts optional filters:
  - `status` — filter by movement status (e.g., Draft, Confirmed, Done, Cancelled)
  - `movementType` — filter by type (e.g., goods_receipt, goods_issue, internal_transfer, block, unblock)
  - `warehouseId` — filter by warehouse (movements involving any storage location in the warehouse)
  - `dateFrom` — filter movements created on or after this date
  - `dateTo` — filter movements created on or before this date
- Returns StockMovement records **without** nested movement lines
- Results are ordered by `createdAt` 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[Apply status, movementType, warehouseId, date range filters as provided]
    C --> D[Order by createdAt descending]
    D --> E{Records found?}
    E -->|Yes| F[Return list of StockMovement records]
    E -->|No| G[Return empty list]
```

## External Dependencies

- None

## Error Scenarios

- Returns empty list if no matching records exist

## Test Cases

- lists movements by status
- lists movements by movement type
- lists movements by warehouse
- lists movements by date range
- returns empty list when no matches
- orders by creation date descending
- does not include movement lines
