Repository navigation
Distance tax - Distance rate with non-zero tax rate shows 0% rate when submitting next expense #43137
Description
Activity
- addedDailyKSv2KSv2BugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.
on 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.@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
We think that this bug might be related to #vip-vsp
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.
App/src/pages/iou/request/step/IOURequestStepDistanceRate.tsx
Lines 80 to 89 in 90dee7a
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.
App/src/components/MoneyRequestConfirmationList.tsx
Lines 241 to 249 in 90dee7a
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 commented
on Jun 6, 2024 ContributorMore actionsI 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 commented
on Jun 6, 2024 ContributorMore actionsGonna 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
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:
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?
Screenshots/Videos
Add any screenshot/video evidence
Bug6502346_1717567663584.bandicam_2024-06-05_14-03-07-751.mp4
View all open jobs on GitHub