W141: Delete receipt
Removes a WO receipt and the inventory effect it booked on both ledgers. Triggered from Work Order Detail receipts section.
Steps
-
Load the receipt. Call
WorkOrders.getReceiptByIdand capture theworkOrderId. -
Physically delete the receipt's ledger rows. Gather the receipt-item ids and call
deleteBySource('wo_receipt', receiptItemIds)on both ledgers, removing the pairedCONSUMEandPRODUCErows outright. This is a hard delete — the rows are gone, not offset withREVERSE_*rows. Gathering happens before the receipt items cascade away. -
Delete the receipt row. Call
WorkOrders.deleteReceipt. Receipt items cascade away at the DB layer. -
Recompute the WO status. Recompute
Partial/Receivedfrom the surviving receipts, reverting toProductionwhen no received quantity remains, so the WO never dangles asReceived/Partialwithout receipts.
Returns
Nothing.
Business rules
- Hard delete, not reversal. The receipt never happened, so its ledger rows are removed rather than reversed. Cancellation is the append-only path that preserves history.
- Atomic. Steps 2 through 4 share a single transaction.
- Status follows the surviving receipts. Deleting the last receipt returns the WO to
Production.
Errors
NotFoundError. The receipt was not found.