# TraceLotForward

## Overview

TraceLotForward provides forward traceability — given a lot, it returns all outbound InventoryLedger entries (goods issues) and their destinations. This is used for recall management to identify where a lot's items have been sent.

## Business Rules

- Requires `lotId`
- Returns all outbound InventoryLedger records where the lot was part of a goods issue by joining InventoryExecution and filtering `executionType=GOODS_ISSUE`
- Each record includes:
  - Executed date (executedAt)
  - Destination location
  - Quantity
  - Reference to the originating document via InventoryExecution source fields
- Returns error if the lot does not exist
- Returns an empty list if the lot exists but has no outbound movements

## Process Flow

```mermaid
flowchart TD
    A[Receive lotId] --> B{Lot exists?}
    B -->|No| C[Return LOT_NOT_FOUND error]
    B -->|Yes| D[Join InventoryExecution and select ledger rows where lotId matches and executionType is GOODS_ISSUE]
    D --> E{Records found?}
    E -->|Yes| F[Return list of outbound InventoryLedger records]
    E -->|No| G[Return empty list]
```

## External Dependencies

- None

## Error Scenarios

- **LOT_NOT_FOUND**: Referenced lot does not exist

## Test Cases

- returns outbound movements for lot
- includes movement date and destination
- returns error when lot not found
- returns empty list when lot has no outbound movements
