(root)/ – Rev 36425
Rev 36424 |
Rev 36426 |
Go to most recent revision |
Last modification |
Compare with Previous |
View Log
| RSS feed
Last modification
- Rev 36425 2026-04-29 13:52:16
- Author: amit
- Log message:
- Sale-return reversal: idempotency guards + CN failure rolls back + non-serialized reject reversal
rejectReturn (#1): add refundTimestamp / rejectTimestamp guards. Without
them a stale-tab click or retry could re-run the full reversal pipeline
on an already-refunded DN — reversing scans twice, re-running
restoreReturnedItems (re-credits scheme amounts to wallet on top of the
refund that already paid out), and stamping rejectTimestamp on top of
refundTimestamp. Mirrors refundOrder's existing guard pair.
refundOrder CN block (#2): replace the swallow-and-log with a re-throw
on IRN failure. With class-level @Transactional(rollbackFor=Exception),
the prior catch caused commits of an advanced sellerWarehouse sequence
+ orphan CreditNote / CreditNoteLine rows whenever the NIC IRN call
failed. Restructured as straight-through; IRN failure now rolls the
whole refundOrder transaction back so finance retries cleanly. Matches
the symmetric path in applyInvoiceReturnViaCreditNote.
applyInvoiceReturnViaCreditNote (#3): stamp pro.refundTimestamp /
refundedBy / refundAmount unconditionally rather than gated on
totalRefundAmount > 0. Defensive idempotency on the state machine: a
0-amount approve (corner case where the invoice's line items are already
fully returned via a sibling DN flow) used to leave the PRO in pending
state, allowing a second Approve click to issue a duplicate CN at NIC.
rejectReturn non-serialized reversal (#5): the reversal loop was gated
on inventoryItem.serialNumber being non-blank, leaving non-serialized
GOOD items' SALE_RET +1 increments un-reversed on rejection — phantom
warehouse stock. Now mirrors applyReceipt's nonSerialWhItemMap pattern
(orderId|itemId) and reverses both serialized and non-serialized.
Conservative addQuantity(-1) gate retained: only fires when lastScanType
== SALE_RET, matching the prior serialized behaviour.