-
-
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(medusa): Upserting tax rates #4189
Conversation
🦋 Changeset detectedLatest commit: 7efa11a The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
@@ -183,8 +182,8 @@ export class AdminPostTaxRatesTaxRateReq { | |||
region_id?: string | |||
|
|||
@IsOptional() | |||
@IsType([Number, null]) | |||
rate?: number | 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.
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
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 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.
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.
LGTM!
Fixes #4186