W136: Remove item from work order
Deletes an output line and its input snapshot. Triggered from the Work Order edit modal.
Steps
- Assert editable. 409 when any receipt exists against the WO.
- Delete the line's ledger rows FIRST. Hard delete: call
deleteBySourceforwo_item(the line's FGORDER) andwo_input(its snapshot inputs'DEMAND/ALLOCATE) on both ledgers, removing the rows outright — once the line and its inputs are deleted their source ids never reach a reconcile again, so this has to happen first. - Delete the item.
WorkOrders.removeItem; thework_order_inputsrows cascade via the L1 FK.
Returns
Nothing (L4 echoes { deletedId }).
Business rules
- Delete-before-remove is load-bearing: the ledger rows must go before the line and its inputs, or they strand. Removing a line physically deletes its rows (it never happened); cancelling the WO is the append-only path that reverses instead.
Errors
| Condition | Error |
|---|---|
| WO item not found | not_found |
| Receipt exists | conflict |