You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(orders): enforce lifecycle transitions and one-time inventory restoration #252
Order status changes and item cancellation/restore paths do not enforce a transition matrix or one-time inventory adjustment. Repeated terminal requests and void-adjustment rows can make inventory and order state diverge.
Current behavior
main/routes/orders.ts:806-925 accepts listed target statuses without validating the current-to-target transition.
Repeating status=cancelled on an already-cancelled order can execute the inventory-restoration loop again.
Whole-order cancellation includes rows that represent void adjustments.
The S6-targeted path in main/routes/index.ts:251-508 has similar cancel/restore status and inventory assumptions.
Expected behavior
Order lifecycle transitions should be explicit and monotonic unless a documented adjustment flow is used. Inventory should be restored at most once and only for quantities that were actually deducted.
Acceptance criteria
Define and enforce a current-to-target transition matrix, including terminal states.
Re-read order/item state inside the transaction and make repeated requests safe.
Exclude void_adjustment and already-processed rows from inventory restoration.
Ensure whole-order cancellation and item cancellation/restore cannot create duplicate adjustments.
Add tests for repeated cancellation, completed/cancelled sources, voided items, and concurrent requests.
Activity