fix(utils,core-flows): subtotal calculation and returns location (#13497)
* fix(utils,core-flows): subtotal calculation and returns location * changeset * fix test * var * rm extra field from test * fix original total * fix partial refunds and pending difference * fix test * fix test * test * extract to util * original total and update payment when receive return * original_subtotal * default fields * test * calculate pending difference * revert claims test * pending difference * creadit line fix * if
This commit is contained in:
committed by
GitHub
parent
4736c58da5
commit
9563ee446f
@@ -224,7 +224,7 @@ export class OrderChangeProcessing {
|
||||
return orderSummary
|
||||
}
|
||||
|
||||
// Calculate the order summary from a calculated order including taxes
|
||||
// Returns the order summary from a calculated order including taxes
|
||||
public getSummaryFromOrder(order: OrderDTO): OrderSummaryDTO {
|
||||
const summary_ = this.summary
|
||||
const total = order.total
|
||||
@@ -241,35 +241,6 @@ export class OrderChangeProcessing {
|
||||
|
||||
orderSummary.accounting_total = orderSummary.current_order_total
|
||||
|
||||
orderSummary.pending_difference = MathBN.sub(
|
||||
orderSummary.current_order_total,
|
||||
orderSummary.transaction_total
|
||||
)
|
||||
|
||||
// return total becomes pending difference
|
||||
for (const item of order.items ?? []) {
|
||||
const item_ = item as any
|
||||
|
||||
;[
|
||||
"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
|
||||
)
|
||||
|
||||
return orderSummary
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user