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 2024-07-24] [$250] Split tax - Tax amount is negative when manually entering tax amount when splitting expense #44632

Closed
6 tasks done
lanitochka17 opened this issue Jun 28, 2024 · 29 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Jun 28, 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-3.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: https://expensify.testrail.io/index.php?/tests/view/4678911
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

  • Taxes feature is enabled.
  • Workspace has at least one non-zero tax rate
  1. Go to staging.new.expensify.com
  2. Go to workspace chat
  3. Go to + > Split expense > Manual
  4. Enter amount > Next
  5. Click Show more > Tax rate
  6. Select a non-zero tax rate
  7. Click Tax amount
  8. Manually enter the tax amount
  9. Split the expense
  10. Click on the split preview

Expected Result:

The tax amount will not be negative

Actual Result:

The tax amount is negative when manually entering tax amount when splitting expense

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

Bug6527444_1719582486649.20240628_214259.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f472383a767ded73
  • Upwork Job ID: 1808173052119824825
  • Last Price Increase: 2024-07-02
Issue OwnerCurrent Issue Owner: @CortneyOfstad
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 28, 2024
Copy link

melvin-bot bot commented Jun 28, 2024

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

@CortneyOfstad 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 #wave-collect - Release 1

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Jun 28, 2024

Proposal

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

What is the root cause of that problem?

BE returns negative tax amount when editing tax amount manually. And we convert the negative tax amount to formatted tax amount here in MoneyRequestConfimationListFooter without first converting the tax amount into positive value as we do in MoneyRequestView.

const formattedTaxAmount = CurrencyUtils.convertToDisplayString(transaction?.taxAmount, iouCurrencyCode);

And display the formatted value here

<MenuItemWithTopDescription
key={`${taxRates?.name}${formattedTaxAmount}`}
shouldShowRightIcon={canModifyTaxFields}
title={formattedTaxAmount}

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

As we do in MoneyRequestView, we should first convert the taxAmount to positive following the same method used in Money RequestVeiw

const taxAmount = TransactionUtils.getTaxAmount(transaction, false);

getTaxAmount() returns the absolute value of transaction.taxAmount

Then we format it

const formattedTaxAmount = CurrencyUtils.convertToDisplayString(taxAmount, iouCurrencyCode);

here

https://github.com/Expensify/App/blob/937c4186409725b57fdaae6ae8e1d8c85a9d52a0/src/components/MoneyRequestConfirmationListFooter.tsx#L254C11-L254C29

Note: Instead of passing false as isExpenseReport param to 'getTaxAmount', we can calculate isExpenseReport using TransactionUtils.isExpenseReport(report)).

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Jul 1, 2024
@nkdengineer
Copy link
Contributor

Proposal

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

The tax amount is negative when manually entering tax amount when splitting expense

What is the root cause of that problem?

If we create a split bill with entering the tax amount manually, BE returns the tax amount as negative amount for expense report.

And in here, we doesn't convert the tax mount to positive value before getting the formatted string.

const formattedTaxAmount = CurrencyUtils.convertToDisplayString(transaction?.taxAmount, iouCurrencyCode);

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

If we create a split bill with entering the tax amount manually, BE returns the tax amount as negative amount for expense report.

With this case BE returns the tax amount as negative amount for expense report. But if we don't enter the tax amount manually, BE returns it as positive amount. So here we should use getTaxAmountAbsValue to make sure that the displayed tax amount is always positive value

const formattedTaxAmount = CurrencyUtils.convertToDisplayString(ModifiedExpenseMessage.getTaxAmountAbsValue(transaction?.taxAmount ?? 0), iouCurrencyCode);

const formattedTaxAmount = CurrencyUtils.convertToDisplayString(transaction?.taxAmount, iouCurrencyCode);

What alternative solutions did you explore? (Optional)

We can fix from BE side to always return the tax amount of split bill transaction in expense report as negative amount
And then here, we can use getTaxAmount function that had already covered the negative amount case for expense chat.

const formattedTaxAmount = CurrencyUtils.convertToDisplayString(TransactionUtils.getTaxAmount(transaction, isPolicyExpenseChat), iouCurrencyCode);

const formattedTaxAmount = CurrencyUtils.convertToDisplayString(transaction?.taxAmount, iouCurrencyCode);

Copy link

melvin-bot bot commented Jul 1, 2024

@CortneyOfstad Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@CortneyOfstad
Copy link
Contributor

I was able to recreate so going to get eyes on this!

@melvin-bot melvin-bot bot removed the Overdue label Jul 2, 2024
@CortneyOfstad CortneyOfstad added the External Added to denote the issue can be worked on by a contributor label Jul 2, 2024
@melvin-bot melvin-bot bot changed the title Split tax - Tax amount is negative when manually entering tax amount when splitting expense [$250] Split tax - Tax amount is negative when manually entering tax amount when splitting expense Jul 2, 2024
Copy link

melvin-bot bot commented Jul 2, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01f472383a767ded73

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 2, 2024
Copy link

melvin-bot bot commented Jul 2, 2024

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

@CortneyOfstad CortneyOfstad moved this to Release 2: Summer 2024 (Aug) in [#whatsnext] #wave-collect Jul 2, 2024
@CortneyOfstad
Copy link
Contributor

@aimane-chnaif there are two proposals here and here for review when you have a chance — thank you!

@aimane-chnaif
Copy link
Contributor

Thanks for the proposals.

We can fix from BE side to always return the tax amount of split bill transaction in expense report as negative amount

@nkdengineer have you found any case where @etCoderDysto's solution is not working?

- const formattedTaxAmount = CurrencyUtils.convertToDisplayString(transaction?.taxAmount, iouCurrencyCode);
+ const formattedTaxAmount = CurrencyUtils.convertToDisplayString(TransactionUtils.getTaxAmount(transaction, false), iouCurrencyCode);

@nkdengineer
Copy link
Contributor

@aimane-chnaif I can't find.

@aimane-chnaif
Copy link
Contributor

@etCoderDysto's proposal looks good. They're the first to provide root cause and working solution.
🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Jul 3, 2024

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

@etCoderDysto
Copy link
Contributor

Hi @hayata-suenaga, should I go on with creating the PR?

@hayata-suenaga
Copy link
Contributor

sorry I have been sick for a while. yes! let's go with your proposal, @etCoderDysto! 😄

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 8, 2024
Copy link

melvin-bot bot commented Jul 8, 2024

📣 @etCoderDysto You have been assigned to this job!
Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot removed the Overdue label Jul 8, 2024
@etCoderDysto
Copy link
Contributor

etCoderDysto commented Jul 8, 2024

sorry I have been sick for a while. yes! let's go with your proposal, @etCoderDysto! 😄

Np 😁. I hope you are feeling better now.

@etCoderDysto
Copy link
Contributor

PR will be ready for review in few hours.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jul 9, 2024
@etCoderDysto
Copy link
Contributor

@aimane-chnaif PR is ready for review.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 17, 2024
@melvin-bot melvin-bot bot changed the title [$250] Split tax - Tax amount is negative when manually entering tax amount when splitting expense [HOLD for payment 2024-07-24] [$250] Split tax - Tax amount is negative when manually entering tax amount when splitting expense Jul 17, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 17, 2024
Copy link

melvin-bot bot commented Jul 17, 2024

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

Copy link

melvin-bot bot commented Jul 17, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.7-8 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 2024-07-24. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jul 17, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@aimane-chnaif] The PR that introduced the bug has been identified. Link to the PR:
  • [@aimane-chnaif] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@aimane-chnaif] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@aimane-chnaif] Determine if we should create a regression test for this bug.
  • [@aimane-chnaif] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@CortneyOfstad] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 23, 2024
Copy link

melvin-bot bot commented Jul 24, 2024

Payment Summary

Upwork Job

BugZero Checklist (@CortneyOfstad)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1808173052119824825/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@CortneyOfstad
Copy link
Contributor

@aimane-chnaif — please complete the check ASAP so there is no further delay in payment. Thanks!

@etCoderDysto — I sent you an offer in Upwork, please let me know once you accept and I will get that paid ASAP. Thanks!

@etCoderDysto
Copy link
Contributor

@CortneyOfstad I have accepted the offer.
Thank you!

@aimane-chnaif
Copy link
Contributor

Offending PR with comment: #32550 (comment)

We already have regression test as stated in OP

@CortneyOfstad
Copy link
Contributor

Payment Summary

@etCoderDysto — paid $250 via Upwork
@aimane-chnaif — to be paid $250 via NewDot

Thanks all!

@github-project-automation github-project-automation bot moved this from Release 2: Summer 2024 (Aug) to Done in [#whatsnext] #wave-collect Jul 25, 2024
@aimane-chnaif
Copy link
Contributor

@CortneyOfstad I am still using upwork. Can you please reopen and sort payment? Thanks

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. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Archived in project
Development

No branches or pull requests

6 participants