Add useEffect to select default tax code#43519
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
@aldo-expensify May I know do I need to wait for the backend change to do the test? |
I don't think it is necessary, the optimistic data should make it looks like it is working fine unless you logout / login |
|
@aldo-expensify I finished frontend (optimistic update) test and it works well for me, see two recordings in the Web browser section of my checklist. I also can repro the negative tax amount issue in the transaction thread as you mentioned here. It seems I got red dot in the Tax field while you didn't.
Let me know if I should continue testing with other platforms or waiting for subsequent updates, thank you. |
|
@aldo-expensify looks like this is just held on the clarification above |
|
I resolved the conflicts and pushed a fix for the taxes showing negative. I don't think taxes will ever be negative, so I added a App/src/components/MoneyRequestConfirmationListFooter.tsx Lines 253 to 254 in f6eddbf just like we do for the amount: App/src/pages/iou/request/step/IOURequestStepConfirmation.tsx Lines 571 to 572 in f6eddbf With this change, the If you follow the testing steps it is possible that you end up with the report loading forever:
I think this is unrelated and is happening because of regressions coming from this PR: #40168 (I already fixed a very similar regression)
@eh2077 I'm not sure about this validation error, I haven't seen it while testing. It may be an unrelated bug? 🤷 Considering the skeleton loading forever problem, I'm not sure if you will be able to test correctly. Can you give it a try and see if works for you? |
|
@eh2077 could you please check this comment above when you have moment, thanks! |
|
@MonilBhavsar Sure, I just tried to re-test it. I found two issues this time
|
This is unrelated and seems to happen in
I pushed a fix for the negative tax, I missed that. About the validation error, I still don't see it, and it is probably unrelated. |
|
I'll re-test it today |
|
@aldo-expensify Kindly help to resolve the conflicts when you get a chance. |
|
@aldo-expensify Can you please clean up debugging console logs? Other than that code changes look good to me. Just realised that free trials of my exiting accounts have been ended. I have applied for free trials here. I'll complete the checklist asap once my account is granted with free trial. |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / Safari0-web.mp4MacOS: Desktop |
|
@tylerkaraszewski 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] |
|
@MonilBhavsar this is ready for internal review (friendly bump) |
|
Oops sorry I missed it. I was focussed on fireroom. I'll surely get to this tomorrow morning - the first thing |
MonilBhavsar
left a comment
There was a problem hiding this comment.
Thanks! Some minor comments. Doing some tests
| ? CurrencyUtils.convertToDisplayString(Math.abs(updatedTransaction?.taxAmount), transactionCurrency) | ||
| : CurrencyUtils.convertToDisplayString(Math.abs(transactionTaxAmount ?? 0), transactionCurrency); |
There was a problem hiding this comment.
Sorry, why this change?
There was a problem hiding this comment.
The tax amount is negative in some cases and we never want to display it as a negative number
| (transaction.taxAmount !== undefined && | ||
| previousTransactionAmount === transaction.amount && | ||
| previousTransactionCurrency === transaction.currency && | ||
| previousCustomUnitRateID === customUnitRateID && |
There was a problem hiding this comment.
Why we added customUnitRateID?
There was a problem hiding this comment.
Because if the rate changes we should recalculate the tax amount because it may have changed
| IOU.setMoneyRequestTaxRate(transactionID, defaultTaxCode ?? ''); | ||
| }, [customUnitRateID, policy, previousCustomUnitRateID, previousTransactionCurrency, previousTransactionModifiedCurrency, shouldShowTax, transaction, transactionID]); | ||
|
|
||
| // A flag for showing the billable field |
There was a problem hiding this comment.
This comment looks off from the code below it
There was a problem hiding this comment.
Probably a bad conflict resolution, I'll remove it.
|
Okay looks good and works fine! @eh2077 checklist is failing somehow, could you please a final look. Thanks! |
|
@MonilBhavsar I replied your questions and removed the comment that was added by mistake. Ready for review again. |
|
Bump @MonilBhavsar, It would be nice if this doesn't get conflicts again |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 9.0.22-0 🚀
|
|
🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 9.0.22-1 🚀
|
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 9.0.22-9 🚀
|
|
|
||
| const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy, isDistanceRequest) && !isTypeInvoice; | ||
|
|
||
| const previousTransactionAmount = usePrevious(transaction?.amount); |
| previousTransactionCurrency === transaction.currency && | ||
| previousCustomUnitRateID === customUnitRateID) | ||
| ) { | ||
| return; |
There was a problem hiding this comment.
We should have also returned if the request was read only. Not doing so caused #73621




Re-implementation of #42126
Details
Needs: https://github.com/Expensify/Auth/pull/10987 and https://github.com/Expensify/Web-Expensify/pull/42115
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-06-11.at.7.37.13.PM.mov
MacOS: Desktop