Tech debt: reverse approval-time inventory increments when a PO is cancelled (deferred from #53) #55

Open
opened 2026-06-21 06:50:18 +00:00 by shad0w · 0 comments
Owner

Tech debt — deferred from #53 (PO cancellation)

When a PO is approved with a siteId, approval increments ItemInventory (app/(portal)/approvals/[id]/actions.ts). The cancel feature (#53) does not reverse that increment, by decision — inventory is currently feature-flagged off (NEXT_PUBLIC_INVENTORY_ENABLED), so a cancelled approved PO can leave a stale stock increment behind.

To do (when inventory is brought live)

  • On cancelPo, if the PO had reached an inventory-incrementing state (approved with a siteId) and the increment was applied, decrement the same ItemInventory quantities for its line items with a productId.
  • Guard against double-reversal and against decrementing below zero / for POs that never incremented.
  • Add an integration test mirroring the approval-increment test.

Why deferred

Per the #53 answers: "Should approval-time inventory increments be reversed on cancel? — Mark this as a new tech debt issue and on wiki, to be resolved when this inventory increment has to be brought to live."

Tracked on the wiki under Inventory-and-Catalogue.

## Tech debt — deferred from #53 (PO cancellation) When a PO is approved with a `siteId`, approval **increments** `ItemInventory` (`app/(portal)/approvals/[id]/actions.ts`). The cancel feature (#53) does **not** reverse that increment, by decision — inventory is currently feature-flagged off (`NEXT_PUBLIC_INVENTORY_ENABLED`), so a cancelled approved PO can leave a stale stock increment behind. ### To do (when inventory is brought live) - On `cancelPo`, if the PO had reached an inventory-incrementing state (approved with a `siteId`) and the increment was applied, **decrement** the same `ItemInventory` quantities for its line items with a `productId`. - Guard against double-reversal and against decrementing below zero / for POs that never incremented. - Add an integration test mirroring the approval-increment test. ### Why deferred Per the #53 answers: "Should approval-time inventory increments be reversed on cancel? — Mark this as a new tech debt issue and on wiki, to be resolved when this inventory increment has to be brought to live." Tracked on the wiki under Inventory-and-Catalogue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: shad0w/pelagia-portal#55
No description provided.