Skip to content

Commit 4bae14c

Browse files
committed
fix(billing): price fractional seat-months to the cent
1 parent 5a2c3fa commit 4bae14c

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎apps/sim/lib/billing/plan-allowance.integration.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ describe('annual plan allowance', () => {
185185
const recorded = Number(row?.allowanceSeatMonths)
186186
expect(recorded).toBeCloseTo(3 * 12 + 2 * (60 / 30.44), 3)
187187
const { minimum } = await getOrgUsageLimit(organizationId, row as NonNullable<typeof row>)
188-
expect(minimum).toBeCloseTo(recorded * PRO_MONTHLY_DOLLARS, 2)
188+
expect(minimum).toBe(Math.round(recorded * PRO_MONTHLY_DOLLARS * 100) / 100)
189189
})
190190

191191
it('credits a seat added in the last days of the year for the days left', async () => {

‎apps/sim/lib/billing/subscriptions/utils.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ export function getOrgIncludedUsageDollars(subscription: OrgAllowanceInput): num
166166
}
167167
if (resolveBillingInterval(subscription) === 'year') {
168168
const monthly = getPlanPricing({ ...subscription, billingInterval: 'month', metadata: null })
169-
return getAnnualSeatMonths(subscription) * monthly.basePrice
169+
// Fractional seat-months price to the cent, the precision every limit is stored and edited in.
170+
return Math.round(getAnnualSeatMonths(subscription) * monthly.basePrice * 100) / 100
170171
}
171172
return (subscription.seats || 1) * getPlanPricing(subscription).basePrice
172173
}

0 commit comments

Comments
 (0)