[MON-1122] Changes the rounding mode to .down instead of .plain#5821
Conversation
📸 Snapshot Test12 modified, 468 unchanged
🛸 Powered by Emerge Tools |
ajpallares
left a comment
There was a problem hiding this comment.
Thank you for fixing this!
I was wondering if this is indeed the behavior we want, but I've seen the internal discussion where this is agreed 👍
|
By the way @polpielladev, there are some snapshots that have been modified now due to this change, which is expected. Yo can totally go ahead, take a look at them and approve if they look ok. Also, could you please run a @RCGitBot please test to run the full test suite? Thanks! |
|
@ajpallares Awesome, I do now have access to Emerge, so will go about fixing things shortly. Am I right in thinking that this change will the propagate to the hybrids without having to change the logic there? I saw a customer report from the capacitor SDK but I can also see that the logic there is pulled from the Purchases Hybrid Common repo, which should use the native SDK right? |
|
Am I right in thinking that this change will the propagate to the hybrids without having to change the logic there? I saw a customer report from the capacitor SDK but I can also see that the logic there is pulled from the Purchases Hybrid Common repo, which should use the native SDK right? That's right! 👍 |
60bc625 to
0fa4d09
Compare
|
@ajpallares It looks like I have some snapshot failures for the paywall tests, how do I re-record the snapshots? Is it documented somewhere? |
Ignore me, didn't take a closer look 😅 |
|
@tonidero I think @polpielladev meant this failure (https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/31809/workflows/65f93dd3-2212-489d-b87b-dfb30ee78b38/jobs/412055) from non-Emerge snapshots tests. He already run the workflow to re-generate them with the changes of this PR (https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/31819) and the automatically-generated PRs in purchases-ios-snapshots have already been merged |
|
Now @polpielladev, in your branch, you can just run to update the commit reference of After that, you can push the changes and the CI will build again, hopefully now with successful snapshot test run |
|
@RCGitBot please test |
|
@RCGitBot please test |
## Summary - Per-period price calculations (`pricePerWeek`, `pricePerMonth`, `pricePerYear`) were using `Math.round` / `Intl.NumberFormat` halfExpand rounding, causing prices like $83.99/yr to display as $7.00/mo instead of $6.99/mo - Added shared `floorMicrosToCurrencyUnit` helper with cached `Intl.NumberFormat` lookup and IEEE 754 epsilon correction - Fixed both code paths: `offerings.ts` (`toPricingPhase` entity builder) and `paywall-price-helpers.ts` (paywall variable formatting) - Matches iOS SDK behavior from [purchases-ios#5821](RevenueCat/purchases-ios#5821) ## Test plan - [x] Updated existing per-period price tests across 3 test files (538 total tests pass) - [x] Added unit tests for `floorMicrosToCurrencyUnit` covering USD, EUR, JPY, zero values, and FP epsilon - [x] TypeScript typecheck and ESLint pass - [ ] Manual verification with paywall displaying annual/6-month packages 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
When shipping Paywalls v2, there was a regression with the way that we show prices. We changed from not rounding or rounding down to actually rounding up.
Where this is specially important is when a dev picks a price that is explicitly designed to get just under a dollar threshold, like $83.99, which is either 6.99 or 7.00 — and 6.99 is the actual price they're aiming to put in front of customers.
Checklist
purchases-androidand hybrids