-
Notifications
You must be signed in to change notification settings - Fork 34
[MKT-846]:feat/new text for renewal #1958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jaaaaavier
wants to merge
3
commits into
master
Choose a base branch
from
feat/update-texts-for-annual-plan
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| export const formatPrice = (price: number) => { | ||
| const formattedAmount = Number(price.toFixed(2)); | ||
| return Number.isInteger(formattedAmount) ? formattedAmount.toString() : price.toFixed(2); | ||
| const truncated = Math.floor(Number(price.toFixed(8)) * 100) / 100; | ||
| return truncated.toFixed(2); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ import { CouponCodeData } from '@internxt/sdk/dist/drive/payments/types/types'; | |
|
|
||
| describe('Calculating final price of a product', () => { | ||
| it('When there is no coupon, returns base amount multiplied by users', () => { | ||
| expect(getProductAmount(10, 2)).toBe('20'); | ||
| expect(getProductAmount(10, 2)).toBe('20.00'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to introduce decimals when they are 00? Is this approved from product? I recall last time I had to remove them if they were .00. |
||
| }); | ||
|
|
||
| describe('When amountOff coupon is applied', () => { | ||
|
|
@@ -16,7 +16,7 @@ describe('Calculating final price of a product', () => { | |
| codeName: 'DISCOUNT', | ||
| }; | ||
|
|
||
| expect(getProductAmount(10, 2, coupon)).toBe('18'); | ||
| expect(getProductAmount(10, 2, coupon)).toBe('18.00'); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -29,7 +29,7 @@ describe('Calculating final price of a product', () => { | |
| codeName: 'HALFOFF', | ||
| }; | ||
|
|
||
| expect(getProductAmount(10, 3, coupon)).toBe('15'); | ||
| expect(getProductAmount(10, 3, coupon)).toBe('15.00'); | ||
| }); | ||
|
|
||
| it('Supports non-integer results rounded to 2 decimals', () => { | ||
|
|
@@ -44,8 +44,8 @@ describe('Calculating final price of a product', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('Handles case with 0 users gracefully (should return 0)', () => { | ||
| expect(getProductAmount(10, 0)).toBe('0'); | ||
| it('Handles case with 0 users gracefully (should return 0.00)', () => { | ||
| expect(getProductAmount(10, 0)).toBe('0.00'); | ||
| }); | ||
|
|
||
| describe('When discount results in negative price', () => { | ||
|
|
@@ -57,7 +57,7 @@ describe('Calculating final price of a product', () => { | |
| codeName: 'BIGDISCOUNT', | ||
| }; | ||
|
|
||
| expect(getProductAmount(10, 1, coupon)).toBe('0'); | ||
| expect(getProductAmount(10, 1, coupon)).toBe('0.00'); | ||
| }); | ||
|
|
||
| it('Returns 0 if percentOff is 100% or more', () => { | ||
|
|
@@ -68,7 +68,7 @@ describe('Calculating final price of a product', () => { | |
| codeName: 'FREE', | ||
| }; | ||
|
|
||
| expect(getProductAmount(10, 2, coupon)).toBe('0'); | ||
| expect(getProductAmount(10, 2, coupon)).toBe('0.00'); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using
toFixed(8)here? It looks arbitrary and makes the intent unclear.If the goal is simply truncating to 2 decimals,
Math.floor(price * 100) / 100should be enough.If this is a workaround for floating-point precision issues, it would be good to document it explicitly or use a more deterministic decimal handling approach.