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

W140: Update receipt

Edits a previously-recorded WO receipt. Triggered from Work Order Detail receipts section. Metadata-only edits are a fast path; any change to received quantities rebuilds the paired ledger entries and recomputes the WO status.

Steps

  1. Load the receipt and parent WO. Call WorkOrders.getReceiptById.

  2. Fast path for metadata-only edits. If only date or notes changed, call WorkOrders.updateReceipt and return.

  3. Rebuild paired ledger entries on quantity edits. For the CONSUME (materials and FG, for sub-assembly inputs) and PRODUCE entries paired to this receipt (matched by source_id = receipt.id), insert reverse entries to net them to zero. Then update the receipt header and items, and post fresh paired ledger entries via the same logic as W137 step 3.

  4. Recompute the WO status. Apply W137 step 4: Received if every line is fully received, Partial otherwise.

Returns

The updated receipt.

Business rules

  • Rebuild rather than patch. Step 3 deletes and re-inserts paired ledger entries; this keeps the consumption math consistent with the current snapshot and the receipt's quantities.
  • Atomic. Steps 3 and 4 share one transaction.

Errors

  • NotFoundError. The receipt was not found.
  • InvalidTransitionError. The parent WO is in a terminal status.