W120: Update purchase order item
Edits a single PO line. Triggered from the Purchase Order Detail items section.
Steps
-
Load the line and parent PO. Call
PurchaseOrders.getItemById. -
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).
-
Ledger-relevant patch? If the patch changes quantity or the material/SKU reference, the line's projected ORDER event must be rewritten: reverse the active ORDER (the projector diffs presence, not quantity), apply the patch, re-project at the PO's current status. A cost-only patch skips the ledger entirely.
-
Apply the patch. Call
PurchaseOrders.updateItem.
Returns
The updated line.
Business rules
- Items are locked once a receipt exists.
- Reverse-then-re-project keeps the ledger append-only. Prior ORDER events are netted by
REVERSE_ORDERrows, never mutated. - Catalog reference cannot cross types. A line on a materials PO must stay a material; same for FG. Switching across types is rejected.
Errors
NotFoundError. The line was not found.ConflictError. A receipt exists against the PO.ValidationError. Catalog mismatch with the parent PO's target type.