fix(medusa): Discount allocation precision issues (#3244)

This commit is contained in:
Adrien de Peretti
2023-02-13 17:22:18 +01:00
committed by GitHub
parent bbbb3d8882
commit 4cb44a3a2e
10 changed files with 306 additions and 40 deletions

View File

@@ -2569,15 +2569,13 @@ describe("/admin/order-edits", () => {
]),
}),
]),
// rounding issue since we are allocating 1/3 of the discount to one item and 2/3 to the other item where both cost 10
// resulting in adjustment amounts like: 1333...
discount_total: 2001,
total: 1099,
discount_total: 2000,
gift_card_total: 0,
gift_card_tax_total: 0,
shipping_total: 0,
subtotal: 3000,
tax_total: 100,
total: 1100,
})
)

View File

@@ -2210,16 +2210,18 @@ describe("/admin/products", () => {
expect(deleteRegionPriceResponse.status).toEqual(200)
expect(finalPriceArray).toHaveLength(2)
expect(finalPriceArray).toEqual([
expect.objectContaining({
amount: 1000,
currency_code: "usd",
}),
expect.objectContaining({
amount: 900,
currency_code: "eur",
}),
])
expect(finalPriceArray).toEqual(
expect.arrayContaining([
expect.objectContaining({
amount: 1000,
currency_code: "usd",
}),
expect.objectContaining({
amount: 900,
currency_code: "eur",
}),
])
)
})
it("successfully updates a variants prices by deleting both a currency and region price", async () => {