medusa icon indicating copy to clipboard operation
medusa copied to clipboard

[Bug] "Paid Total" is is incorrect if the order contains deleted discounts

Open maxpanakov opened this issue 1 year ago • 4 comments

Bug report

Describe the bug

paid_total will be less then total, if order has a discounts which is soft deleted

System information

Medusa version :1.20.1

Steps to reproduce the behavior

  1. Create the order from the cart with discount
  2. Delete the discount
  3. Compare paid_total with total

maxpanakov avatar Feb 01 '24 05:02 maxpanakov

Solution: inside OrderRepository

const ITEMS_REL_NAME = "items"
const REGION_REL_NAME = "region"
const DISCOUNTS_REL_NAME = "discounts"

const WITH_DELETED_REL_NAMES = [
    ITEMS_REL_NAME,
    REGION_REL_NAME,
    DISCOUNTS_REL_NAME
]
return this.find({
  withDeleted: WITH_DELETED_REL_NAMES.includes(topLevel),
})

maxpanakov avatar Feb 01 '24 06:02 maxpanakov

Nice catch, would you be up for sending a PR with the fix + test?

olivermrbl avatar Feb 04 '24 13:02 olivermrbl

@olivermrbl we ran into this issue as well, I opened a PR with the fix (https://github.com/medusajs/medusa/pull/6837)

pepijn-vanvlaanderen avatar Mar 27 '24 09:03 pepijn-vanvlaanderen

Thanks @pepijn-vanvlaanderen, will be part of next release.

olivermrbl avatar Mar 27 '24 09:03 olivermrbl