Skip to content
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: "Default" label changes to "Workspace currency default" after changing tax code #48105

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/libs/actions/TaxRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,17 @@ function renamePolicyTax(policyID: string, taxID: string, newName: string) {
function setPolicyTaxCode(policyID: string, oldTaxCode: string, newTaxCode: string) {
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`];
const originalTaxRate = {...policy?.taxRates?.taxes[oldTaxCode]};
const oldDefaultExternalID = policy?.taxRates?.defaultExternalID;
const oldForeignTaxDefault = policy?.taxRates?.foreignTaxDefault;
const onyxData: OnyxData = {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
taxRates: {
defaultExternalID: oldTaxCode === policy?.taxRates?.defaultExternalID ? newTaxCode : policy?.taxRates?.defaultExternalID,
defaultExternalID: oldTaxCode === oldDefaultExternalID ? newTaxCode : oldDefaultExternalID,
foreignTaxDefault: oldTaxCode === oldForeignTaxDefault ? newTaxCode : oldForeignTaxDefault,
taxes: {
[oldTaxCode]: null,
[newTaxCode]: {
Expand All @@ -514,7 +517,8 @@ function setPolicyTaxCode(policyID: string, oldTaxCode: string, newTaxCode: stri
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
taxRates: {
defaultExternalID: oldTaxCode === policy?.taxRates?.defaultExternalID ? newTaxCode : policy?.taxRates?.defaultExternalID,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etCoderDysto why don't we need to set successData?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am checking if removing it causes any issue.

Copy link
Contributor Author

@etCoderDysto etCoderDysto Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushatgabhane When we updated tax code of default tax rate, BE will update the defaultExternalID and foreignTaxDefault with the new tax code we have updated the default tax code, and merges the data to onyx.
Screenshot 2024-08-27 at 10 05 27 at night

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure I understand, you're saying that setting the successData does cause a problem?

Copy link
Contributor Author

@etCoderDysto etCoderDysto Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushatgabhane I can defaultExternalID and foreignTaxDefault to abide by the docs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do that then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

defaultExternalID: oldTaxCode === oldDefaultExternalID ? newTaxCode : oldDefaultExternalID,
foreignTaxDefault: oldTaxCode === oldForeignTaxDefault ? newTaxCode : oldForeignTaxDefault,
taxes: {
[oldTaxCode]: null,
[newTaxCode]: {
Expand All @@ -535,7 +539,8 @@ function setPolicyTaxCode(policyID: string, oldTaxCode: string, newTaxCode: stri
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
taxRates: {
defaultExternalID: policy?.taxRates?.defaultExternalID,
defaultExternalID: oldDefaultExternalID,
foreignTaxDefault: oldForeignTaxDefault,
taxes: {
[newTaxCode]: null,
[oldTaxCode]: {
Expand Down
Loading