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:
@@ -336,7 +336,10 @@ function OrderEditModal(props: OrderEditModalProps) {
|
||||
currencyCode={currencyCode}
|
||||
amountPaid={paidTotal - refundedTotal}
|
||||
newTotal={orderEdit.total}
|
||||
differenceDue={orderEdit.total - paidTotal + refundedTotal}
|
||||
differenceDue={
|
||||
// TODO: more correct would be to have => diff_due = orderEdit_total_of_items_user_is_getting - paid_total + refunded_total
|
||||
orderEdit.total - paidTotal // (orderEdit_total - refunded_total) - (paidTotal - refundedTotal)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user