W152: Remove item from sales order
Drops a line from an SO. Triggered from Sales Order Detail items section.
Steps
-
Load the line. Call
SalesOrders.getItemById; unknown ids raiseNotFoundError(no silent no-op). -
Delete the line's ledger rows FIRST. Hard delete: call
deleteBySource('so_item', [itemId])on both ledgers to physically remove the line'sDEMAND/ALLOCATE/CONSUMErows — once the line is gone its source id never reaches a reconcile again, so this has to happen first. (Earlier this step was missing, so the rows stranded; fixed with #608.) -
Remove the line. Call
SalesOrders.removeItem.
Returns
Nothing.
Business rules
- Delete-before-remove is load-bearing: the ledger rows must go before the line, or they strand. Removing a line physically deletes its rows (it never happened); cancelling the SO (→
Rejected) is the append-only path that reverses instead. - No shipped guard in v1. Blocking removal on already-shipped orders is still deferred; removing a shipped line nets FG on-hand back up by the consumed quantity.
Errors
NotFoundError. The line was not found.