Files
medusa-store/packages/admin-ui
Frane Polić bd199d7f44 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
2023-03-24 16:59:15 +00:00
..

Medusa

@medusajs/admin-ui

Documentation | Medusa Admin Demo | Website

An open source composable commerce engine built for developers.

Medusa is released under the MIT license. Current CircleCI build status. PRs welcome! Product Hunt Discord Chat Follow @medusajs

The Medusa Admin App. Included with the @medusajs/admin plugin. You shouldn't install this package separately.