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-Decimals are not supported for this currency yet entering dot is allowed #49336

Open
3 of 6 tasks
IuliiaHerets opened this issue Sep 17, 2024 · 42 comments
Open
3 of 6 tasks
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

@IuliiaHerets
Copy link

IuliiaHerets commented Sep 17, 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.36-1
Reproducible in staging?: Y
Reproducible in production?: Y
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Go to profile icon --workspaces --workspace
  3. Change workspace currency to ALL
  4. Tap more features -- distance rate
  5. Tap on rate
  6. Enter decimal number with dot eg : 6.4
  7. Tap save
  8. Tap rate again

Expected Result:

Decimals are bit supported for this currency so user must not be allowed to enter dot.

Actual Result:

Decimals are not supported for this currency yet entering dot is displayed in distance rate page.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6606435_1726567186205.screenrecorder-2024-09-17-09-24-44-25_compress_1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021836536263898090209
  • Upwork Job ID: 1836536263898090209
  • Last Price Increase: 2024-09-18
  • Automatic offers:
    • DylanDylann | Reviewer | 104120435
Issue OwnerCurrent Issue Owner: @DylanDylann
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 17, 2024
Copy link

melvin-bot bot commented Sep 17, 2024

Triggered auto assignment to @alexpensify (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.

@IuliiaHerets
Copy link
Author

@alexpensify 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

@BhuvaneshPatil
Copy link
Contributor

BhuvaneshPatil commented Sep 17, 2024

Edited by proposal-police: This proposal was edited at 2024-09-17 11:35:39 UTC.

Proposal

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

Distance rate-Decimals are not supported for this currency yet entering dot is allowed

What is the root cause of that problem?

We are adding extra decimals prop here

This causes allowing one decimal to any currency.

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

We should remove that prop or set to different value based on the decimals supported for the currency

Note : We need to check with original contributor as to why this was set to 1, based on that we can change the value.

Same can be done in this component PolicyDistanceRateEditPage
We can always find and update pages where we are using distance rate add/update functionality

Update -
After this comment

We shall pass this comment

extraDecimals={TOTAL_DECIMALS - CurrencyUtils.getCurrencyDecimals(currency)}

TOTAL_DECIMALS is constant.

Incase of TOTAL_DECIMALS = 3

case 1: CurrencyUtils.getCurrencyDecimals(currency) returns 0 then final value will be 3
case 2: CurrencyUtils.getCurrencyDecimals(currency) returns 2 then passed values will be 1, and decimals will be 3

We can update this change where we take amount input

What alternative solutions did you explore? (Optional)

@Krishna2323
Copy link
Contributor

Krishna2323 commented Sep 17, 2024

Edited by proposal-police: This proposal was edited at 2024-09-17 11:38:52 UTC.

Proposal


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

Distance rate-Decimals are not supported for this currency yet entering dot is allowed

What is the root cause of that problem?

  • The extraDecimals props was introduced for specific cases like tax value and distance rates.
  • It assumes that all currency uses 2 decimal places but this doesn't apply to all currencies.
    // The default currency uses 2 decimal places, so we substract it
    extraDecimals={CONST.MAX_TAX_RATE_DECIMAL_PLACES - 2}

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


  • We should rename the extraDecimals prop to fixedDecimals.
  • In the AmountForm we should modify the line to const decimals = fixedDecimals ?? CurrencyUtils.getCurrencyDecimals(currency);
    const decimals = CurrencyUtils.getCurrencyDecimals(currency) + extraDecimals;
  • Update all the components which uses extraDecimals props.
  • Then we can pass 4 or 3 to fixedDecimals props.

What alternative solutions did you explore? (Optional)

  • We can introduce a new prop in AmountForm to use it instead of CurrencyUtils.getCurrencyDecimals(currency) if present.
    const decimals = CurrencyUtils.getCurrencyDecimals(currency) + extraDecimals;

What alternative solutions did you explore? (Optional 2)

  • Update to extraDecimals={getCurrencyDecimals(currency) ? 1 : 0}.
  • We should check all the pages which use extraDecimals prop and update like above of needed.
  • We can default to 3 if getCurrencyDecimals(currency) returns 0 or less than one.

Result

@alexpensify alexpensify added the External Added to denote the issue can be worked on by a contributor label Sep 18, 2024
Copy link

melvin-bot bot commented Sep 18, 2024

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

@melvin-bot melvin-bot bot changed the title Distance rate-Decimals are not supported for this currency yet entering dot is allowed [$250] Distance rate-Decimals are not supported for this currency yet entering dot is allowed Sep 18, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 18, 2024
Copy link

melvin-bot bot commented Sep 18, 2024

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

@alexpensify
Copy link
Contributor

alexpensify commented Sep 18, 2024

@DylanDylann when you get a chance, can you review the proposals to address this Albanian currency issue? Also, I'm not sure if there are other currencies that are affected by this issue like Japanese Yen. Thanks!

@daledah
Copy link
Contributor

daledah commented Sep 20, 2024

Edited by proposal-police: This proposal was edited at 2024-09-25 05:28:13 UTC.

Proposal

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

Decimals are not supported for this currency yet entering dot is allowed

What is the root cause of that problem?

We always display one extra decimal

If currency is ALL the default decimal is 0 and the extra decimal is 1 --> we will display one decimal

If currency is USD the default decimal is 2 and the extra decimal is 1 --> we will display three decimal

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

Add new prop to AmountForm Component called fixedDecimal. If fixedDecimal is valuable, we will use this value instead of CurrencyUtils.getCurrencyDecimals(currency) + extraDecimals

const decimals = CurrencyUtils.getCurrencyDecimals(currency) + extraDecimals;

In CreateDistanceRatePage PolicyDistanceRateEditPage, PolicyDistanceRateTaxReclaimableEditPage, we need to pass fixedDecimal: 4 and remove extraDecimals prop

Also need to update minimumFractionDigits: 4

minimumFractionDigits: getCurrencyDecimals(currency) + 1,

Also need to update here

const rateValueRegex = RegExp(String.raw`^-?\d{0,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{0,${CurrencyUtils.getCurrencyDecimals(currency) + 1}})?$`, 'i');

If we need to update the same thing across App (In money request flow) we also need to address some other instances (discuss futher)

@daledah
Copy link
Contributor

daledah commented Sep 20, 2024

@DylanDylann Please confirm the expect before going to proposals

How many decimals should be displayed?

@DylanDylann
Copy link
Contributor

@daledah Interesting point. I will review this issue today

@DylanDylann
Copy link
Contributor

DylanDylann commented Sep 20, 2024

I lean toward removing the extra decimal in the distance rate page as mentioned by @daledah

Anyway, I think we still need to confirm the expected first because the extra decimal is added a long time ago for the rate feature

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Sep 20, 2024

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

@DylanDylann
Copy link
Contributor

DylanDylann commented Sep 20, 2024

@Expensify/design @lakchote The number of decimals on the submit expense page and distance rate page is inconsistent. Is there any reason why we need to add one more extra decimal on the distance rate page? If not, should we remove extraDecimal to keep it consistent?

  1. In the Submit Expense Page, we use the default number of decimal places for each currency (USD: 2, ALL: 0)
Screen.Recording.2024-09-20.at.14.44.53.mov
  1. In the Add distance rate, we have one more decimal compared to the default (USD: 3, ALL: 1)
Screenshot 2024-09-20 at 14 46 01

@shawnborton
Copy link
Contributor

I think that is on purpose, since a lot of government distance rates use three decimal places. cc @trjExpensify to fact check me there.

@DylanDylann
Copy link
Contributor

@shawnborton For the VND, ALL currency (there are no decimal in the submit expense page), Should we allow one decimal in the distance rate page?

@BhuvaneshPatil
Copy link
Contributor

@DylanDylann I have mentioned about removing that prop in my proposal. Any reason for selecting the other proposal

@DylanDylann
Copy link
Contributor

DylanDylann commented Sep 20, 2024

I lean toward removing the extra decimal in the distance rate page as mentioned by @daledah

@daledah gave a good explanation of why we should remove that prop that makes me lean toward this approach

@BhuvaneshPatil Let's discuss the expectation first, I will come back to proposals later. Thanks

@shawnborton
Copy link
Contributor

What do you mean by the VND?

@DylanDylann
Copy link
Contributor

DylanDylann commented Sep 20, 2024

@shawnborton Ahhh VND is a currency, ALL also be a currency

For the VND currency and ALL currency (there are no decimal in the submit expense page), Should we allow one decimal in the distance rate page?

Screen.Recording.2024-09-20.at.17.42.10.mov

@shawnborton
Copy link
Contributor

Hmm honestly I have no idea. I kind of think we can just always allow three decimal places no matter what the currency is to keep things simple? But would love someone more familiar with distance rates to fact check me, cc @twisterdotcom

@Krishna2323
Copy link
Contributor

Proposal Updated

  • Minor update.

@twisterdotcom
Copy link
Contributor

I think we should just allow three everywhere. That's what we do on oldDot.

@alexpensify
Copy link
Contributor

@DylanDylann, are there more questions here, or are we good to move forward? Thanks!

@melvin-bot melvin-bot bot added the Overdue label Sep 23, 2024
@BhuvaneshPatil
Copy link
Contributor

### Proposal updated

  • added logic to have three decimals

@trjExpensify
Copy link
Contributor

I think we should just allow three everywhere. That's what we do on oldDot.

Distance rate decimals are to 4 aren't they, @twisterdotcom.

image

@Krishna2323
Copy link
Contributor

Proposal Updated

  • Added new solution in main section and moved previous main section solution to alternative 2

Copy link

melvin-bot bot commented Sep 23, 2024

@alexpensify, @lakchote, @DylanDylann Whoops! This issue is 2 days overdue. Let's get this updated quick!

@DylanDylann
Copy link
Contributor

Waiting for @twisterdotcom to discuss more about the expect: #49336 (comment)

@melvin-bot melvin-bot bot removed the Overdue label Sep 24, 2024
@twisterdotcom
Copy link
Contributor

Wow, I didn't even test adding another one. Okay, then sure, let's do 4 everywhere.

@daledah
Copy link
Contributor

daledah commented Sep 25, 2024

Updated proposal

@DylanDylann
Copy link
Contributor

DylanDylann commented Sep 25, 2024

@daledah's proposal looks good to me. Because they provide an anchor point (from their original proposal) that helps us reach the final expectation, they also address all fixes to ensure consistency across the app.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Sep 25, 2024

Current assignee @lakchote is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@Krishna2323
Copy link
Contributor

@DylanDylann, I think selected proposal is same as mine. Can you please tell me the reason why you selected their proposal?

@DylanDylann
Copy link
Contributor

Ahh, thanks for your reminder. I updated comment to explain my decision. Don't hesitate to tell me if you have any concern

@Krishna2323
Copy link
Contributor

@DylanDylann, I think their initial proposal was to remove the prop and my proposal was the first to provide a valid solution after we got confirmation on the expected behaviour.

I have also mentioned to check all the places where we use extraDecimal prop and additional I also included example of Tax rate page and distance rate page before any proposal.

@daledah
Copy link
Contributor

daledah commented Sep 25, 2024

@Krishna2323 You missed this point

Also need to update minimumFractionDigits: 4

minimumFractionDigits: getCurrencyDecimals(currency) + 1,

Also need to update here

const rateValueRegex = RegExp(String.raw`^-?\d{0,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{0,${CurrencyUtils.getCurrencyDecimals(currency) + 1}})?$`, 'i');

If we need to update the same thing across App (In money request flow) we also need to address some other instances (discuss futher)

@Krishna2323
Copy link
Contributor

Okay, thanks for explaining @daledah :)

@lakchote
Copy link
Contributor

@daledah's proposal LGTM.

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

melvin-bot bot commented Sep 25, 2024

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

Offer link
Upwork job

Copy link

melvin-bot bot commented Sep 25, 2024

📣 @daledah 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 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 26, 2024
@daledah
Copy link
Contributor

daledah commented Sep 26, 2024

@DylanDylann PR is ready.

@alexpensify
Copy link
Contributor

Awesome, waiting for this one to go into Production.

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
None yet
Development

No branches or pull requests

10 participants