[web] Remove redundant annualDividedByTwelve from pricing tables (#35507)

* [web] Add snapshot test for all annualDividedByTwelve values

Captures the 85 stored values into a JSON fixture and asserts the
effective value (stored field, or PlansHelper.roundedTwelfth(annual)
once the field is derived at runtime) matches. Verification harness for
the annualDividedByTwelve refactor.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [web] Compute annualDividedByTwelve at runtime instead of hardcoding it

* [web] Update annualDividedByTwelve snapshot for the rounding rule

The runtime derivation reproduces 84 of the 85 historical values exactly.
The one difference is PEN assistant, which was historically stored
unrounded (350 / 12 = 29.1667) and now follows the round-up-to-0.05 rule
(29.20). The assistant add-on is unavailable, so this is not user-visible.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Remove `localizedAddOnsPricing` from test

* Add more sanity tests

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
GitOrigin-RevId: e60e8b3e90360817d4be3732243d242dc0cbb69e
This commit is contained in:
Antoine Clausse
2026-09-17 11:36:17 +00:00
committed by Copybot
co-authored by Claude Fable 5
parent 33e0a5e1c2
commit 59b4a67c2d
3 changed files with 31 additions and 2 deletions
@@ -15,7 +15,20 @@ export function isProfessionalGroupPlan(subscription) {
return subscription.groupPlan && isProfessional
}
/**
* The per-month price shown when a plan or add-on is billed annually: the
* annual price divided by twelve, rounded up to the nearest 0.05 for a tidy
* display value.
*
* @param {number} annual
* @returns {number}
*/
export function roundedTwelfth(annual) {
return Math.round(Math.ceil(annual / 12 / 0.05) * 5) / 100
}
export default {
isProfessionalPlan,
isProfessionalGroupPlan,
roundedTwelfth,
}
@@ -43,7 +43,6 @@ describe('ProjectController', function () {
collaborator: {
monthly: 15,
annual: 180,
annualDividedByTwelve: 15,
},
},
},
@@ -1602,7 +1601,6 @@ describe('ProjectController', function () {
assistant: {
annual: 60,
monthly: 5,
annualDividedByTwelve: 5,
},
},
}
@@ -0,0 +1,18 @@
import { describe, expect, it } from 'vitest'
import { roundedTwelfth } from '../../../../app/src/Features/Subscription/PlansHelper.mjs'
describe('PlansHelper', function () {
describe('roundedTwelfth', function () {
it('divides by twelve when the result is already a multiple of 0.05', function () {
expect(roundedTwelfth(120)).to.equal(10)
expect(roundedTwelfth(180)).to.equal(15)
})
it('rounds up to the nearest 0.05 for display', function () {
// 263 / 12 = 21.9166… -> 21.95
expect(roundedTwelfth(263)).to.equal(21.95)
// 505 / 12 = 42.0833… -> 42.1
expect(roundedTwelfth(505)).to.equal(42.1)
})
})
})