fix(draft-order): create tax-inclusive with discount (#2579)
**What** Fix system error (500) with DraftOrder create operation when payload includes discount in a tax-inclusive context. **How** * Ensure newly created cart contains all required relation in order to calculate line item tax-inclusive pricing with discounts. * Add resilience to TotalsService.getLineDiscounts() * Ensure newly generate line items have variant relation loaded. * fix TotalsService.getLineItemTotals to use the passed lineItem instead of relying on cartOrOrder.items. **Test** * Unit: * TotalsService.getLineDiscounts - coverage * Integration: * Admin API draft-order - coverage * Admin API draft-order create w/ discount in tax-inclusive Resolves: CORE-771 Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
co-authored by
Oliver Windall Juhl
Adrien de Peretti
parent
03fc9e18e9
commit
022a84691e
@@ -22,6 +22,7 @@ const {
|
||||
callGet,
|
||||
partial,
|
||||
} = require("../../../helpers/call-helpers")
|
||||
const { simpleShippingOptionFactory } = require("../../../factories")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -1760,6 +1761,12 @@ describe("/admin/orders", () => {
|
||||
it("creates a swap", async () => {
|
||||
const api = useApi()
|
||||
|
||||
await simpleShippingOptionFactory(dbConnection, {
|
||||
id: "testytest",
|
||||
is_return: true,
|
||||
region_id: "test-region",
|
||||
})
|
||||
|
||||
const response = await api.post(
|
||||
"/admin/orders/test-order/swaps",
|
||||
{
|
||||
@@ -1770,6 +1777,10 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
additional_items: [{ variant_id: "test-variant-2", quantity: 1 }],
|
||||
return_shipping: {
|
||||
option_id: "testytest",
|
||||
price: 400,
|
||||
},
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user