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 |
eh2077
left a comment
There was a problem hiding this comment.
Frontend optimistic updating works well. Code also looks good, just a minor comment
| if (defaultTaxCode) { | ||
| IOU.setMoneyRequestTaxRate(transactionID, defaultTaxCode); | ||
| } |
There was a problem hiding this comment.
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.
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
useEffectin 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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.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