# TransferOrderLine

## Description

TransferOrderLine stores item-level transfer intent and cumulative execution progress. It is the quantity truth for derived shipment and receipt progress.

The header remains in a document-control status such as OPEN while the line quantities determine whether the transfer is not shipped, partially shipped, shipped, partially received, or received.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [createTransferOrder](../command/CreateTransferOrder.md) - Creates transfer lines
- [updateTransferOrder](../command/UpdateTransferOrder.md) - Replaces transfer lines while the header is DRAFT
- [shipTransferOrder](../command/ShipTransferOrder.md) - Increments `shippedQuantity`
- [receiveTransferOrder](../command/ReceiveTransferOrder.md) - Increments `receivedQuantity`

### Query Definitions

- [getTransferOrder](../query/GetTransferOrder.md) - Returns transfer lines with the header
- [listTransferOrders](../query/ListTransferOrders.md) - Returns transfer lines with each header

### Models

- TransferOrderLine

### Invariants

- Each line belongs to exactly one TransferOrder
- `itemId`, derived `unitId`, and `orderedQuantity` are required
- `orderedQuantity` must be greater than zero
- `shippedQuantity` and `receivedQuantity` are cumulative progress quantities in the same unit as `orderedQuantity`
- `shippedQuantity` and `receivedQuantity` are initialized to zero
- `shippedQuantity` cannot exceed `orderedQuantity`
- `receivedQuantity` cannot exceed `shippedQuantity`
- `shippedQuantity` is changed only by shipTransferOrder
- `receivedQuantity` is changed only by receiveTransferOrder
- `unitId` is derived from the referenced item primary unit when the line is created or replaced
- `unitId` is the inventory primary unit snapshot for ordered, shipped, and received quantities
- `lotId` and `serialNumberId` are optional generic inventory references

### Relationships

- **Belongs to TransferOrder**: Each line references its parent transfer order
- **References Item**: Each line references the item being transferred
- **References Unit**: Each line stores the item primary unit snapshot for all transfer quantities
- **Optionally References Lot**: A line may constrain execution to a lot
- **Optionally References SerialNumber**: A line may constrain execution to a serial number
