-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Set default tax #42126
Set default tax #42126
Conversation
Following the Test steps described above, I end up with a negative tax amount: Is this expected? @MonilBhavsar @teneeto @getusha (Tagged you because you are in the original PR #40443 and may know if this is correct or not 🙇 ) |
@hungvu193 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@aldo-expensify Let me know if this needs C+ review |
Let me see if @getusha can get to this, since they reviewed the PR that introduced the regression https://github.com/Expensify/App/pull/40443/files#r1599258680 |
Thanks for the PR! We already have a hook to set tax details here App/src/components/MoneyRequestConfirmationList.tsx Lines 373 to 382 in d646a30
Issue will be fixed with #42151 |
That is setting taxAmount, not the taxCode. This PR is using the same pattern to set the taxCode. |
@MonilBhavsar @aldo-expensify will this be fixed in #42151? |
No, we should fix it here and close #42151 |
This is linked to this issue #42114. So I think we should assign Eric as a reviewer here 🤔 cc @aldo-expensify |
…-tax-rate-to-transaction
Swapped reviewer to @eh2077, this should be ready for review. |
The backend for now is ignoring the |
Reviewer Checklist
Screenshots/VideosAndroid: NativeN/A Android: mWeb ChromeN/A iOS: NativeN/A iOS: mWeb SafariN/A MacOS: Chrome / Safari0-web.mp4MacOS: DesktopN/A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frontend optimistic updating works well. Code also looks good, just a minor comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for me but might be able to get around the eslint thing with @eh2077's suggestion!
if (defaultTaxCode) { | ||
IOU.setMoneyRequestTaxRate(transactionID, defaultTaxCode); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could remove this condition - if (defaultTaxCode)?
we can fallback to empty string and always set tax rate
Bug 1:
Expected: Tax rate changes to have foreign default currency rate Bug 2:
Expected: Tax rate changes to have foreign default currency rate and workspace default rates as per currency |
@MonilBhavsar thanks for reviewing, I'll try to get back to this asap |
Thanks! We can do similar to what we did here c671c7a#diff-29ef0426ea09b0af3420c95911645adcd54c0d3d4c0d8c4fa5aa99dfe37a3646R342-R365 On first mount, set default rate and only update the rate depending on other parameters |
…-ttax-rate-to-transaction
Co-authored-by: Eric Han <117511920+eh2077@users.noreply.github.com>
…:Expensify/App into aldo_add-default-tax-rate-to-transaction
I tried it, but only works if the user press the "back" to change the amount. If the user clicks the amount input and changes the currency, it doesn't work because the component doesn't get unmounted. Screen.Recording.2024-05-30.at.11.53.32.PM.mov |
@MonilBhavsar I think the bugs you found are fixed now, but I found a new one: the tax amount doesn't update automatically when the tax code changes because the currency changed. I think the code here is buggy: App/src/components/MoneyRequestConfirmationList.tsx Lines 384 to 396 in 3a5b0c8
I wish there was some comment explaining that Do you know in which cases are we supposed to update the tax amount automatically? is it when we change the |
return; | ||
} | ||
const defaultTaxCode = TransactionUtils.getDefaultTaxCode(policy, transactionCurrency); | ||
IOU.setMoneyRequestTaxRate(transactionID, defaultTaxCode ?? ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the function IOU.setMoneyRequestTaxRate
to receive only the currency instead of the whole transaction object allow us to only watch the currency
instead of the transaction
object, which is what we want to react to if it changes.
Agree, we're getting rid of that condition in this PR #42737
Yes, when we change the taxCode, when we change the amount and when we change the currency(if taxCode changes, taxAmount should also update) |
I didn't check yet, but I believe it is related to this PR only? |
I'm re-implementing this here: #43519 I tested cases of:
The amount of the tax is updated when the tax code changes |
Details
Solution: use the policy's default tax rate if taxCode is not set. We do this in a
useEffect
in the same way we do it for other fields, for example here:App/src/components/MoneyRequestConfirmationList.tsx
Lines 248 to 256 in 8668b62
Fixed Issues
$ #42114
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2024-05-13.at.7.30.09.PM.mov
MacOS: Desktop