Skip to main content

Returns

Overview​

Return requests, lines, and policies. Completion can restore stock and emit inventory sync.

Code map​

PiecePath
Featuresrc/modules/commerce/return
State machinereturn-state-machine.ts
Shipment listenerreturn-shipment.listener.ts
Schema44-return.prisma

Entities: ReturnRequest, ReturnLineItem, ReturnPolicy.

State machine​

Null from allows any target, the same helper pattern as orders.

FromTo
REQUESTEDAPPROVED, REJECTED, CANCELLED
APPROVEDRETURN_LABEL_CREATED, RETURN_SHIPPED, RETURN_RECEIVED, CANCELLED
RETURN_LABEL_CREATEDRETURN_SHIPPED, CANCELLED
RETURN_SHIPPEDRETURN_RECEIVED, CANCELLED
RETURN_RECEIVEDINSPECTING, COMPLETED, REJECTED
INSPECTINGCOMPLETED, REJECTED
COMPLETED, REJECTED, CANCELLEDnone

Events​

NameKindConsumer
return.status.changedin-processnone found
return.stock.restoredin-processnone found
order.status.changedoutboxproduced by return command
stock.sync.requestedoutboxinventory publish
Emitted and unused

return.status.changed and return.stock.restored have no @OnEvent listener in the scan. Do not depend on them for a side effect.

Business rules​

Unknown: whether restock on COMPLETED is mandatory or depends on ReturnItemGrade.

Order-level return statuses (RETURN_REQUESTED, RETURN_RECEIVED, and the rest) are the order state machine, not this one. Both can move in one flow. See Order state machine.

Workflows​

API surface​

POST /v1/commerce/returns requires RETURN:CREATE. PUT /v1/commerce/returns/:id requires RETURN:UPDATE. RTO type is rejected on the public create unless createFromForwardRto calls it with the internal flag. Return-policy controllers are separate.