W114: Update purchase order
Edits a PO's header fields, including status and lifecycle timestamps. Triggered from the Purchase Order Detail page.
Steps
-
Load the PO. Call
PurchaseOrders.getPoByIdto confirm existence. -
Apply the header patch. Call
PurchaseOrders.updatePowith the patch. Patchable fields:status,placedAt,shipDate,expectedDeliveryDate,receivedAt,paidAt,cancelledAt,shippingCosts,setupCosts,otherCosts,notes. -
Reconcile the inventory ledger to the new status. Run the status → ledger reconciliation projector. It ensures an
ORDERentry per line item (materials or FG ledger pertargetType) exists whenever the status is notPlanningorCancelled, and emitsREVERSE_ORDERwhen a transition back toPlanning— or to terminalCancelled— makes those entries no longer desired. The projector is idempotent: a status patch that doesn't change the desired set writes nothing.RECEIVEstays receipt-driven (W122).
Returns
The updated PO.
Business rules
- Some header fields are immutable.
poNumber,vendorId,targetType, andshipToLocationIdare not patchable. - Status is patched directly. Any of the seven
org.po_statusvalues is accepted; a validated manual-transition map is a v1 gap.Partial/Receivedare normally computed by the receipt workflow (W122). - Status drives the ledger. Step 3 reconciles
ORDERentries to the new status (seeded once status leavesPlanning, reversed onCancelled) via the idempotent projector.RECEIVEremains receipt-driven (W122), so the two paths don't double-count.
Errors
NotFoundError. The PO was not found.