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
- Assert editable. 409 when any receipt exists against the WO.
- Cost-only patch? Apply and return — no input or ledger impact.
- Quantity change:
- 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.
- Apply the patch.
WorkOrders.updateItem. - Re-scale the snapshot.
quantity × new/oldper input row — preserves the creation-time recipe (no BOM re-read). - 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
| Condition | Error |
|---|---|
| WO item not found | not_found |
| Receipt exists | conflict |