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

W135: Update work order item

Patches an output line's quantity / conversion cost, keeping the input snapshot and the projected ledger truthful. Triggered from the Work Order edit modal.

Steps

  1. Assert editable. 409 when any receipt exists against the WO.
  2. Cost-only patch? Apply and return — no input or ledger impact.
  3. Quantity change:
    1. Reverse the line. Net the line's active events (FG ORDER + input DEMAND/ALLOCATE) to zero — the projector diffs presence, not quantity, so the old-quantity events must be reversed, never edited.
    2. Apply the patch. WorkOrders.updateItem.
    3. Re-scale the snapshot. quantity × new/old per input row — preserves the creation-time recipe (no BOM re-read).
    4. Re-project. Run the reconciliation projector for the line at the WO's current status — fresh forward events at the new quantities.

Returns

{ item, inputs } — the patched line plus its re-scaled recipe.

Business rules

  • The SKU is fixed once added; swapping = remove + add.
  • Reverse-then-re-project keeps the ledger append-only: prior events are netted by REVERSE_* rows, never mutated.

Errors

ConditionError
WO item not foundnot_found
Receipt existsconflict