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 16:07:44 +02:00
committed by GitHub
parent b7b0a7d3a4
commit 5ac7f08e4d
6 changed files with 289 additions and 69 deletions

View File

@@ -8,16 +8,16 @@
"build": "babel src -d dist --extensions \".ts,.js\""
},
"dependencies": {
"@medusajs/medusa": "1.3.4-dev-1658251581042",
"@medusajs/medusa": "1.3.5-dev-1661328147668",
"faker": "^5.5.3",
"medusa-interfaces": "1.3.1-dev-1658251581042",
"medusa-interfaces": "1.3.2-dev-1661328147668",
"typeorm": "^0.2.31"
},
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/node": "^7.12.10",
"babel-preset-medusa-package": "1.1.19-dev-1658251581042",
"babel-preset-medusa-package": "1.1.19-dev-1661328147668",
"jest": "^26.6.3"
}
}