feat: Add necessary middlewares for tax inclusive pricing (#7827)

We are adding tax inclusive pricing calculation when listing products.

Two things to keep in mind:
- `region_id` will be required if you request calculated prices.
- We won't accept `currency_code` anymore, as that will come from the region info (since ultimately a cart and its currency are tied to a region)

REF CORE-2376
DEPENDS ON #8003
This commit is contained in:
Stevche Radevski
2024-07-09 09:37:13 +00:00
committed by GitHub
parent db6969578f
commit 1c3ef13371
22 changed files with 824 additions and 121 deletions
@@ -1449,6 +1449,39 @@ moduleIntegrationTestRunner<IPricingModuleService>({
])
})
it("should return the region tax inclusivity for the selected price when there are multiple region preferences", async () => {
await (service as any).createPricePreferences([
{
attribute: "region_id",
value: "DE",
is_tax_inclusive: false,
},
{
attribute: "region_id",
value: "PL",
is_tax_inclusive: true,
},
])
const priceSetsResult = await service.calculatePrices(
{ id: ["price-set-PLN"] },
{
context: { currency_code: "PLN", region_id: "PL" },
}
)
expect(priceSetsResult).toEqual([
expect.objectContaining({
id: "price-set-PLN",
is_calculated_price_tax_inclusive: true,
calculated_amount: 300,
is_original_price_tax_inclusive: true,
original_amount: 300,
currency_code: "PLN",
}),
])
})
it("should return the appropriate tax inclusive setting for each calculated and original price", async () => {
await createPriceLists(service, {}, {})
await (service as any).createPricePreferences([