-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[HOLD for payment 2023-10-05] [$500] [Distance] Some rates in the distance field have an excessive number of zeros added after the decimal point #27107
Comments
ProposalPlease re-state the problem that we are trying to solve in this issue.[Distance] Some rates in the distance field have an excessive number of zeros added after the decimal point What is the root cause of that problem?The result of this calculation is wrong App/src/libs/DistanceRequestUtils.js Line 78 in 57b7606
This is a problem of javascript like this What changes do you think we should make in order to solve the problem?Using decimal.js (this lib is used in package-lock.json) like this
What alternative solutions did you explore? (Optional)We also can round ratePerUnit by using the
|
ProposalPlease re-state the problem that we are trying to solve in this issue.[Distance] Some rates in the distance field have an excessive number of zeros added after the decimal point What is the root cause of that problem?This is the expected result in js when multiply point values see here for more details console.log(0.1 + 0.2) -> will print 0.30000000000000004 not 0.3 What changes do you think we should make in order to solve the problem?We need to use App/src/libs/DistanceRequestUtils.js Lines 72 to 82 in 0e836df
What alternative solutions did you explore? (Optional)we can use third party library like js-big-decimal.js or decimal.js |
ProposalPlease re-state the problem that we are trying to solve in this issue.Error displaying rate when requesting money What is the root cause of that problem?We use the function App/src/libs/DistanceRequestUtils.js Lines 72 to 82 in b11bddc
The problem with this line App/src/libs/DistanceRequestUtils.js Line 78 in b11bddc
When performing the calculation 128.3 * 0.01 in JavaScript, the returned result is not 1.283, but 1.2830000000000001. This comes from the way computers handle decimals in the floating-point system. What changes do you think we should make in order to solve the problem?To control the number of decimal places after the decimal point: const ratePerUnit = (rate * 0.01).toFixed(3); What alternative solutions did you explore? (Optional)If we want to remove unnecessary zeros after the decimal point: const ratePerUnit = Number((rate * 0.01).toFixed(3)); Or const ratePerUnit = Number((rate * 0.01)); |
ProposalPlease re-state the problem that we are trying to solve in this issue.Some rates in the distance field have an excessive number of zeros added after the decimal point What is the root cause of that problem?In App/src/libs/DistanceRequestUtils.js Line 78 in b11bddc
In other instances where the rate is displayed, we use
Furthermore, there are other inconsistencies. For example, here we multiply by 0.01, but in the other implementations we divide by What changes do you think we should make in order to solve the problem?We currently have 3 implementations for getting the rate value, with getRateDisplayValue (and getNumericValue) being essentially duplicated in the two files mentioned above. We should move getRateDisplayValue to a util file and use the same function everwhere (i.e. DistanceRequestUtils, WorkspaceRateAndUnitPage and WorkspaceRateAndUnitPage). This would solve the issue and also make the implementations consistent. Fixed result: What alternative solutions did you explore? (Optional)Option 1. Add |
Job added to Upwork: https://www.upwork.com/jobs/~010a1acc02586756aa |
Triggered auto assignment to @trjExpensify ( |
Bug0 Triage Checklist (Main S/O)
|
Triggered auto assignment to @strepanier03 ( |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @burczu ( |
@hayata-suenaga putting this one on your radar and adding it to the project board! ![]() |
Reviewed all the proposals and all of them are correct in my opinion - I personally prefer just using the 🎀 👀 🎀 C+ reviewed |
Triggered auto assignment to @luacmartins, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
@burczu In both WorkspaceRateAndUnitPage and WorkspaceReimburseView we use the There's also another difference in implementation: * 0.01 (hard-coded value) is done here instead of dividing by 100 (CONST.POLICY.CUSTOM_UNIT_RATE_BASE_OFFSET) that is done in |
@samh-nl I see that it is the same idea using toFixed method to avoid this issue |
hmm I think using |
@luacmartins Yes, I agree. |
In that case it seems like we should go with @samh-nl's proposal. |
📣 @hichamcc We're missing your Upwork ID to automatically send you an offer for the Reporter role. |
Assigned @samh-nl to the issue |
PR is ready for review: #27816 |
Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:
On to the next one 🚀 |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.74-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2023-10-05. 🎊 After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
For reference, here are some details about the assignees on this issue:
As a reminder, here are the bonuses/penalties that should be applied for any External issue:
|
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
👋 @burczu can you complete the checklist please so we can proceed with payments? Thanks! |
@burczu, @trjExpensify, @luacmartins, @samh-nl Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
Same, awaiting the checklist. |
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
@trjExpensify accepted |
settled up with you both. Closing! |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
Expected Result:
the rate in the Distance field should be 1.283
Actual Result:
the rate in the Distance field: 1.283000000000...
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.3.66.3
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Recording.4363.mp4
Expensify/Expensify Issue URL:
Issue reported by: @hichamcc
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693912703643649
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: