Skip to content
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

[$250] Distance - Rate on confirmation page shows 3 decimal value for a 4-digit decimal value rate #49929

Open
6 tasks done
lanitochka17 opened this issue Sep 30, 2024 · 32 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Sep 30, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.41-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): applausetester+kh010901@applause.expensifail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Distance rates
  3. Click on any distance rate
  4. Change the distance rate to 4-digit decimal value (non-zero) and save it
  5. Go to workspace chat
  6. Click + > Submit expense > Distance
  7. Enter waypoints and proceed to confirmation page
  8. Click Rate
  9. Select the 4-digit decimal value rate in Step 4
  10. Note that the rate list only shows 3 decimal value instead of 4
  11. Submit the distance expense
  12. Go to transaction thread and open the receipt
  13. Note that the expense preview and distance receipt shows the complete rate which is 4-digit decimal value

Expected Result:

In Step 10, the rate list should show the complete decimal value (eg, 1.2345)

Actual Result:

In Step 10, the rate list only shows 3 decimal value (eg, 1.234)
In Step 13, the expense preview and distance receipt shows 4 decimal value which is the complete rate (eg, 1.2345)
The rate format is not consistent in the rate list and distance receipt

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6618594_1727539618646.20240929_000027.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021841311378926667676
  • Upwork Job ID: 1841311378926667676
  • Last Price Increase: 2024-10-09
  • Automatic offers:
    • allgandalf | Contributor | 104470034
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 30, 2024
Copy link

melvin-bot bot commented Sep 30, 2024

Triggered auto assignment to @kadiealexander (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@lanitochka17
Copy link
Author

@kadiealexander FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@NJ-2020
Copy link
Contributor

NJ-2020 commented Sep 30, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Distance - Rate on confirmation page shows 3 decimal value for a 4-digit decimal value rate

What is the root cause of that problem?

Right here the Rate Decimal for displaying Rate is 3 which is wrong

App/src/CONST.ts

Line 2402 in 0e3b82c

RATE_DECIMALS: 3,

And same here
const fixedDecimalPoints = decimalPart.length > 2 && !decimalPart.endsWith('0') ? 3 : 2;

What changes do you think we should make in order to solve the problem?

We should change it to 4

Result

Screen.Recording.2024-09-30.at.07.00.01.mov

What alternative solutions did you explore? (Optional)

@abzokhattab
Copy link
Contributor

i think this is caused by this PR

@thelullabyy
Copy link

Proposal

Please re-state the problem that we are trying to solve in this issue.

We have an inconsistency in the number of decimal places for the distance rate.

What is the root cause of that problem?

In this PR #49773, we decided to always display 4 decimals for all currencies. But we haven't updated this function getRateDisplayValue function.

What changes do you think we should make in order to solve the problem?

Update to display 4 decimals

return Number(numValue).toFixed(fixedDecimalPoints).toString().replace('.', toLocaleDigit('.'));

        return Number(numValue).toFixed(CONST.MAX_TAX_RATE_DECIMAL_PLACES).toString().replace('.', toLocaleDigit('.'));

return numValue.toFixed(CONST.CUSTOM_UNITS.RATE_DECIMALS);

       return numValue.toFixed(CONST.MAX_TAX_RATE_DECIMAL_PLACES);

I see one more edge case when rate is 166.9800 (There are some zeros in the end), should we display zeros? Currently, we also display inconsistency in this case

  1. If yes, (we need to update how we display rates in the money request flow)

return numValue.toString().replace('.', toLocaleDigit('.')).substring(0, value.toString().length);

Remove .substring(0, value.toString().length);

  1. If no, (we need to update how we display rates distance rate page)

minimumFractionDigits: CONST.MAX_TAX_RATE_DECIMAL_PLACES,

        minimumFractionDigits: 2,
        maximumFractionDigits: 4,

Another problem in the update rate message, the rate only display 2 decimals. But this data is get from originalMessage. If we want to update it, we need to fix on the BE side or make a workaround on FE (detail later if needed)

Screenshot 2024-10-01 at 10 48 19

What alternative solutions did you explore? (Optional)

Copy link

melvin-bot bot commented Oct 1, 2024

📣 @thelullabyy! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

Copy link

melvin-bot bot commented Oct 1, 2024

⚠️ Invalid email. Please make sure to create an Expensify account with this email first here.

Copy link

melvin-bot bot commented Oct 1, 2024

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@kadiealexander kadiealexander added External Added to denote the issue can be worked on by a contributor Hourly KSv2 labels Oct 2, 2024
@melvin-bot melvin-bot bot changed the title Distance - Rate on confirmation page shows 3 decimal value for a 4-digit decimal value rate [$250] Distance - Rate on confirmation page shows 3 decimal value for a 4-digit decimal value rate Oct 2, 2024
@kadiealexander kadiealexander removed the Daily KSv2 label Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

Job added to Upwork: https://www.upwork.com/jobs/~021841311378926667676

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 2, 2024
@kadiealexander kadiealexander added the Daily KSv2 label Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat (External)

@kadiealexander kadiealexander removed the Hourly KSv2 label Oct 2, 2024
@parasharrajat
Copy link
Member

This seems like a regression from #49773. cc: @DylanDylann @daledah

@DylanDylann
Copy link
Contributor

@parasharrajat Hmm, In #49773, we decided to mirror the Olddot behavior and always use a 4-digit decimal on the rate value.

About this bug, I think this is a new requirement for the update distance rate on the request money flow to use of 4-digit decimals, because this issue also happens on the Olddot

Screen.Recording.2024-10-03.at.10.59.06.mov

@DylanDylann
Copy link
Contributor

I just glanced at proposals and noticed that @thelullabyy mentioned a valuable point

I see one more edge case when rate is 166.9800 (There are some zeros in the end), should we display zeros? Currently, we also display inconsistency in this case

@parasharrajat
Copy link
Member

Ok. thanks for the input. let me review the proposals in that case.

@ChavdaSachin
Copy link
Contributor

ChavdaSachin commented Oct 5, 2024

Edited by proposal-police: This proposal was edited at 2024-10-05 23:59:46 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Rate on confirmation page shows 3 decimal value for a 4-digit decimal value rate

What is the root cause of that problem?

What changes do you think we should make in order to solve the problem?

  • First update RATE_DECIMALS: 4

    App/src/CONST.ts

    Line 2411 in 99f280b

    RATE_DECIMALS: 3,
  • Now update fixedDecimalPoints logic here, based on if we want to hide appending zeroes or not.
    const fixedDecimalPoints = decimalPart.length > 2 && !decimalPart.endsWith('0') ? 3 : 2;
  • An additional problem we face after such update is for currency which do not support decimals.(ex. ALL)
check this video

parameter: currency- ALL, rate-0.6799, distance-74.59mil, from New York to New Jersey.

Screen.Recording.2024-10-06.at.5.07.35.AM.mov
  • When we display amount on report page we roundoff the amount according to currency. but when we try to edit the amount, edit amount page actually rips off the digits after decimal points for currencies which do not support decimals. which causes inconsistency between amount displayed on report page and amount displayed on edit amount page.

To solve this problem we need to start rounding off amount on IOUStepAmount instead of ripping of the digits after decimal point.

        setNewAmount(Number(currentAmount).toFixed());

setNewAmount(MoneyRequestUtils.stripDecimalsFromAmount(currentAmount));

And some cleanup.

And need some additional changes from BE, the generated message when changing distance rate only has 3 decimal places so BE now need to return amount with 4 decimal places.
Screenshot 2024-10-06 at 5 29 06 AM

Optional
Generally we store amount value by multiplying it with 100 to avoid storing floating values, for the same reason we should start to store rate amount by multiplying it with 10000 and make a workflow around.

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@melvin-bot melvin-bot bot added the Overdue label Oct 5, 2024
Copy link

melvin-bot bot commented Oct 7, 2024

@parasharrajat, @kadiealexander Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@kadiealexander
Copy link
Contributor

@parasharrajat bump on the reviews!

@melvin-bot melvin-bot bot removed the Overdue label Oct 8, 2024
Copy link

melvin-bot bot commented Oct 9, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@parasharrajat
Copy link
Member

Because this problem is about the display of currency, I like @thelullabyy's proposal. They picked a few related cases to this issue.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Oct 9, 2024

Triggered auto assignment to @puneetlath, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 10, 2024
Copy link

melvin-bot bot commented Oct 10, 2024

📣 @thelullabyy You have been assigned to this job!
Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
Keep in mind: Code of Conduct | Contributing 📖

@ChavdaSachin
Copy link
Contributor

ChavdaSachin commented Oct 10, 2024

@parasharrajat

Here in my Proposal I have mentioned an additional problem which will arise afterwards , If you think that issue is out of scope here, then we could raise a new issue for the same. Otherwise I request you to assign this issue to me or at least let me and @thelullabyy work here collaboratively.

Thank you.

cc. @puneetlath

@melvin-bot melvin-bot bot added the Overdue label Oct 14, 2024
Copy link

melvin-bot bot commented Oct 14, 2024

@puneetlath @parasharrajat @kadiealexander @thelullabyy this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@kadiealexander
Copy link
Contributor

@thelullabyy could you please provide an update here? Thank you!

@thelullabyy
Copy link

@kadiealexander I'll open a PR soon.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Oct 15, 2024
@thelullabyy
Copy link

@parasharrajat This PR is ready for review.

@allgandalf
Copy link
Contributor

I can take this as C+ ) if this is critical while @parasharrajat is OOO until Oct 25

@puneetlath
Copy link
Contributor

@allgandalf are you ok with splitting the C+ bounty since @parasharrajat already did the proposal review? If so, please go ahead.

@allgandalf
Copy link
Contributor

yeah no worries at all, thanks

Copy link

melvin-bot bot commented Oct 17, 2024

📣 @allgandalf 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@allgandalf
Copy link
Contributor

@puneetlath can you take a look here once you find time, thanks :)

@parasharrajat
Copy link
Member

parasharrajat commented Oct 26, 2024

Looks like @allgandalf took it. I can continue reviewing this if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
No open projects
Status: Polish
Development

No branches or pull requests

10 participants