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

[HOLD for payment 2024-04-05] [Simplified Collect][Taxes] Optimistically create default tax rates #38234

Closed
luacmartins opened this issue Mar 13, 2024 · 20 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@luacmartins
Copy link
Contributor

Coming from this PR and this comment, we need to optimistically create default tax rates when enabling the Tax feature on the More features page.

This issue has two parts to it.

  1. We need to optimistically create the default rates in App when enabling the feature
  2. The backend needs to process the created rates and store it in the DB

cc @filip-solecki @kosmydel

@luacmartins luacmartins added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 13, 2024
@luacmartins luacmartins self-assigned this Mar 13, 2024
Copy link

melvin-bot bot commented Mar 13, 2024

Triggered auto assignment to @trjExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@luacmartins luacmartins moved this to Release 1: Spring 2024 (May) in [#whatsnext] #wave-collect Mar 13, 2024
@nkdengineer
Copy link
Contributor

nkdengineer commented Mar 14, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

  • Optimistically create default tax rates

What is the root cause of that problem?

  • In here, we do not have a logic to create the optimistic tax data once when enabling the feature

What changes do you think we should make in order to solve the problem?

  • Generally, when enabling the tax feature, we need to set the default data to policy.taxRates if it is not set yet:
{
    "defaultExternalID": "id_TAX_EXEMPT",
    "defaultValue": "0%",
    "foreignTaxDefault": "id_TAX_EXEMPT",
    "name": "Tax",
    "taxes": {
        "id_TAX_EXEMPT": {
            "name": "Tax exempt",
            "value": "0%"
        },
        "id_TAX_OPTION_1": {
            "name": "Tax option 1",
            "value": "5%"
        }
    }
}
  • Below is the details steps:
  1. Create a optimisticTaxRatesData:
    const optimisticTaxRatesData = {
        onyxMethod: Onyx.METHOD.MERGE,
        key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
        value: {
            tax: {
                trackingEnabled: enabled,
            },
            taxRates: {
                defaultExternalID: 'id_TAX_EXEMPT',
                defaultValue: '0%',
                foreignTaxDefault: 'id_TAX_EXEMPT',
                name: 'Tax',
                taxes: {
                    id_TAX_EXEMPT: {
                        name: 'Tax exempt',
                        value: '0%',
                    },
                    id_TAX_OPTION_1: {
                        name: 'Tax option 1',
                        value: '5%',
                    },
                },
            },
        },
    };
  1. Used the condition isEmpty(policy.taxRates) && enabled to decide whether we should use the above optimisticData or not.

  2. If the API is called failed, update the failureData as well.

  3. We also need to consider the policyTaxRates_policyID data

What alternative solutions did you explore? (Optional)

  • NA

Copy link

melvin-bot bot commented Mar 14, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@nkdengineer
Copy link
Contributor

@luacmartins Can contributor work on this issue?

@luacmartins
Copy link
Contributor Author

Yes, I think that'd be ok if you can prioritize this issue and get a PR up in a day.

@nkdengineer
Copy link
Contributor

nkdengineer commented Mar 14, 2024

@luacmartins Sure thanks. Can yoou assign the issue to me then I will create PR for it

@nkdengineer
Copy link
Contributor

I am working on it

@DylanDylann
Copy link
Contributor

@luacmartins This issue comes from #37870, If we need a C+ to review PR, I am happy to take over as a high-priority

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Mar 15, 2024
@nkdengineer
Copy link
Contributor

@luacmartins The PR #38375 is ready to review

Copy link

melvin-bot bot commented Mar 25, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Mar 29, 2024
@melvin-bot melvin-bot bot changed the title [Simplified Collect][Taxes] Optimistically create default tax rates [HOLD for payment 2024-04-05] [Simplified Collect][Taxes] Optimistically create default tax rates Mar 29, 2024
Copy link

melvin-bot bot commented Mar 29, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Mar 29, 2024
Copy link

melvin-bot bot commented Mar 29, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.57-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-04-05. 🎊

For reference, here are some details about the assignees on this issue:

  • @nkdengineer requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Mar 29, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@luacmartins] The PR that introduced the bug has been identified. Link to the PR:
  • [@luacmartins] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@luacmartins] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@nkdengineer] Determine if we should create a regression test for this bug.
  • [@nkdengineer] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@trjExpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

Copy link

melvin-bot bot commented Apr 5, 2024

Payment Summary

Upwork Job

BugZero Checklist (@trjExpensify)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@rojiphil
Copy link
Contributor

rojiphil commented Apr 5, 2024

@MelvinBot @trjExpensify I was a reviewer for the PR as can be seen here.
And it looks like my name got missed in the payment summary. Please note.

@trjExpensify
Copy link
Contributor

Assigned you so we track that, @rojiphil. Confirming the number of regressions here. One false positive, one legit. Sound right?

@luacmartins
Copy link
Contributor Author

@trjExpensify I this this one is also a false positive, since the comment in the linked issue mentions that this PR is solving it. So I don't think we had any legit regressions on this one.

@trjExpensify
Copy link
Contributor

Okay, perfect. Works for me! Payment summary as follows:

Offers sent!

@rojiphil
Copy link
Contributor

rojiphil commented Apr 8, 2024

@trjExpensify Offer accepted. Thanks.

@luacmartins luacmartins added Daily KSv2 and removed Weekly KSv2 labels Apr 8, 2024
@trjExpensify
Copy link
Contributor

Settled up with you both!

@github-project-automation github-project-automation bot moved this from Release 1: Spring 2024 (May) to Done in [#whatsnext] #wave-collect Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2
Projects
No open projects
Archived in project
Development

No branches or pull requests

5 participants