From ee9065e38557560f8c4d87651f198fdc2da8d022 Mon Sep 17 00:00:00 2001 From: Julian Maurer Date: Wed, 18 Dec 2024 17:24:17 +0100 Subject: [PATCH] Fix calculation of recurrences with estimated prices for simple prices --- src/pricing.test.ts | 6 ++++++ src/pricing.ts | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pricing.test.ts b/src/pricing.test.ts index 889fe7d..e5c920e 100644 --- a/src/pricing.test.ts +++ b/src/pricing.test.ts @@ -682,6 +682,8 @@ describe('getRecurrencesWithEstimatedPrices', () => { type: 'recurring', billing_period: 'monthly', _price: { + type: 'recurring', + billing_period: 'monthly', price_display_in_journeys: 'estimated_price' } } @@ -689,6 +691,7 @@ describe('getRecurrencesWithEstimatedPrices', () => { const oneTimeEstimateComponent = { type: 'one_time', _price: { + type: 'one_time', price_display_in_journeys: 'estimated_price' } } @@ -697,6 +700,8 @@ describe('getRecurrencesWithEstimatedPrices', () => { type: 'recurring', billing_period: 'monthly', _price: { + type: 'recurring', + billing_period: 'monthly', price_display_in_journeys: 'show_price' } } @@ -704,6 +709,7 @@ describe('getRecurrencesWithEstimatedPrices', () => { const oneTimeComponent = { type: 'one_time', _price: { + type: 'one_time', price_display_in_journeys: 'show_price' } } diff --git a/src/pricing.ts b/src/pricing.ts index af4cfdf..7e682bb 100644 --- a/src/pricing.ts +++ b/src/pricing.ts @@ -1269,7 +1269,8 @@ export const getRecurrencesWithEstimatedPrices = (lineItems: PriceItems | undefi } }); } else { - const recurrence = lineItem.type === 'recurring' ? lineItem.billing_period : lineItem.type; + const recurrence = + lineItem._price?.type === 'recurring' ? lineItem._price?.billing_period : lineItem._price?.type; if (recurrence !== undefined) { recurrences[recurrence] =