-
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
fix: add default rates data #38375
fix: add default rates data #38375
Changes from 6 commits
060df3d
4ca4290
385893f
5e03c10
f0a87ff
578d2d9
23e9eff
8ca415f
1948ce0
47a2dc7
b4e2493
f49fd7e
bd33bd3
b7e8947
2437b2c
713782d
95af3e3
016e4f1
c915f96
d26c90d
469be4c
2d751ea
ec240ac
0cd290e
0b1005e
dc5dfda
3472f14
c923ed6
250baa9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3415,6 +3415,36 @@ function enablePolicyTags(policyID: string, enabled: boolean) { | |
} | ||
|
||
function enablePolicyTaxes(policyID: string, enabled: boolean) { | ||
const taxRatesData: OnyxData = { | ||
optimisticData: [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, | ||
value: { | ||
taxRates: { | ||
defaultExternalID: CONST.TAXES.DEFAULT.EXTERNAL_ID, | ||
defaultValue: CONST.TAXES.DEFAULT.VALUE, | ||
foreignTaxDefault: CONST.TAXES.DEFAULT.FOREIGN_ID, | ||
name: CONST.TAXES.DEFAULT.NAME, | ||
taxes: { | ||
[CONST.TAXES.DEFAULT.EXEMPT_ID]: { | ||
name: CONST.TAXES.DEFAULT.EXEMPT_NAME, | ||
value: CONST.TAXES.DEFAULT.EXEMPT_VALUE, | ||
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, | ||
}, | ||
[CONST.TAXES.DEFAULT.TAX_RATE_1_ID]: { | ||
name: CONST.TAXES.DEFAULT.TAX_RATE_1_NAME, | ||
value: CONST.TAXES.DEFAULT.TAX_RATE_1_VALUE, | ||
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's create a const with these defaults There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @luacmartins Apologies as it looks like I introduced some confusion here. I was unaware of your earlier review comments about using individual values in CONST to generate |
||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}; | ||
nkdengineer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const policy = ReportUtils.getPolicy(policyID); | ||
const shouldAddDefaultTaxRatesData = isEmptyObject(policy.taxRates) && enabled; | ||
luacmartins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const onyxData: OnyxData = { | ||
optimisticData: [ | ||
{ | ||
|
@@ -3429,6 +3459,7 @@ function enablePolicyTaxes(policyID: string, enabled: boolean) { | |
}, | ||
}, | ||
}, | ||
...(shouldAddDefaultTaxRatesData ? taxRatesData.optimisticData ?? [] : []), | ||
nkdengineer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
], | ||
successData: [ | ||
{ | ||
|
@@ -3449,6 +3480,7 @@ function enablePolicyTaxes(policyID: string, enabled: boolean) { | |
tax: { | ||
trackingEnabled: !enabled, | ||
}, | ||
taxRates: undefined, | ||
pendingFields: { | ||
tax: null, | ||
}, | ||
|
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.
These data are obtained when I try turning on the tax feature in OD
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.
@luacmartins @kosmydel @filip-solecki
Please confirm if the following default tax rates as per @nkdengineer proposal would match the BE defaults.
Also, is localization required for
name
i.e. "Tax", "Tax exempt", "Tax option 1"?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.
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 left a comment above, I think the only difference is
id_TAX_OPTION_1
should beid_TAX_RATE_1
and same for the nameTax option 1
->Tax rate 1
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 the code has incorporated most of these already. Only one minor change is pending:
Tax Rate 1
->Tax rate 1