Skip to main content
Version: v1.0.0(int)

W152: Remove item from sales order

Drops a line from an SO. Triggered from Sales Order Detail items section.

Steps

  1. Load the line. Call SalesOrders.getItemById; unknown ids raise NotFoundError (no silent no-op).

  2. Delete the line's ledger rows FIRST. Hard delete: call deleteBySource('so_item', [itemId]) on both ledgers to physically remove the line's DEMAND/ALLOCATE/CONSUME rows — 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.)

  3. 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.