fix(medusa): Incorrect swap difference due (#2086)

### What
Creating a swap on an order with a discount leads to an incorrect difference due. 

**Scenario**
- Create a store with minimum 2 products (Prod A, Prod B)
- Create a discount that only works for Prod A
- Create an order for Prod A with the discount applied
- Create a swap between Prod A and Prod B

**Expected outcome**
We would expect the difference_due amount to come out to the sum of:
- -1 * (price of prod a - discount applied to prod a) 
- price of prod b

**Actual outcome**
Instead the discount is applied across both products when calculating difference due. This results in a total that is instead the sum of:
- -1 * (price of prod a - discount applied to prod a)
- price of prod b - discount on prod b ignoring the condition

### How
Adds `line_item.adjustments` to relations in cart retrieval prior to setting the difference_due to car total

Fixes CORE-361
This commit is contained in:
Oliver Windall Juhl
2022-08-24 14:07:44 +00:00
committed by GitHub
parent b7b0a7d3a4
commit 5ac7f08e4d
6 changed files with 289 additions and 69 deletions
@@ -30,6 +30,7 @@ describe("Order Totals", () => {
medusaProcess = await setupServer({ cwd })
} catch (error) {
console.log(error)
throw error
}
})