# ListStockAdjustments

## Overview

ListStockAdjustments lists StockAdjustment records with optional filters by adjustment type, status, and date range. Results include associated StockAdjustmentLines and are ordered by creation date descending (newest first). Supports pagination via limit and offset.

## Business Rules

- Accepts optional filters:
  - `adjustmentType` -- filter by type (CORRECTION, SCRAP, BLOCK, UNBLOCK)
  - `status` -- filter by status (DRAFT, SUBMITTED, REJECTED, CONFIRMED, CANCELLED)
  - `dateFrom` -- filter adjustments created on or after this date
  - `dateTo` -- filter adjustments created on or before this date
- Returns StockAdjustment records with nested StockAdjustmentLine records
- Results are ordered by `createdAt` descending (newest first)
- Supports pagination via `limit` and `offset` parameters; returns `hasNextPage` to indicate more results
- 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{adjustmentType provided?}
    C -->|Yes| D[Add adjustmentType filter]
    C -->|No| E{status provided?}
    D --> E
    E -->|Yes| F[Add status filter]
    E -->|No| G{dateFrom or dateTo provided?}
    F --> G
    G -->|Yes| H[Add date range filter]
    G -->|No| I[Order by createdAt descending]
    H --> I
    I --> J[Apply pagination: limit and offset]
    J --> K{Records found?}
    K -->|Yes| L[Return list of StockAdjustments with lines and hasNextPage]
    K -->|No| M[Return empty list]
```

## External Dependencies

- None

## Error Scenarios

- Returns empty list if no matching records exist

## Test Cases

- lists all stock adjustments
- filters by adjustmentType
- filters by status
- filters by date range
- returns empty list when no matches
- paginates results
- includes stockAdjustmentLines grouped by adjustment
- paginates results with hasNextPage=false when no more results
