fix(admin): OrderEdit display of difference due with refund (#3487)
**What** - fix `difference_due` in the OE modal to show the correct difference a user has to pay - fix Timeline crashing due to returned line item being `undefined `(deleted after OE confirmation) **Why** We were taking into account `refunded_amount` when calculating "Difference Due" and used the following formula: `orderEdit.total - paidTotal + refundedTotal`. The issue here is that `orderEdit.total` is "overpriced" for the amount of items that are returned/refunded already (i.e. we are charging the user again for the returned items). The straightforward solution would be to subtract `refunded_total` from the `orderEdit.total` to get the total cost of items the user is actually getting after the edit. `difference_due = (orderEdit.total - refundedTotal) - (paidTotal - refundedTotal ) = orderEdit.total - paidTotal` But if we have partially refunded returns, we would have the same problem of returned items priced into the total. In that case, general solution should be something like: `diff_due_display = orderEdit_total_of_items_user_is_getting - paid_total + refunded_total` Would like to hear what you guys think! --- FIXES CORE-1246
This commit is contained in:
@@ -23,10 +23,7 @@ const PaymentRequired: React.FC<RequestedProps> = ({ event }) => {
|
||||
}
|
||||
|
||||
const amount = requestedEditDifferenceDue
|
||||
? order.total +
|
||||
order.refunded_total -
|
||||
order.paid_total +
|
||||
requestedEditDifferenceDue
|
||||
? order.total - order.paid_total + requestedEditDifferenceDue
|
||||
: order.refunded_total - order.paid_total
|
||||
|
||||
if (amount <= 0) {
|
||||
|
||||
Reference in New Issue
Block a user