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

W126: Delete receipt

Removes a receipt and the inventory effect it booked. Triggered from the Purchase Order Detail receipts section.

Steps

  1. Load the receipt. Call PurchaseOrders.getReceiptById to confirm existence and capture the purchaseOrderId.

  2. Physically delete the receipt's ledger rows. Gather the receipt-item ids and call deleteBySource('po_receipt', receiptItemIds) on both the materials and finished-goods ledgers, removing the RECEIVE rows outright. This is a hard delete — the rows are gone, not reversed (contrast a cancellation, which stays append-only). Gathering happens before the receipt items cascade away.

  3. Delete the receipt row. Call PurchaseOrders.deleteReceipt. The receipt items cascade away at the DB layer.

  4. Recompute the PO status. Recompute Partial / Received from the surviving receipts, reverting to Placed when no received quantity remains, so the PO never dangles as Received/Partial without receipts behind it.

Returns

Nothing.

Business rules

  • Hard delete, not reversal. The receipt never happened, so its ledger rows are removed rather than offset with REVERSE_* rows. Cancellation is the append-only path that preserves history.
  • Status follows the surviving receipts. Deleting the last receipt returns the PO to Placed.
  • Cost cascade is still a v1 gap. The PO header has no stored costs column today (it is computed on read), so there is nothing to re-roll here. The downstream FIFO/cost cascade remains deferred with W122 steps 7-9.

Errors

  • NotFoundError. The receipt was not found.