Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-moments-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@epilot/pricing': patch
---

Improve tier display string
10 changes: 5 additions & 5 deletions src/tiers/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ describe('getTierDescription', () => {
${PricingModel.tieredVolume} | ${tierWithUnitAmount} | ${'kWh'} | ${'de'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${false} | ${undefined} | ${undefined} | ${'Starts at 10,00 €/kWh'}
${PricingModel.tieredVolume} | ${tierWithUnitAmount} | ${'kWh'} | ${'en'} | ${'USD'} | ${mockedTranslationFn} | ${true} | ${false} | ${undefined} | ${undefined} | ${'Starts at $10.00/kWh'}
${PricingModel.tieredVolume} | ${tierWithUnitAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${true} | ${undefined} | ${undefined} | ${'Starts at €10.00/kWh'}
${PricingModel.tieredVolume} | ${tierWithSubunitAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${true} | ${undefined} | ${undefined} | ${'Starts at 5.12 cents/kWh'}
${PricingModel.tieredVolume} | ${tierWithSubunitAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${true} | ${undefined} | ${undefined} | ${'Starts at 5.123412 cents/kWh'}
${PricingModel.tieredVolume} | ${tierWithSubunitAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${true} | ${undefined} | ${4} | ${'Starts at 5.1234 cents/kWh'}
${PricingModel.tieredVolume} | ${tierWithUnitAmount} | ${undefined} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${false} | ${undefined} | ${undefined} | ${'Starts at €10.00'}
${PricingModel.tieredVolume} | ${tierWithUnitAmount} | ${'unit'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${false} | ${undefined} | ${undefined} | ${'Starts at €10.00'}
Expand Down Expand Up @@ -261,10 +261,10 @@ describe('getTierDescription', () => {

it.each`
pricingModel | tier | unit | locale | currency | t | showStartsAt | enableSubunitDisplay | shouldDisplayOnRequest | tax | expected
${PricingModel.tieredGraduated} | ${tierWithUnitAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${false} | ${undefined} | ${{ isInclusive: true, rate: 10 }} | ${'Starts at €9.09/kWh'}
${PricingModel.tieredVolume} | ${tierWithUnitAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${false} | ${undefined} | ${{ isInclusive: true, rate: 10 }} | ${'Starts at €9.09/kWh'}
${PricingModel.tieredVolume} | ${tierWithSubunitAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${true} | ${undefined} | ${{ isInclusive: true, rate: 10 }} | ${'Starts at 4.66 cents/kWh'}
${PricingModel.tieredFlatFee} | ${tierWithFlatFeeAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${false} | ${undefined} | ${{ isInclusive: true, rate: 10 }} | ${'Starts at €9.09'}
${PricingModel.tieredGraduated} | ${tierWithUnitAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${false} | ${undefined} | ${{ isInclusive: true, rate: 10 }} | ${'Starts at €9.090909090909/kWh'}
${PricingModel.tieredVolume} | ${tierWithUnitAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${false} | ${undefined} | ${{ isInclusive: true, rate: 10 }} | ${'Starts at €9.090909090909/kWh'}
${PricingModel.tieredVolume} | ${tierWithSubunitAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${true} | ${undefined} | ${{ isInclusive: true, rate: 10 }} | ${'Starts at 4.657647 cents/kWh'}
${PricingModel.tieredFlatFee} | ${tierWithFlatFeeAmount} | ${'kWh'} | ${'en'} | ${'EUR'} | ${mockedTranslationFn} | ${true} | ${false} | ${undefined} | ${{ isInclusive: true, rate: 10 }} | ${'Starts at €9.090909090909'}
`(
'should return correct net values for the tier, when pricingModel=$pricingModel, unit=$unit, locale=$locale, currency=$currency, showStartsAt=$showStartsAt',
({
Expand Down
4 changes: 2 additions & 2 deletions src/tiers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function getTierDescription(
return;
}

const { showStartsAt = true, enableSubunitDisplay = false, precision = 2 } = options;
const { showStartsAt = true, enableSubunitDisplay = false, precision } = options;
const showUnitAmount =
(pricingModel === PricingModel.tieredGraduated || pricingModel === PricingModel.tieredVolume) &&
typeof tier.unit_amount === 'number';
Expand All @@ -161,7 +161,7 @@ export function getTierDescription(
currency,
locale,
enableSubunitDisplay,
precision,
...(precision !== undefined ? { precision } : { useRealPrecision: true }),
};

const unitAmountDecimal =
Expand Down
Loading