Inspect a return and restock
Entry. PUT /v1/commerce/returns/:id → ReturnCommandService.update. Permission RETURN:UPDATE.
Line rules
For each supplied line, received cannot exceed requested. Accepted plus rejected must equal received (return.error.invalidSumAcceptedRejected).
A line restocks during the update when accepted quantity is greater than 0, putawayCompleted is true, and restoredToStockAt is still empty. That calls ReturnInventoryService.restockSingleLineItem only when order.warehouseId is set. The code checks order.warehouseId before the call, not returnRequest.warehouseId.
Completion
restockItems runs when status becomes COMPLETED and it was not already completed. The comment says commercial quantities are final only after inspection, and putaway may happen earlier per line.
restockItems:
- Restocks a line only when accepted is greater than 0,
putawayCompletedis true, andrestoredToStockAtis empty. - Adds
quantityReceivedontoOrderItem.quantityReturned, and accepted and rejected onto the matching order-item counters. SetsisReturnwhen returned quantity is greater than 0. - Emits in-process
return.stock.restored. No listener was found for that name.
Warehouse for the single-line restock is returnRequest.warehouseId, else order.warehouseId, else the fulfillment order’s warehouse. Missing warehouse throws return.error.warehouseRequired. A restoredToBinId must belong to that warehouse and tenant, and must not be BLOCKED (return.error.invalidRestockBin). Stock adjustment goes through StockOperationsPort.adjustStock.
Order status
| Return status just entered | Order status written |
|---|---|
RETURN_RECEIVED | RETURN_RECEIVED |
COMPLETED | RETURNED |
That order write uses OrderStatusService.transitionWithTx. force on the return update is passed through. Other return statuses do not change the order in this block.
Status changes also emit return.status.changed (no listener found) and, on COMPLETED, emitAsync return.completed.
Grade
itemGrade and gradeOnReceipt are stored on the line. Restock uses accepted quantity and putaway, not the grade enum, in the method that was read. Whether grade should block restock is unknown. The code does not check it before adjustStock.