The reverse pipeline
A return runs the order backward: the buyer requests it, ships the item, the warehouse inspects it, and only then does money move and stock return. Each step needs its own state.
State and money
- Model the return as its own state machine: requested, label issued, received, inspected, refunded.
- Refund only after inspection confirms condition, or refund early and accept some loss for speed.
- Make refunds idempotent so a retried refund does not pay twice.
Inventory effects
- Restock only sellable returns; route damaged items to a separate disposition.
- Update the ledger so a restocked unit becomes sellable again without inflating counts.
Key idea
A return is a reverse order modeled as its own state machine, where money moves idempotently after inspection and only sellable items restock into the inventory ledger.