-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
fix: apply 4 decimal values for distance rate display #52609
fix: apply 4 decimal values for distance rate display #52609
Conversation
@allgandalf Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
// Rounding to 4 decimal places | ||
return parseFloat(numValue.toFixed(CONST.MAX_TAX_RATE_DECIMAL_PLACES)); |
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.
for my understanding, can you explain why that regression happened and how will this change fix it ?
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.
bump @thelullabyy
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.
@allgandalf Due to the way Javascript store floating points number, some divisions could result in false value, example:
console.log(11.11/100)
// expected: 0.1111
// actual: 0.11109999999999999
More info can be found in this SO
To fix this problem, we can:
- Fix the result in some digits (4 in this PR)
- Turn the divided number into integers by multiplying it with a big number (e.g. 10000) and perform devide after
In this PR I chose the first approach.
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.
That makes sense to me, thanks a lot for the info and SO
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.
@puneetlath , here's the fix and explanation for the last deploy blocker we faced
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-11-20.at.11.58.42.AM.movAndroid: mWeb ChromeScreen.Recording.2024-11-20.at.12.00.57.PM.moviOS: NativeScreen.Recording.2024-11-20.at.11.52.14.AM.moviOS: mWeb SafariScreen.Recording.2024-11-20.at.11.53.48.AM.movMacOS: Chrome / SafariScreen.Recording.2024-11-20.at.11.35.56.AM.movMacOS: DesktopScreen.Recording.2024-11-20.at.11.38.58.AM.mov |
@thelullabyy please remove this comment from the description: ![]() Also update the offline steps |
@allgandalf I already updated |
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.
LGTM!
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.
The changes seem fine to me. Do the unit tests cover the regression scenario that we saw?
I assume so, @thelullabyy can you confirm please |
@allgandalf @puneetlath The division is calculated in |
Ok so shall we add a unit test for getUnitRateValue then? |
That's a good idea!, @thelullabyy can you please add one? |
@allgandalf I added the tests. |
@allgandalf can you give it another review? |
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.
LGTM!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/puneetlath in version: 9.0.68-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.68-7 🚀
|
Explanation of Change
This PR fixes the dividing problem of Javascript where sometimes the divided value is not correct.
Example:
Fixed Issues
$ #52342
$ #49929
PROPOSAL: #49929 (comment)
Tests
Offline tests
Same above
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Screen.Recording.2024-11-15.at.16.44.58.mp4
Android: mWeb Chrome
Screen.Recording.2024-11-15.at.17.12.39.mp4
iOS: Native
Screen.Recording.2024-11-15.at.17.56.24.mp4
iOS: mWeb Safari
Screen.Recording.2024-11-15.at.17.30.58.mov
MacOS: Chrome / Safari
Screen.Recording.2024-11-15.at.15.13.27.mov
MacOS: Desktop
Screen.Recording.2024-11-15.at.18.04.56.mp4