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

W121: Remove item from purchase order

Drops a PO line. Triggered from the Purchase Order Detail items section.

Steps

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

  2. Assert editable. 409 when any receipt exists against the PO — line items are locked once goods have been received (same rule as WO items, W134-W136).

  3. Delete the line's ledger rows FIRST. Removing a line is a hard delete, so call deleteBySource('po_item', [itemId]) on both ledgers to physically remove the line's ORDER rows — once the line row is gone its source id never reaches a reconcile again, so this has to happen first.

  4. Remove the line. Call PurchaseOrders.removeItem.

Returns

Nothing.

Business rules

  • Items are locked once a receipt exists. (Receipt items are keyed by material / SKU, not by PO line, so this is a business-level guard, not a DB constraint.)
  • 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 whole PO is the append-only path that reverses instead.

Errors

  • NotFoundError. The line was not found.
  • ConflictError. A receipt exists against the PO.