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

[HOLD for payment 2025-01-13] Distance - Inconsistency in Tax field when both distance rate and category have different tax #54513

Open
6 of 8 tasks
IuliiaHerets opened this issue Dec 24, 2024 · 20 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Engineering Weekly KSv2

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Dec 24, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.78-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
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): [email protected]
Issue reported by: Applause Internal Team
Device used: Windows 11
App Component: Money Requests

Action Performed:

Precondition:

  • Rules, Distance rates, and Taxes are enabled.
  • There are two non-zero tax rates - Tax rate A and Tax rate B.
  • Track tax is enabled.
  • Distance rate is assigned with tax rate A.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Categories.
  3. Click Advertising category.
    4 Click Default tax rate.
  4. Select Tax rate B.
  5. Go to workspace chat.
  6. Click + > Submit expense > Distance.
  7. Enter waypoints > Next.
  8. On confirmation page, note that the distance tax rate is Tax rate A (follows distance rate track tax).
  9. Click Category.
  10. Select Advertising category from Step 3.
  11. Note that the distance tax rate is Tax rate B (follows the category).
  12. Submit the expense.
  13. Go to transaction thread.
  14. Note that the distance tax rate is back to Tax rate A.

Expected Result:

When submitting distance expense with distance rate that has tax rate and category with its own tax rate, the tax field should follow the tax rate from distance rate.

Actual Result:

In Step 12, after selecting category with own tax rate, the Tax field changes to the rate from the selected category, while the tax amount remains unchanged.
In Step 15, after submitting the distance expense, the Tax field changes back to the tax rate that follows distance rate.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6701707_1735032557064.bandicam_2024-12-24_17-18-24-974.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @Christinadobrzyn
@IuliiaHerets IuliiaHerets added DeployBlockerCash This issue or pull request should block deployment Bug Something is broken. Auto assigns a BugZero manager. labels Dec 24, 2024
Copy link

melvin-bot bot commented Dec 24, 2024

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

Copy link

melvin-bot bot commented Dec 24, 2024

Triggered auto assignment to @youssef-lr (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

@melvin-bot melvin-bot bot added the Daily KSv2 label Dec 24, 2024
Copy link

melvin-bot bot commented Dec 24, 2024

💬 A slack conversation has been started in #expensify-open-source

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Dec 24, 2024
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@Christinadobrzyn
Copy link
Contributor

hum... maybe related to - #53789? Asking

@Christinadobrzyn
Copy link
Contributor

Neil and the contributor of #53789 don't think it's related... I'll keep digging to see if I can find the culprit..

@nkdengineer
Copy link
Contributor

nkdengineer commented Dec 25, 2024

Edited by proposal-police: This proposal was edited at 2024-12-25 08:13:40 UTC.

Proposal

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

In Step 12, after selecting category with own tax rate, the Tax field changes to the rate from the selected category, while the tax amount remains unchanged.
In Step 15, after submitting the distance expense, the Tax field changes back to the tax rate that follows distance rate.

What is the root cause of that problem?

Here, we always update tax code and tax amount when we change the category without checking the correct tax is the distance rate tax or not.

const {categoryTaxCode, categoryTaxAmount} = TransactionUtils.getCategoryTaxCodeAndAmount(category, transaction, PolicyUtils.getPolicy(policyID));

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

Since the distance rate tax should be prioritized, we should update getCategoryTaxCodeAndAmount to return categoryTaxCode and categoryTaxAmount as undefined if the current tax code is distance rate tax.

const taxRules = policy?.rules?.expenseRules?.filter((rule) => rule.tax);
const currentTaxCode = getTaxCode(transaction);
const customUnitRateID = transaction?.comment?.customUnit?.customUnitRateID ?? '-1';
const policyCustomUnitRate = getDistanceRateCustomUnitRate(policy, customUnitRateID);
const taxRateExternalID = policyCustomUnitRate?.attributes?.taxRateExternalID ?? '-1';
if (!taxRules || taxRules?.length === 0 || taxRateExternalID === currentTaxCode) {
    return {categoryTaxCode: undefined, categoryTaxAmount: undefined};
}

const {categoryTaxCode, categoryTaxAmount} = TransactionUtils.getCategoryTaxCodeAndAmount(category, transaction, PolicyUtils.getPolicy(policyID));

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

Add a test case for getCategoryTaxCodeAndAmount and confirm that it returns categoryTaxCode and categoryTaxAmount as undefined if the current tax code is distance rate tax.

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@youssef-lr
Copy link
Contributor

@bernhardoj could this be coming from your PR?

@youssef-lr
Copy link
Contributor

I reverted the PR locally and I can't reproduce. Please take look when you're online @bernhardoj

@bernhardoj
Copy link
Contributor

@MonilBhavsar can you help clarify the expected behavior here? Should we ignore the tax rules for a category if there is a distance rate tax?

@bernhardoj
Copy link
Contributor

I assume we want to ignore it since we don't allow the user to manually change the tax rate when it's a distance request. The PR is here: #54579

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Hourly KSv2 labels Dec 26, 2024
Copy link

melvin-bot bot commented Dec 26, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@jasperhuangg jasperhuangg added DeployBlocker Indicates it should block deploying the API and removed DeployBlockerCash This issue or pull request should block deployment labels Dec 26, 2024
@jasperhuangg
Copy link
Contributor

The PR fixes this issue mostly in the front-end, but we still need a back-end PR to fully solve this issue, so I'm adding the Web blocker label.

@MonilBhavsar MonilBhavsar self-assigned this Dec 26, 2024
@MonilBhavsar
Copy link
Contributor

@MonilBhavsar can you help clarify the expected behavior here? Should we ignore the tax rules for a category if there is a distance rate tax?

Confirmed from oldDot, we don't need to update category when updating tax

Screen.Recording.2024-12-26.at.1.38.48.PM.mov

@MonilBhavsar
Copy link
Contributor

The PR fixes this issue mostly in the front-end, but we still need a back-end PR to fully solve this issue, so I'm adding the Web blocker label.

Self assigning and working on a backend PR

@MonilBhavsar MonilBhavsar removed the DeployBlocker Indicates it should block deploying the API label Dec 26, 2024
@MonilBhavsar
Copy link
Contributor

Removing the Deploy blocker label as it is not really a Web blocker. The logic lies in Auth

@MonilBhavsar
Copy link
Contributor

Sent backend PR https://github.com/Expensify/Auth/pull/13644

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jan 6, 2025
@melvin-bot melvin-bot bot changed the title Distance - Inconsistency in Tax field when both distance rate and category have different tax [HOLD for payment 2025-01-13] Distance - Inconsistency in Tax field when both distance rate and category have different tax Jan 6, 2025
Copy link

melvin-bot bot commented Jan 6, 2025

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 6, 2025
Copy link

melvin-bot bot commented Jan 6, 2025

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. 🎊

Copy link

melvin-bot bot commented Jan 6, 2025

@youssef-lr / @MonilBhavsar @Christinadobrzyn @youssef-lr / @MonilBhavsar 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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Engineering Weekly KSv2
Projects
Status: No status
Development

No branches or pull requests

7 participants