fix(order): caculate received total for pending difference (#11919)
**What** - use the return received total to compute pending difference with return requested total **Why** - this would show incorrect outstanding amount when receiving a return and also, the outstanding amount after the return is received would be incorrect
This commit is contained in:
@@ -246,16 +246,25 @@ export class OrderChangeProcessing {
|
||||
orderSummary.transaction_total
|
||||
)
|
||||
|
||||
// return requested becomes pending difference
|
||||
// return total becomes pending difference
|
||||
for (const item of order.items ?? []) {
|
||||
const item_ = item as any
|
||||
|
||||
if (MathBN.gt(item_.return_requested_total, 0)) {
|
||||
orderSummary.pending_difference = MathBN.sub(
|
||||
orderSummary.pending_difference,
|
||||
item_.return_requested_total
|
||||
)
|
||||
}
|
||||
;[
|
||||
"return_requested_total",
|
||||
"return_received_total",
|
||||
// TODO: revisit this when we settle on which dismissed items need to be refunded
|
||||
// "return_dismissed_total",
|
||||
].forEach((returnTotalKey) => {
|
||||
const returnTotal = item_[returnTotalKey]
|
||||
|
||||
if (MathBN.gt(returnTotal, 0)) {
|
||||
orderSummary.pending_difference = MathBN.sub(
|
||||
orderSummary.pending_difference,
|
||||
returnTotal
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
orderSummary.pending_difference = new BigNumber(
|
||||
orderSummary.pending_difference
|
||||
|
||||
Reference in New Issue
Block a user