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

Distance tax - Distance rate with non-zero tax rate shows 0% rate when submitting next expense #43137

Closed
6 tasks done
lanitochka17 opened this issue Jun 5, 2024 · 6 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Jun 5, 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: 1.4-79-2
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
Issue reported by: Applause - Internal Team

Issue found when executing PR #42909

Action Performed:

Precondition:

  • Track Tax distance is enabled on Old Dot
  • Workspace has a few distance rates and the distance rates are associated with tax rates
  1. Go to staging.new.expensify.com
  2. Go to workspace chat
  3. Submit a distance expense with distance rate that has non-zero tax rate (so that this distance rate will be the default one when creating the next distance expense)
  4. Go to workspace chat
  5. Go to + > Submit expense > Distance
  6. Enter waypoints > Next
  7. Note that the tax rate for the distance in Step 3 becomes tax exempt (0%)
  8. Change to another distance rate and change again back to the same distance rate in Step 8
  9. Note that the distance rate only shows the correct tax rate after reselecting distance rate

Expected Result:

In Step 7, the selected distance rate should show the correct tax rate when creating another distance expense

Actual Result:

In Step 7, the selected distance rate should show the incorrect tax rate (it shows tax exempt 0%) when creating another distance expense
It only shows the correct tax rate when reselecting the distance rate (Step 8)

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

Bug6502346_1717567663584.bandicam_2024-06-05_14-03-07-751.mp4

View all open jobs on GitHub

@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 5, 2024
Copy link

melvin-bot bot commented Jun 5, 2024

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

@lanitochka17
Copy link
Author

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

@lanitochka17
Copy link
Author

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

@bernhardoj
Copy link
Contributor

bernhardoj commented Jun 6, 2024

Proposal

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

The distance tax rate isn't set automatically.

What is the root cause of that problem?

When we select a distance rate, we also update the tax rate here.

function selectDistanceRate(customUnitRateID: string) {
if (policy?.customUnits && customUnitID && shouldShowTax) {
const policyCustomUnitRate = policy?.customUnits[customUnitID].rates[customUnitRateID];
const taxRateExternalID = policyCustomUnitRate.attributes?.taxRateExternalID ?? '';
const taxAmount = CurrencyUtils.convertToBackendAmount(DistanceRequestUtils.calculateTaxAmount(policy, transaction, customUnitRateID));
IOU.setMoneyRequestTaxAmount(transactionID, taxAmount);
IOU.setMoneyRequestTaxRate(transactionID, taxRateExternalID);
}
IOU.updateDistanceRequestRate(transactionID, customUnitRateID, policy?.id ?? '');
navigateBack();

But we don't do the same when initializing it. The app will currently only initialize the distance rate.

useEffect(() => {
if (customUnitRateID || !canUseP2PDistanceRequests) {
return;
}
if (!customUnitRateID) {
const rateID = lastSelectedDistanceRates?.[policy?.id ?? ''] ?? defaultMileageRate?.customUnitRateID ?? '';
IOU.setCustomUnitRateID(transactionID, rateID);
}
}, [defaultMileageRate, customUnitRateID, lastSelectedDistanceRates, policy?.id, canUseP2PDistanceRequests, transactionID]);

So the tax rate will always be the default one.

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

Initialize the tax rate too when the page is initialized.

useEffect(() => {
    if (!customUnitRateID) {
        return;
    }
    const distanceUnit = PolicyUtils.getCustomUnit(policy);
    const customUnitID = distanceUnit?.customUnitID;
    if (policy?.customUnits && customUnitID && shouldShowTax) {
        const policyCustomUnitRate = policy?.customUnits[customUnitID].rates[customUnitRateID];
        const taxRateExternalID = policyCustomUnitRate.attributes?.taxRateExternalID ?? '';
        const taxAmount = CurrencyUtils.convertToBackendAmount(DistanceRequestUtils.calculateTaxAmount(policy, transaction, customUnitRateID));
        IOU.setMoneyRequestTaxAmount(transactionID, taxAmount, true);
        IOU.setMoneyRequestTaxRate(transactionID, taxRateExternalID);
    }
}, [customUnitRateID, isPolicyExpenseChat, policy, isDistanceRequest, transaction, transactionID]);

maybwe we should move it to a util function

@joekaufmanexpensify
Copy link
Contributor

I followed the reproduction steps above, and can't reproduce this. We are using the correct tax rate when I create the second expense, rather than defaulting to $0.

2024-06-06_16-51-54.mp4

@joekaufmanexpensify
Copy link
Contributor

Gonna close this out for now since it doesn't appear to be reproducible, but LMK if there is some other way to reproduce this, and happy to take another look

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. Daily KSv2
Projects
None yet
Development

No branches or pull requests

3 participants