Skip to content

[HOLD #39616][$250] [Track Tax] - Tax does not show up in the Expense report when created offline #40051

Closed

Description

@lanitochka17

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: 1.4.62-0
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): sustinov@applausemail.com
Issue reported by: Applause - Internal Team

Issue found when executing PR #39723

Action Performed:

Prerequisites:
Create WS collect, include Tax, add 5% rate.

  1. Open https://staging.new.expensify.com/
  2. Navigate to a workspace room
  3. Switch on offline
  4. Create and send to the IOU room with 5% tax.
  5. Navigate to the IOU details

Expected Result:

The tax should appear in the IOU report when created offline

Actual Result:

Tax does not show up in the IOU report when created offline

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

Bug6445180_1712786974295.Recording__34.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01d25bb36f4e169f12
  • Upwork Job ID: 1779966508736303104
  • Last Price Increase: 2024-04-15

Activity

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

    @melvin-bot

    Triggered auto assignment to @abekkala (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. lanitochka17 commented on Apr 10, 2024

    @lanitochka17
    Author

    @abekkala 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. lanitochka17 commented on Apr 10, 2024

    @lanitochka17
    Author

    We think that this bug might be related to #wave-collect - Release 1

  5. allgandalf commented on Apr 11, 2024

    @allgandalf
    Contributor

    Proposal

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

    Tax amount is not stored optimistically when we create IOU request offline

    What is the root cause of that problem?

    When we create the request offline, we call IOU.requestMoney and in requestMoney, we build out a report optimistically :

    function buildOptimisticTransaction(
    amount: number,
    currency: string,
    reportID: string,
    comment = '',
    created = '',
    source = '',
    originalTransactionID = '',
    merchant = '',
    receipt: Receipt = {},
    filename = '',
    existingTransactionID: string | null = null,
    category = '',
    tag = '',
    billable = false,
    pendingFields: Partial<{[K in TransactionPendingFieldsKey]: ValueOf<typeof CONST.RED_BRICK_ROAD_PENDING_ACTION>}> | undefined = undefined,
    reimbursable = true,
    ): Transaction {

    But in here we do not save the tax rate and tax amount optimistically , we only send them to the BE:

    App/src/libs/actions/IOU.ts

    Lines 2338 to 2352 in 8ae5491

    taxCode,
    taxAmount,
    billable,
    // This needs to be a string of JSON because of limitations with the fetch() API and nested objects
    gpsPoints: gpsPoints ? JSON.stringify(gpsPoints) : undefined,
    transactionThreadReportID,
    createdReportActionIDForThread,
    };
    API.write(WRITE_COMMANDS.REQUEST_MONEY, parameters, onyxData);
    resetMoneyRequestInfo();
    Navigation.dismissModal(activeReportID);
    if (activeReportID) {
    Report.notifyNewAction(activeReportID, payeeAccountID);
    }

    but here we forgot to consider the case when IOU is created Offline at this case when we call buildOptimisticTransaction we do not pass and store both values optimistically.

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

    We need to send additional props for tax rate and tax amount, this will be passed down to buildOptimisticTransaction via getMoneyRequestInformation, and then we will return the value of tax amount and rate stored optimistically so that we can see the rate and tax amount even in offline mode

    } = getMoneyRequestInformation(

    Result Video

    Screen.Recording.2024-04-11.at.7.03.14.AM.mov

    Note: Same approach would be followed for tax rate as well, in the video I have only implemented taxamount

  6. nkdengineer commented on Apr 11, 2024

    @nkdengineer
    Contributor

    Proposal

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

    • Tax - Tax does not show up in the IOU report when created offline

    What is the root cause of that problem?

    • In requestMoney the onyxData does not contain the taxCode and taxAmount, that leads to there is no tax data shown in offline mode.

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

        let optimisticTransaction = TransactionUtils.buildOptimisticTransaction(
            ReportUtils.isExpenseReport(iouReport) ? -amount : amount,
            ...
            taxCode,
            ReportUtils.isExpenseReport(iouReport) ? -taxAmount : taxAmount,
        );
    
    • An additional bug is that, we do not have correct optimistic tax data when editing taxCode. When editing taxCode, we do not update the taxAmount accordingly. Solution: we can add check if the transactionChanges in here contains taxCode field. If it is, update the taxAmount as well. To do it, we can add the below logic to this:
    if ('taxCode' in transactionChanges && !('taxAmount' in transactionChanges)) {
            const taxRates = policy?.taxRates;
            const getTaxAmount = (taxRates, selectedTaxRate: string, amount: number) => {
                const percentage = Object.values(OptionsListUtils.transformedTaxRates(taxRates)).find((taxRate) => taxRate.code?.includes(selectedTaxRate))?.value;
                if (percentage) {
                    return TransactionUtils.calculateTaxAmount(percentage, amount);
                }
            };
            const taxAmount = getTaxAmount(taxRates, transactionChanges.taxCode, transaction?.amount);
            const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(taxAmount);
            optimisticData.push({
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
                value: {
                    taxAmount: amountInSmallestCurrencyUnits,
                },
            });
        }
    
    • Then we need to add the failureData and successData properly.

    What alternative solutions did you explore? (Optional)

    • NA
  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 15, 2024
  8. changed the title [-]Tax - Tax does not show up in the IOU report when created offline[/-] [+][$250] Tax - Tax does not show up in the IOU report when created offline[/+] on Apr 15, 2024
  9. melvin-bot commented on Apr 15, 2024

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

    @melvin-bot

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

  12. 5 remaining items

  13. jayeshmangwani commented on Apr 17, 2024

    @jayeshmangwani
    Contributor

    Thanks @GandalfGwaihir and @nkdengineer for the proposals

    Both proposals are correct, and RCA is on point. @nkdengineer has added some extra details than @GandalfGwaihir for editing taxCode, but that is additional to the original issue. @GandalfGwaihir proposed a working solution first for the described issue, so in this case, we can go with user @GandalfGwaihir 's Proposal

    🎀 👀 🎀 C+ reviewed

  14. melvin-bot commented on Apr 17, 2024

    @melvin-bot

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

  15. changed the title [-][$250] Tax - Tax does not show up in the IOU report when created offline[/-] [+][$250] Tax - Tax does not show up in the Expense report when created offline[/+] on Apr 18, 2024
  16. trjExpensify commented on Apr 18, 2024

    @trjExpensify
    Contributor

    👋 Just a heads up to make sure we distinguish between iouReport and expenseReport in the title and OP of the issue. A request to a workspace goes onto an expense report. Tax tracking is a feature of workspaces. You can't track tax on requests to individuals, that go on iou Reports.

  17. changed the title [-][$250] Tax - Tax does not show up in the Expense report when created offline[/-] [+][$250] [Track Tax] - Tax does not show up in the Expense report when created offline[/+] on Apr 18, 2024
  18. trjExpensify commented on Apr 18, 2024

    @trjExpensify
    Contributor

    CC: @MonilBhavsar as it's Track Tax related.

  19. nkdengineer commented on Apr 18, 2024

    @nkdengineer
    Contributor

    @arosiclair More about this C+ comment: We have addtional bugs related to the tax flow in offline mode (mentioned in my proposal), should we plan to fix it in this issue? If not, I think we can go with the selected proposal

  20. MonilBhavsar commented on Apr 18, 2024

    @MonilBhavsar
    Contributor

    This is dupe of implementation issue - #39616

  21. changed the title [-][$250] [Track Tax] - Tax does not show up in the Expense report when created offline[/-] [+][HOLD #39616][$250] [Track Tax] - Tax does not show up in the Expense report when created offline[/+] on Apr 18, 2024
  22. arosiclair commented on Apr 18, 2024

    @arosiclair
    Contributor

    This is dupe of implementation issue - #39616

    Should we just close this then?

  23. MonilBhavsar commented on Apr 18, 2024

    @MonilBhavsar
    Contributor

    Let's close it 👍

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions