Skip to content

Commit

Permalink
Merge pull request #149 from epilot-dev/fix/estimated-simple-prices
Browse files Browse the repository at this point in the history
Fix calculation of recurrences with estimated prices for simple prices
  • Loading branch information
derjayjay authored Dec 19, 2024
2 parents dd91f38 + ee9065e commit 9d94489
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/pricing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,13 +682,16 @@ describe('getRecurrencesWithEstimatedPrices', () => {
type: 'recurring',
billing_period: 'monthly',
_price: {
type: 'recurring',
billing_period: 'monthly',
price_display_in_journeys: 'estimated_price'
}
}

const oneTimeEstimateComponent = {
type: 'one_time',
_price: {
type: 'one_time',
price_display_in_journeys: 'estimated_price'
}
}
Expand All @@ -697,13 +700,16 @@ describe('getRecurrencesWithEstimatedPrices', () => {
type: 'recurring',
billing_period: 'monthly',
_price: {
type: 'recurring',
billing_period: 'monthly',
price_display_in_journeys: 'show_price'
}
}

const oneTimeComponent = {
type: 'one_time',
_price: {
type: 'one_time',
price_display_in_journeys: 'show_price'
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down

0 comments on commit 9d94489

Please sign in to comment.