fix(pricing): Calculate price sets with amount 0 (#8622)
This commit is contained in:
+55
@@ -897,6 +897,61 @@ moduleIntegrationTestRunner<IPricingModuleService>({
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should return a price of 0", async () => {
|
||||||
|
const priceSet = await service.createPriceSets({
|
||||||
|
prices: [
|
||||||
|
{
|
||||||
|
amount: 0,
|
||||||
|
currency_code: "USD",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
const priceSetsResult = await service.calculatePrices(
|
||||||
|
{ id: [priceSet.id] },
|
||||||
|
{
|
||||||
|
context: {
|
||||||
|
currency_code: "USD",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(priceSetsResult).toEqual([
|
||||||
|
{
|
||||||
|
id: priceSet.id,
|
||||||
|
is_calculated_price_price_list: false,
|
||||||
|
is_calculated_price_tax_inclusive: false,
|
||||||
|
calculated_amount: 0,
|
||||||
|
raw_calculated_amount: {
|
||||||
|
value: "0",
|
||||||
|
precision: 20,
|
||||||
|
},
|
||||||
|
is_original_price_price_list: false,
|
||||||
|
is_original_price_tax_inclusive: false,
|
||||||
|
original_amount: 0,
|
||||||
|
raw_original_amount: {
|
||||||
|
value: "0",
|
||||||
|
precision: 20,
|
||||||
|
},
|
||||||
|
currency_code: "USD",
|
||||||
|
calculated_price: {
|
||||||
|
id: expect.any(String),
|
||||||
|
price_list_id: null,
|
||||||
|
price_list_type: null,
|
||||||
|
min_quantity: null,
|
||||||
|
max_quantity: null,
|
||||||
|
},
|
||||||
|
original_price: {
|
||||||
|
id: expect.any(String),
|
||||||
|
price_list_id: null,
|
||||||
|
price_list_type: null,
|
||||||
|
min_quantity: null,
|
||||||
|
max_quantity: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
describe("Price Lists", () => {
|
describe("Price Lists", () => {
|
||||||
it("should return price list prices when price list conditions match", async () => {
|
it("should return price list prices when price list conditions match", async () => {
|
||||||
await createPriceLists(service)
|
await createPriceLists(service)
|
||||||
|
|||||||
@@ -272,6 +272,7 @@ export default class PricingModuleService
|
|||||||
defaultPrice
|
defaultPrice
|
||||||
let originalPrice: PricingTypes.CalculatedPriceSetDTO | undefined =
|
let originalPrice: PricingTypes.CalculatedPriceSetDTO | undefined =
|
||||||
defaultPrice
|
defaultPrice
|
||||||
|
|
||||||
if (priceListPrice) {
|
if (priceListPrice) {
|
||||||
calculatedPrice = priceListPrice
|
calculatedPrice = priceListPrice
|
||||||
|
|
||||||
@@ -338,8 +339,9 @@ export default class PricingModuleService
|
|||||||
calculatedPrice.currency_code!,
|
calculatedPrice.currency_code!,
|
||||||
pricingContext.context?.region_id as string
|
pricingContext.context?.region_id as string
|
||||||
),
|
),
|
||||||
calculated_amount:
|
calculated_amount: isPresent(calculatedPrice?.amount)
|
||||||
parseFloat((calculatedPrice?.amount as string) || "") || null,
|
? parseFloat(calculatedPrice?.amount as string)
|
||||||
|
: null,
|
||||||
raw_calculated_amount: calculatedPrice?.raw_amount || null,
|
raw_calculated_amount: calculatedPrice?.raw_amount || null,
|
||||||
|
|
||||||
is_original_price_price_list: !!originalPrice?.price_list_id,
|
is_original_price_price_list: !!originalPrice?.price_list_id,
|
||||||
@@ -351,8 +353,9 @@ export default class PricingModuleService
|
|||||||
pricingContext.context?.region_id as string
|
pricingContext.context?.region_id as string
|
||||||
)
|
)
|
||||||
: false,
|
: false,
|
||||||
original_amount:
|
original_amount: isPresent(originalPrice?.amount)
|
||||||
parseFloat((originalPrice?.amount as string) || "") || null,
|
? parseFloat(originalPrice?.amount as string)
|
||||||
|
: null,
|
||||||
raw_original_amount: originalPrice?.raw_amount || null,
|
raw_original_amount: originalPrice?.raw_amount || null,
|
||||||
|
|
||||||
currency_code: calculatedPrice?.currency_code || null,
|
currency_code: calculatedPrice?.currency_code || null,
|
||||||
|
|||||||
Reference in New Issue
Block a user