# SalesOrderLine

## Description

SalesOrderLine represents one sellable obligation within a sales order. It stores the item, ordered quantity, selling unit, commercial price snapshot, requested fulfillment date, billing policy hints, and cumulative shipped or invoiced progress needed to calculate what remains to ship or invoice.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [createSalesOrder](../commands/CreateSalesOrder.md) - Create initial order lines when the sales order is first drafted.
- [updateSalesOrder](../commands/UpdateSalesOrder.md) - Add, remove, or revise draft order lines before the commercial baseline is confirmed.
- [confirmSalesOrder](../commands/ConfirmSalesOrder.md) - Freeze line-level pricing, payment, and fulfillment snapshots at confirmation time.
- [closeSalesOrder](../commands/CloseSalesOrder.md) - Mark remaining line balance as complete, cancelled, or written off when the order closes.

### Query Definitions

- [getSalesOrder](../queries/GetSalesOrder.md) - Return line-level item, quantity, and progress details inside one sales order.
- [listSalesOrders](../queries/ListSalesOrders.md) - Expose line summaries for sales and fulfillment work queues.

### Models

- SalesOrderLine

### Invariants

- Every sales order line belongs to exactly one sales order and inherits its company scope.
- Each line must reference one ACTIVE sellable item, a positive ordered quantity, and a non-negative unit price.
- Remaining quantity to ship and remaining quantity to invoice are derived from the immutable ordered quantity and the cumulative posted shipment or issued invoice evidence.
- Once the parent order is confirmed, line-level commercial fields are immutable unless an explicit revision workflow is introduced.

### Relationships

- **Belongs To SalesOrder**: `salesOrderId` ties the line to its parent order aggregate.
- **References Item (cross-module)**: `itemId` must point to an ACTIVE item from item-management.
- **References SalesPriceRule**: `matchedPriceRuleId` is optional and records which rule defaulted the commercial price.
- **Referenced By ShipmentLine**: Shipment lines consume open shippable quantity from one order line.
- **Referenced By SalesInvoiceLine**: Invoice lines validate billed quantity and price against one order line.
