fix(pricing): add null conditions for deleted at during price calculations (#10896)
This commit is contained in:
1 parent
6747a1564b
commit
3fec01ab49
3 files changed
+75
-1
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/pricing": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(pricing): add null conditions for deleted at during price calculations
|
||||||
+68
@@ -1814,6 +1814,74 @@ moduleIntegrationTestRunner<IPricingModuleService>({
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should not return price list prices when price is deleted", async () => {
|
||||||
|
const [priceList] = await createPriceLists(
|
||||||
|
service,
|
||||||
|
{},
|
||||||
|
{ region_id: ["DE", "PL"] },
|
||||||
|
[
|
||||||
|
{
|
||||||
|
amount: 111,
|
||||||
|
currency_code: "PLN",
|
||||||
|
price_set_id: "price-set-PLN",
|
||||||
|
rules: {
|
||||||
|
region_id: "DE",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
const priceSetsResult1 = await service.calculatePrices(
|
||||||
|
{ id: ["price-set-EUR", "price-set-PLN"] },
|
||||||
|
{
|
||||||
|
context: {
|
||||||
|
currency_code: "PLN",
|
||||||
|
region_id: "DE",
|
||||||
|
customer_group_id: "vip-customer-group-id",
|
||||||
|
company_id: "medusa-company-id",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(priceSetsResult1).toEqual([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: "price-set-PLN",
|
||||||
|
is_calculated_price_price_list: true,
|
||||||
|
calculated_amount: 111,
|
||||||
|
is_original_price_price_list: false,
|
||||||
|
original_amount: 400,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
|
||||||
|
const test = await service.softDeletePrices(
|
||||||
|
priceList.prices.map((p) => p.id)
|
||||||
|
)
|
||||||
|
|
||||||
|
console.log("test -- ", JSON.stringify(test, null, 4))
|
||||||
|
|
||||||
|
const priceSetsResult2 = await service.calculatePrices(
|
||||||
|
{ id: ["price-set-EUR", "price-set-PLN"] },
|
||||||
|
{
|
||||||
|
context: {
|
||||||
|
currency_code: "PLN",
|
||||||
|
region_id: "DE",
|
||||||
|
customer_group_id: "vip-customer-group-id",
|
||||||
|
company_id: "medusa-company-id",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(priceSetsResult2).toEqual([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: "price-set-PLN",
|
||||||
|
is_calculated_price_price_list: false,
|
||||||
|
calculated_amount: 400,
|
||||||
|
is_original_price_price_list: false,
|
||||||
|
original_amount: 400,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("Tax inclusivity", () => {
|
describe("Tax inclusivity", () => {
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ export class PricingRepository
|
|||||||
min_quantity: "price.min_quantity",
|
min_quantity: "price.min_quantity",
|
||||||
max_quantity: "price.max_quantity",
|
max_quantity: "price.max_quantity",
|
||||||
currency_code: "price.currency_code",
|
currency_code: "price.currency_code",
|
||||||
|
deleted_at: "price.deleted_at",
|
||||||
price_set_id: "price.price_set_id",
|
price_set_id: "price.price_set_id",
|
||||||
rules_count: "price.rules_count",
|
rules_count: "price.rules_count",
|
||||||
price_list_id: "price.price_list_id",
|
price_list_id: "price.price_list_id",
|
||||||
@@ -268,7 +269,7 @@ export class PricingRepository
|
|||||||
.join(priceSubQueryKnex.as("price"), "price.price_set_id", "ps.id")
|
.join(priceSubQueryKnex.as("price"), "price.price_set_id", "ps.id")
|
||||||
.whereIn("ps.id", pricingFilters.id)
|
.whereIn("ps.id", pricingFilters.id)
|
||||||
.andWhere("price.currency_code", "=", currencyCode)
|
.andWhere("price.currency_code", "=", currencyCode)
|
||||||
|
.whereNull("price.deleted_at")
|
||||||
.orderBy([
|
.orderBy([
|
||||||
{ column: "price.has_price_list", order: "asc" },
|
{ column: "price.has_price_list", order: "asc" },
|
||||||
{ column: "all_rules_count", order: "desc" },
|
{ column: "all_rules_count", order: "desc" },
|
||||||
|
|||||||
Reference in new issue
Block a user