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(medusa): Upserting tax rates #4189

Merged
merged 4 commits into from
May 29, 2023
Merged

fix(medusa): Upserting tax rates #4189

merged 4 commits into from
May 29, 2023

Conversation

olivermrbl
Copy link
Contributor

@olivermrbl olivermrbl commented May 28, 2023

Fixes #4186

@olivermrbl olivermrbl requested a review from a team as a code owner May 28, 2023 10:09
@changeset-bot
Copy link

changeset-bot bot commented May 28, 2023

🦋 Changeset detected

Latest commit: 7efa11a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@medusajs/medusa Patch
@medusajs/admin-ui Patch
@medusajs/admin Patch
@medusajs/medusa-js Patch
medusa-payment-paypal Patch
medusa-payment-stripe Patch
medusa-plugin-restock-notification Patch
medusa-react Patch
@medusajs/medusa-oas-cli Patch
@medusajs/oas-github-ci Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@olivermrbl olivermrbl requested a review from srindom May 28, 2023 10:09
@vercel
Copy link

vercel bot commented May 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
medusa-docs ⬜️ Ignored (Inspect) May 29, 2023 5:44am

@@ -183,8 +182,8 @@ export class AdminPostTaxRatesTaxRateReq {
region_id?: string

@IsOptional()
@IsType([Number, null])
rate?: number | null
Copy link
Collaborator

Choose a reason for hiding this comment

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

thought: the design of taxes includes support for a nullable rate - the idea behind this is that if you are integrating with a third party system you may be in a situation where the numerical rate is dynamically computed through a 3rd party request. In this scenario, you use the TaxRate to tag the tax code to a product, collection, etc., the code is then used to compute and respond with the correct rate. E.g.:

  • Product - Book
  • TaxRate - code: book, rate: null
  • Cart - items: [book]
  • Total -> makes call to 3rd party with code: book and address: "some place with hyper local tax rates" -> responds with rate: 0.0932 -> This rate is used in cart total calculation

Copy link
Contributor Author

@olivermrbl olivermrbl May 29, 2023

Choose a reason for hiding this comment

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

This doesn't change with this PR. You can still create and update tax rates with a null rate. The changes here correct what is an inconsistent - and recently breaking - way of supporting a nullable payload at the API level.

I've added tests to ensure we are aligned on the intended behaviour. Can you confirm?

And I've kept the explicit null typing for DX purposes.

Copy link
Collaborator

@srindom srindom left a comment

Choose a reason for hiding this comment

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

LGTM!

@olivermrbl olivermrbl merged commit 6998666 into develop May 29, 2023
@olivermrbl olivermrbl deleted the fix/tax-rate-upsert branch May 29, 2023 11:31
@github-actions github-actions bot mentioned this pull request May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when adding a new tax rate
2 participants