Skip to content

[$250] Distance rate-Decimals are not supported for this currency yet entering dot is allowed #49336

Closed

Description

@IuliiaHerets

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 17, 2024
  2. melvin-bot commented on Sep 17, 2024

    @melvin-bot

    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.

  3. IuliiaHerets commented on Sep 17, 2024

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

  4. BhuvaneshPatil commented on Sep 17, 2024

    @BhuvaneshPatil
    Contributor

    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)

  5. Krishna2323 commented on Sep 17, 2024

    @Krishna2323
    Contributor

    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

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 18, 2024
  7. melvin-bot commented on Sep 18, 2024

    @melvin-bot
  8. 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[/+] on Sep 18, 2024
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 18, 2024
  10. melvin-bot commented on Sep 18, 2024

    @melvin-bot

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

  11. alexpensify commented on Sep 18, 2024

    @alexpensify
    Contributor

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

  12. daledah commented on Sep 20, 2024

    @daledah
    Contributor

    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)

  13. 36 remaining items

  14. melvin-bot commented on Sep 25, 2024

    @melvin-bot

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

  15. daledah commented on Sep 26, 2024

    @daledah
    Contributor

    @DylanDylann PR is ready.

  16. alexpensify commented on Sep 27, 2024

    @alexpensify
    Contributor

    Awesome, waiting for this one to go into Production.

  17. alexpensify commented on Oct 2, 2024

    @alexpensify
    Contributor

    Automation failed but this one went into production 2 days ago

  18. alexpensify commented on Oct 7, 2024

    @alexpensify
    Contributor

    Automation failed, I'll work on the payment process tomorrow.

  19. alexpensify commented on Oct 8, 2024

    @alexpensify
    Contributor

    Payouts due: 10-07-2024

    Upwork job is here.

  20. alexpensify commented on Oct 8, 2024

    @alexpensify
    Contributor

    @daledah, please apply to the job above, and I can complete the payment process in Upwork. Thanks!

  21. daledah commented on Oct 9, 2024

    @daledah
    Contributor

    @alexpensify Hi, can you create the offer and send to me at https://www.upwork.com/freelancers/~0138d999529f34d33f

  22. alexpensify commented on Oct 10, 2024

    @alexpensify
    Contributor

    @daledah - I sent an offer via Upwork. Please accept, and then I can complete the payment process. Thanks!

  23. daledah commented on Oct 11, 2024

    @daledah
    Contributor

    @alexpensify Accepted thx

  24. alexpensify commented on Oct 11, 2024

    @alexpensify
    Contributor

    All set here, I've completed the payment for @daledah!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions