fix(types,medusa): calculate taxes for original price (#11692)

This commit is contained in:
Riqwan Thamir
2025-03-03 14:20:48 +01:00
committed by GitHub
parent 954136f13a
commit 51b0af193c
4 changed files with 108 additions and 0 deletions
@@ -2369,6 +2369,12 @@ medusaIntegrationTestRunner({
expect(products[0].variants[0].calculated_price).not.toHaveProperty(
"calculated_amount_without_tax"
)
expect(products[0].variants[0].calculated_price).not.toHaveProperty(
"original_amount_with_tax"
)
expect(products[0].variants[0].calculated_price).not.toHaveProperty(
"original_amount_without_tax"
)
})
it("should not return tax pricing if automatic taxes are off when listing products", async () => {
@@ -2386,6 +2392,12 @@ medusaIntegrationTestRunner({
expect(products[0].variants[0].calculated_price).not.toHaveProperty(
"calculated_amount_without_tax"
)
expect(products[0].variants[0].calculated_price).not.toHaveProperty(
"original_amount_with_tax"
)
expect(products[0].variants[0].calculated_price).not.toHaveProperty(
"original_amount_without_tax"
)
})
it("should return prices with and without tax for a tax inclusive region when listing products", async () => {
@@ -2430,6 +2442,66 @@ medusaIntegrationTestRunner({
)
})
it("should return prices with and without tax for a tax inclusive region when listing products with a price list sale", async () => {
const customerGroup = (
await api.post(
"/admin/customer-groups",
{ name: "VIP" },
adminHeaders
)
).data.customer_group
await api.post(
`/admin/customer-groups/${customerGroup.id}/customers`,
{ add: [customer.id] },
adminHeaders
)
await api.post(
`/admin/price-lists`,
{
title: "test price list",
description: "test",
status: PriceListStatus.ACTIVE,
type: PriceListType.SALE,
prices: [
{
amount: 35,
currency_code: euRegion.currency_code,
variant_id: product1.variants[0].id,
},
],
rules: { "customer.groups.id": [customerGroup.id] },
},
adminHeaders
)
const products = (
await api.get(
`/store/products?fields=id,*variants.calculated_price&region_id=${euRegion.id}&country_code=it`,
storeHeadersWithCustomer
)
).data.products
expect(products.length).toBe(2)
expect(products[0].variants).toEqual(
expect.arrayContaining([
expect.objectContaining({
calculated_price: expect.objectContaining({
currency_code: "eur",
calculated_amount: 35,
original_amount: 45,
is_calculated_price_price_list: true,
calculated_amount_with_tax: 38.5,
calculated_amount_without_tax: 35,
original_amount_with_tax: 45,
original_amount_without_tax: 40.90909090909091,
}),
}),
])
)
})
it("should return prices with and without tax for a tax exclusive region when listing products", async () => {
const products = (
await api.get(
@@ -2547,6 +2619,13 @@ medusaIntegrationTestRunner({
expect(product.variants[0].calculated_price).not.toHaveProperty(
"calculated_amount_without_tax"
)
expect(product.variants[0].calculated_price).not.toHaveProperty(
"original_amount_with_tax"
)
expect(product.variants[0].calculated_price).not.toHaveProperty(
"original_amount_without_tax"
)
})
it("should return prices with and without tax for a tax inclusive region when fetching a single product", async () => {