# SalesOrderLine

## Description

SalesOrderLine represents one sellable obligation within a sales order. It stores the item, ordered quantity, selling unit, agreed unit price, and cumulative fulfilled or billed progress needed to calculate what remains to fulfill or bill.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

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

### Query Definitions

- [getSalesOrder](../query/GetSalesOrder.md) - Return line-level item, quantity, and progress details inside one sales order.
- [listSalesOrders](../query/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.
- Each line's `requiresPhysicalFulfillment` is resolved from the item's [SalesItem](./SalesItem.md) record when the item is chosen and frozen there; later changes to that record never rewrite it.
- Remaining quantity to fulfill and remaining quantity to bill are derived from the immutable ordered quantity, cumulative downstream fulfillment progress, and downstream accounts-receivable billing progress.
- 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 that holds a [SalesItem](./SalesItem.md) record.
- **Referenced By Fulfillment Lines**: Downstream fulfillment lines consume open fulfillable quantity from one order line.
- **Referenced By Accounts Receivable Lines**: Customer invoice and credit-note lines validate billed quantity and price against one order line from the accounts-receivable module.
