(root)/ – Rev 36427
Rev 36426 |
Rev 36428 |
Go to most recent revision |
Last modification |
Compare with Previous |
View Log
| RSS feed
Last modification
- Rev 36427 2026-04-29 14:38:13
- Author: amit
- Log message:
- rejectReturn: simplify to cancel-the-request semantics
After the receive/refund refactor, applyReceipt — and therefore every
warehouse-side effect (SALE_RET scans, WarehouseInventoryItem.addQuantity,
InventoryItem.returnTimestamp, ReturnOrderInfo, Order.status flip,
lineItem.returnQty) — only runs from refundOrder (or its inline
auto-approve sibling in submitReceiptForApproval). Both paths set
pro.refundTimestamp in the same transaction, all-or-nothing under
@Transactional(rollbackFor=Exception.class).
The refund_timestamp guard at the top of rejectReturn blocks rejection
once any of that has fired, which means rejectReturn is now ONLY
callable on a pending PRO — a state where applyReceipt has never run
and there is nothing on the warehouse side to undo.
The pre-existing reversal pipeline (warehouse-scan -1 reversal scans,
ReturnOrderInfo update/create-with-REJECTED, Order.status flip back to
DELIVERY_SUCCESS, lineItem.returnQty decrement) was therefore operating
against state that doesn't exist:
- lastScanType is SALE (from original sale), not SALE_RET, so
addQuantity(-1) gate correctly skipped — but the unconditional
persist of WarehouseScan(qty=-1, type=SALE_RET) was creating
fake reversal rows for receipts that never happened.
- selectByOrderId for ReturnOrderInfo always returned empty
(refundOrder is the only writer), and the no-rows branch was
fabricating REJECTED ROI rows for returns that were never received.
- Order.status was never flipped to COMPLETE_RETURN, so the
DELIVERY_SUCCESS reversal block correctly skipped — pure dead
branch.
Strip all of it. rejectReturn is now: guards (refund/reject timestamps),
stamp PRO with reject_timestamp/remark/updatedBy, restoreReturnedItems
to undo the partner-side effects from generateDebitNote(), mark items
REJECTED so a fresh re-request is possible.
This also undoes the previous fix #5 (extending the warehouse-scan
reversal to non-serialized) — that fix was making things worse by
creating fake reversal rows for both serialized and non-serialized
items instead of just serialized. The right answer was to delete the
whole block, not extend it.