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

W132: Update work order

Edits a WO's header fields, including status and lifecycle timestamps. Triggered from Work Order Detail. The WO status flow is Draft → Entered → Placed → Production → In Transit → Partial → Received → Completed, with Cancelled available at any point. Status is patched directly; a validated transition map is a v1 gap. Status changes drive the inventory ledgers via the reconciliation projector (step 3). Partial / Received are normally computed by the receipt workflow (W137).

Steps​

  1. Load the WO. Call WorkOrders.getWoById to confirm existence.

  2. Apply the header patch. Call WorkOrders.updateWo with the patch. Patchable fields: status, orderDate, expectedDeliveryDate, productionStartedAt, receivedAt, cancelledAt, notes.

  3. Reconcile the inventory ledger to the new status. Run the status → ledger reconciliation projector. It ensures the net-active set for the current status: FG ORDER per output line and DEMAND per BOM-snapshot input once status leaves Draft; ALLOCATE per input from Production onwards (In Transit, Partial, Received, Completed). A backward transition that drops an event, or Cancelled (which reverses everything), emits the matching REVERSE_* entry. The projector is idempotent — a patch that doesn't change the desired set writes nothing. CONSUME / PRODUCE stay receipt-driven (W137).

Returns​

The updated WO.

Business rules​

  • Header fields only. Output lines and the recipe snapshot are not edited here; woNumber and workSiteLocationId are not patchable.
  • Status is patched directly. Any of the nine org.wo_status values is accepted; a validated manual-transition map is a v1 gap. Partial / Received are normally computed by the receipt workflow (W137).
  • Status drives the ledger. Step 3 reconciles FG ORDER / DEMAND / ALLOCATE to the new status via the idempotent projector, writing REVERSE_* on backward or terminal (Cancelled) transitions. CONSUME / PRODUCE remain receipt-driven (W137), so the two paths don't double-count.

Errors​

  • NotFoundError. The WO was not found.