Skip to content

[HOLD for payment 2025-01-13] [$125] Invoices - Invoices badge is $0.00 instead of 0,00 US$ when app language is Spanish #53916

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.74-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): applausetester+kh1311020@applause.expensifail.com
Issue reported by: Applause Internal Team

Action Performed:

Precondition:

  • App language is Spanish.
  • Default workspace currency is USD.
  • Invoices feature is enabled.
  1. Go to staging.new.expensify.com
  2. Go to Account settings.
  3. Note that the currency and amount in the Wallet (Billetera) badge is in the format of 0,00 US$
  4. Go to workspace settings.

Expected Result:

The currency and amount in the Invoices (Facturas) badge will change to the format of 0,00 US$

Actual Result:

The currency and amount in the Invoices (Facturas) badge is still $0.00.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6690644_1733899866488.20241211_144650.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021866918061086756277
  • Upwork Job ID: 1866918061086756277
  • Last Price Increase: 2024-12-11
  • Automatic offers:
    • nkdengineer | Contributor | 105375971
Issue OwnerCurrent Issue Owner: @sonialiap / @jliexpensify

Activity

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

    @melvin-bot

    Triggered auto assignment to @sonialiap (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. etCoderDysto commented on Dec 11, 2024

    @etCoderDysto
    Contributor

    Edited by proposal-police: This proposal was edited at 2024-12-11 11:33:12 UTC.

    Proposal

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

    Invoices - Invoices badge is $0.00 instead of 0,00 US$ when app language is Spanish

    What is the root cause of that problem?

    We are using CurrencyUtils.convertToFrontendAmountAsString to format the amount to a floating number and then we prefix it with currency. convertToFrontendAmountAsString doesn't return a localized floating number as convertToDisplayString

    badgeText: `${CurrencyUtils.getCurrencySymbol(currencyCode)}${CurrencyUtils.convertToFrontendAmountAsString(
    policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0,
    currencyCode,

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

    We should use convertToDisplayString instead of convertToFrontendAmountAsString to localize the amount as we are doing on WorkspaceInvoiceBalanceSection. And remove CurrencyUtils.getCurrencySymbol call

    badgeText: `${CurrencyUtils.convertToDisplayString(policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0, currencyCode)}`,
    

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    N/A
    UI issue

    What alternative solutions did you explore? (Optional)

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Dec 11, 2024
  5. melvin-bot commented on Dec 11, 2024

    @melvin-bot
  6. changed the title [-]Invoices - Invoices badge is $0.00 instead of 0,00 US$ when app language is Spanish[/-] [+][$250] Invoices - Invoices badge is $0.00 instead of 0,00 US$ when app language is Spanish[/+] on Dec 11, 2024
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 11, 2024
  8. melvin-bot commented on Dec 11, 2024

    @melvin-bot

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

  9. changed the title [-][$250] Invoices - Invoices badge is $0.00 instead of 0,00 US$ when app language is Spanish[/-] [+][$125] Invoices - Invoices badge is $0.00 instead of 0,00 US$ when app language is Spanish[/+] on Dec 11, 2024
  10. melvin-bot commented on Dec 11, 2024

    @melvin-bot

    Upwork job price has been updated to $125

  11. nkdengineer commented on Dec 11, 2024

    @nkdengineer
    Contributor

    Proposal

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

    The currency and amount in the Invoices (Facturas) badge is still $0.00.

    What is the root cause of that problem?

    The invoice badge is always displayed with the format ${currency}{amount} that is inconsistent with the balance that we displayed in WorkspaceInvoiceBalanceSection here and I notice that the badge is also displayed with the wrong currency. It displays with the workspace currency while in WorkspaceInvoiceBalanceSection we display with USD currency with the same value is policy?.invoice?.bankAccount?.stripeConnectAccountBalance

    Screenshot 2024-12-12 at 02 07 27

    badgeText: `${CurrencyUtils.getCurrencySymbol(currencyCode)}${CurrencyUtils.convertToFrontendAmountAsString(
    policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0,
    currencyCode,
    )}`,

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

    We should use convertToDisplayString function without currency code then it will default to USD as we did here

    badgeText: CurrencyUtils.convertToDisplayString(policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0),
    

    badgeText: `${CurrencyUtils.getCurrencySymbol(currencyCode)}${CurrencyUtils.convertToFrontendAmountAsString(
    policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0,
    currencyCode,
    )}`,

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    What alternative solutions did you explore? (Optional)

    If the correct currency should be the workspace currency, we need to add the worksapce currency to convertToDisplayString here

    badgeText: CurrencyUtils.convertToDisplayString(policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0, currencyCode),
    

    badgeText: `${CurrencyUtils.getCurrencySymbol(currencyCode)}${CurrencyUtils.convertToFrontendAmountAsString(
    policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0,
    currencyCode,
    )}`,

    and here

    CurrencyUtils.convertToDisplayString(policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0, policy?.outputCurrency)
    

    title={CurrencyUtils.convertToDisplayString(policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0)}

  12. hungdannt commented on Dec 12, 2024

    @hungdannt

    Proposal

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

    The Invoices badge displays '$0.00', but it should be formatted as 0,00 US$ when the app language is set to Spanish

    What is the root cause of that problem?

    badgeText: `${CurrencyUtils.getCurrencySymbol(currencyCode)}${CurrencyUtils.convertToFrontendAmountAsString(
    policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0,
    currencyCode,

    The Invoices badge manually concatenates the currency symbol with function convertToFrontendAmountAsString that just converts the amount to a string, but does not handle localization or currency formatting

    function convertToFrontendAmountAsString(amountAsInt: number | null | undefined, currency: string = CONST.CURRENCY.USD, withDecimals = true): string {
        if (amountAsInt === null || amountAsInt === undefined) {
            return '';
        }
        const decimals = withDecimals ? getCurrencyDecimals(currency) : 0;
        return convertToFrontendAmountAsInteger(amountAsInt, currency).toFixed(decimals);
    }
    

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

    Should use convertToDisplayString instead of convertToFrontendAmountAsString. This will properly handle currency formatting and localization in a single function call and provides a more consistent user experience across the application

    function convertToDisplayString(amountInCents = 0, currency: string = CONST.CURRENCY.USD): string {
        const convertedAmount = convertToFrontendAmountAsInteger(amountInCents, currency);
        let currencyWithFallback = currency;
        if (!currency) {
            currencyWithFallback = CONST.CURRENCY.USD;
        }
        return NumberFormatUtils.format(BaseLocaleListener.getPreferredLocale(), convertedAmount, {
            style: 'currency',
            currency: currencyWithFallback,
            minimumFractionDigits: getCurrencyDecimals(currency),
            maximumFractionDigits: 2,
        });
    }
    

    The suggested change:

    badgeText: `${CurrencyUtils.convertToDisplayString(policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0, currencyCode)}`,
    

    POC :
    https://github.com/user-attachments/assets/b30785d3-f8a6-4233-a73c-c64b7c67340f

    What alternative solutions did you explore? (Optional)

    N/A

  13. 33 remaining items

  14. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Jan 6, 2025
  15. changed the title [-][$125] Invoices - Invoices badge is $0.00 instead of 0,00 US$ when app language is Spanish[/-] [+][HOLD for payment 2025-01-13] [$125] Invoices - Invoices badge is $0.00 instead of 0,00 US$ when app language is Spanish[/+] on Jan 6, 2025
  16. melvin-bot commented on Jan 6, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  17. melvin-bot commented on Jan 6, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.80-6 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 2025-01-13. 🎊

    For reference, here are some details about the assignees on this issue:

  18. melvin-bot commented on Jan 6, 2025

    @melvin-bot

    @dukenv0307 @sonialiap / @jliexpensify @dukenv0307 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  19. dukenv0307 commented on Jan 7, 2025

    @dukenv0307
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production
    • 2b. Reported on staging (deploy blocker)
    • 2c. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/50565/files#r1904876773

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again. Yes

    Regression Test Proposal Template

    Regression Test Proposal

    Test:

    1. Create a new workspace
    2. Go to More Features -> enable Invoice
    3. Go to the Invoice page
    4. Verify that: invoice badge displays selected currency of the workspace

    Do we agree 👍 or 👎

  20. sonialiap commented on Jan 14, 2025

    @sonialiap
    Contributor

    Payment summary:

  21. JmillsExpensify commented on Feb 10, 2025

    @JmillsExpensify
    Contributor

    $125 approved for @dukenv0307

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions