Skip to content

[$250] Invoice - 0.00 displayed on Pay button for invoice receiver #51312

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.52-5
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5113365
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/ and log in
  2. Create a workspace if there is no any
  3. Navigate to the workspace settings > More features
  4. Enable the Invoice option
  5. Click on FAB > Send invoice
  6. Select an invoice receiver
  7. Enter the company info and send the invoice
  8. Log in with the invoice receiver account in incognito
  9. Navigate to the invoice room

Expected Result:

The correct amount is displayed on the Pay button

Actual Result:

0.00 is displayed on the Pay button

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6642672_1729642693581.Recording__879.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021849917912281837951
  • Upwork Job ID: 1849917912281837951
  • Last Price Increase: 2024-11-29
Issue OwnerCurrent Issue Owner: @MitchExpensify
Issue OwnerCurrent Issue Owner: @NikkiWines

Activity

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

    @melvin-bot

    Triggered auto assignment to @MitchExpensify (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 Oct 23, 2024

    @IuliiaHerets
    Author

    We think that this bug might be related to #vip-bills

  4. IuliiaHerets commented on Oct 23, 2024

    @IuliiaHerets
    Author

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

  5. twilight2294 commented on Oct 23, 2024

    @twilight2294
    Contributor

    Edited by proposal-police: This proposal was edited at 2024-11-05 08:36:07 UTC.

    Proposal

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

    0.00 displayed on Pay button for invoice receiver

    What is the root cause of that problem?

    We get the settlement amount using getSettlementAmount:

    const getSettlementAmount = () => {

    We get the total reimbursableSpend to be displayed in the pay button form getMoneyRequestSpendBreakdown:

    const {totalDisplaySpend, reimbursableSpend} = ReportUtils.getMoneyRequestSpendBreakdown(iouReport);

    We calculate reimbursableSpend using the formula:

    const reimbursableSpend = totalDisplaySpend - nonReimbursableSpend;

    But for a invoice report nonReimbursableSpend is going to be equal to the totalDisplaySpend as for invoices we request the amount from the user and not ask for reimbursement. So the value goes to zero and that is what is displayed on the FE.
    Screenshot 2024-10-23 at 3 04 02 PM

    This causes the 0 amount error

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

    We should check if the current report is an invoice report and for that case should directly pass the totalDisplaySpend as that would be the requested invoice amount:

    const reimbursableSpend = isInvoiceReport(report) ? totalDisplaySpend : totalDisplaySpend - nonReimbursableSpend;

    We also need to update the below:

    let total = (iouReport?.total ?? 0) - (iouReport?.nonReimbursableTotal ?? 0);

    To:

        let total = (iouReport?.total ?? 0) - (isInvoiceReport ? 0 : iouReport?.nonReimbursableTotal ?? 0);

    And then in MoneyReportView we calculate the formattedOutOfPocketAmount in the wrong way, it should be totalDisplaySpend - nonReimbursableSpend as that is what is owed for reimbursement.

    const formattedOutOfPocketAmount = CurrencyUtils.convertToDisplayString(reimbursableSpend, report.currency);

        const formattedOutOfPocketAmount = CurrencyUtils.convertToDisplayString(totalDisplaySpend - nonReimbursableSpend, report.currency);

    What alternative solutions did you explore? (Optional)

    Or when we get settlement amount below:

    formattedAmount={getSettlementAmount() ?? ''}

    We can check if the current report is invoice and if so then call getDisplayAmount() for that case

  6. Tony-MK commented on Oct 23, 2024

    @Tony-MK
    Contributor

    Edited by proposal-police: This proposal was edited at 2024-11-04 16:27:36 UTC.

    Proposal

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

    0.00 displayed on Pay button for invoice receiver

    What is the root cause of that problem?

    Since the nonReimbursableTotal for invoice reports is the same as it's total, the reimbursableSpend, which is calculated from the ReportPreview.getMoneyRequestSpendBreakdown function, will be 0.

    App/src/libs/ReportUtils.ts

    Lines 2760 to 2761 in 5e975f5

    const totalDisplaySpend = totalSpend;
    const reimbursableSpend = totalDisplaySpend - nonReimbursableSpend;

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

    Let's create a condition in the ReportPreview and MoneyReportHeader components to display the total instead of the reimbursableSpend if the report is an invoice report.

    return CurrencyUtils.convertToDisplayString(reimbursableSpend, iouReport?.currency);

    const formattedAmount = CurrencyUtils.convertToDisplayString(
             ReportUtils.isInvoiceReport(moneyRequestReport) ? moneyRequestReport.total : reimbursableSpend, 
             iouReport?.currency
    );
    

    const formattedAmount = CurrencyUtils.convertToDisplayString(reimbursableSpend, moneyRequestReport?.currency);

    return CurrencyUtils.convertToDisplayString(
             isInvoiceRoom ? totalDisplaySpend : reimbursableSpend, 
             iouReport?.currency
    );
    

    Finally, let's change how we calculate total in the getPayMoneyRequestParams function, like below, to only use the value of iouReport?.total by excluding the value of iouReport?.nonReimbursableTotal in the calculation only when if the report is an invoice report.

    let total = (iouReport?.total ?? 0) - (iouReport?.nonReimbursableTotal ?? 0);

    let total = (iouReport?.total ?? 0) - (!isInvoiceReport && (iouReport?.nonReimbursableTotal ?? 0));
    
  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 25, 2024
  8. changed the title [-]Invoice - 0.00 displayed on Pay button for invoice receiver[/-] [+][$250] Invoice - 0.00 displayed on Pay button for invoice receiver[/+] on Oct 25, 2024
  9. melvin-bot commented on Oct 25, 2024

    @melvin-bot
  10. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 25, 2024
  11. MitchExpensify commented on Oct 25, 2024

    @MitchExpensify
    Contributor

    Lets fix!

  12. 80 remaining items

  13. melvin-bot commented on Dec 3, 2024

    @melvin-bot

    @NikkiWines, @MitchExpensify, @dukenv0307 Eep! 4 days overdue now. Issues have feelings too...

  14. MitchExpensify commented on Dec 3, 2024

    @MitchExpensify
    Contributor

    @FitseTLT - Paid
    @dukenv0307 - Waiting on acceptance

  15. melvin-bot commented on Dec 5, 2024

    @melvin-bot

    @NikkiWines, @MitchExpensify, @dukenv0307 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  16. MitchExpensify commented on Dec 5, 2024

    @MitchExpensify
    Contributor

    Still waiting for you to accept the offer here @dukenv0307 https://www.upwork.com/nx/wm/offer/105160257

  17. added
    ReviewingHas a PR in review
    InternalRequires API changes or must be handled by Expensify staff
    and removed
    ExternalAdded to denote the issue can be worked on by a contributor
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 6, 2024
  18. dukenv0307 commented on Dec 6, 2024

    @dukenv0307
    Contributor

    @MitchExpensify Accepted thanks!

  19. MitchExpensify commented on Dec 11, 2024

    @MitchExpensify
    Contributor

    Paid thanks!

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.DailyKSv2InternalRequires API changes or must be handled by Expensify staffReviewingHas a PR in review

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions