W134: Add item to work order
Appends an output-SKU line post-creation and snapshots its BOM inputs — the same per-item logic W129 runs at create (shared helper). Triggered from the Work Order edit modal.
Steps
- Assert editable. 409 when any receipt exists against the WO (items are locked once production has been received).
- Validate. WO + SKU must exist; the SKU must not already be on this WO (409).
- Insert the item.
WorkOrders.addItem. - Snapshot the BOM.
BOM.getBomForSkuscaled by quantity →WorkOrders.addInputsForItem(no-op for a BOM-less SKU). - Project the new line. Run the status → ledger reconciliation projector for just this line: Entered onward books FG ORDER + input DEMAND, Production onward adds input ALLOCATE, Draft books nothing.
Returns
{ item, inputs } — the line plus its snapshotted recipe.
Business rules
- One line per SKU per WO.
- The snapshot is taken from the live BOM at the moment of the add, scaled by the item quantity — identical semantics to creation-time snapshotting.
- Items are locked once a receipt exists (consistent with PO items, W117/W120/W121).
Errors
| Condition | Error |
|---|---|
| WO or SKU not found | not_found |
| Receipt exists / duplicate SKU | conflict |