-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
support for offline tax tracking #40443
support for offline tax tracking #40443
Conversation
…6/support-for-offline-tax-tracking
…6/support-for-offline-tax-tracking
…6/support-for-offline-tax-tracking
…6/support-for-offline-tax-tracking
…6/support-for-offline-tax-tracking
This is bug with certain currencies where amount in small decimals is not supported. Not related to this PR |
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.
Looks good. Let's ship it! 🚀
✋ 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: 1.4.73-0 🚀
|
Hey @teneeto @MonilBhavsar. I believe this deploy blocker was introduced by this large PR. Would you mind taking a look? As this is a huge PR reverting isn't going to be ideal so ideally we can get a quick fix submitted. |
taxCode, | ||
taxAmount, |
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 is causing the deploy blocker: #42114 (comment)
🚀 Deployed to production by https://github.com/Beamanator in version: 1.4.73-7 🚀
|
hey, this PR caused a blocker - #42045 |
const transactionChanges = { | ||
taxCode, | ||
...(taxAmount && {taxAmount}), |
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.
It caused this bug, when taxAmount is zero, the value will be ignored
const getTaxAmount = (transaction: OnyxEntry<OnyxTypes.Transaction>, policy: OnyxEntry<OnyxTypes.Policy>) => { | ||
const defaultTaxCode = TransactionUtils.getDefaultTaxCode(policy, transaction) ?? ''; | ||
|
||
const taxPercentage = TransactionUtils.getTaxValue(policy, transaction, transaction?.taxCode ?? 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.
When the currency
differs from the current transaction currency
, the taxCode
should have also changed to the default (i.e. local or foreign based on the newly updated currency) tax rate. And, the tax amount should also have been recomputed. Missing these changes here resulted in issue #42049.
if (transaction?.taxAmount && previousTransactionAmount === transaction?.amount && previousTransactionCurrency === transaction?.currency) { | ||
return IOU.setMoneyRequestTaxAmount(transaction?.transactionID, transaction?.taxAmount, true); | ||
} |
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.
What is this block doing here? is it here in case the currency didn't change?
if transaction?.taxAmount && previousTransactionAmount
, what is the purpose of calling IOU.setMoneyRequestTaxAmount
? is the draft in a different state?
const defaultTaxCode = () => { | ||
if (!transaction) { | ||
return defaultExternalID; | ||
} | ||
|
||
return policy && getDefaultTaxCode(policy, transaction); | ||
}; |
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.
@teneeto Why did we wrap this code in a function? Why didn't we just do something like:
const defaultTaxCode = !transaction ? defaultExternalID : policy && getDefaultTaxCode(policy, transaction);
Are you expecting that policy
or transaction
can mutate?
const moneyRequestTaxPercentage = (transaction?.taxRate ? transaction?.taxRate?.data?.value : defaultTaxValue) ?? ''; | ||
const editingTaxPercentage = (transactionTaxCode ? taxRates?.taxes[transactionTaxCode]?.value : moneyRequestTaxPercentage) ?? ''; | ||
const defaultTaxCode = TransactionUtils.getDefaultTaxCode(policy, transaction) ?? ''; | ||
const getTaxValue = (taxCode: string) => TransactionUtils.getTaxValue(policy, transaction, taxCode); |
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.
Why did we create this getTaxValue
function, it is only used inside here, right? is it just to type getTaxValue(xxx)
instead of TransactionUtils.getTaxValue(policy, transaction, taxCode)
?
if (percentage) { | ||
return TransactionUtils.calculateTaxAmount(percentage, amount); | ||
function getTaxAmount(policy: OnyxEntry<Policy>, transaction: OnyxEntry<Transaction>, selectedTaxCode: string, amount: number): number | undefined { | ||
const getTaxValue = (taxCode: string) => TransactionUtils.getTaxValue(policy, transaction, taxCode); |
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.
Why did we define a function here? this makes the code more confusing
Details
This PR adds Support for tax tracking when offline.
Fixed Issues
$: 39616
PROPOSAL: 39616
Tests
Submit expense
(money request) flow.Expectation: when currency is changed from
Policy default currency
to another currency then let's make sure we use tax rate asforeign default
else it should remain asworkspace default
.Expectation: when changing request amount and tax rate offline, the tax amount will change accordingly and immediately.
Offline tests
Submit expense
(money request) flow.Expectation: when currency is changed from
Policy default currency
to another currency then let's make sure we use tax rate asforeign default
else it should remain asworkspace default
.Expectation: when changing request amount and tax rate offline, the tax amount will change accordingly and immediately.
QA Steps
Submit expense
(money request) flow.Expectation: when currency is changed from
Policy default currency
to another currency then let's make sure we use tax rate asforeign default
else it should remain asworkspace default
.Expectation: when changing request amount and tax rate offline, the tax amount will change accordingly and immediately.
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
MacOS: Chrome / Safari
Screen.Recording.2024-04-18.at.15.18.16.mov
iOS: Native
Android: Native
Android: mWeb Chrome
iOS: mWeb Safari
MacOS: Desktop