-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat: Add support for fallback tax service #4871
Conversation
8353192
to
6c1db77
Compare
…ss-fallback-tax-service
@impactmass So there could be a case when the tax plugin is triggered but there was no shipping entered because of which the tax-service returned |
@Akarshit thanks for raising this scenario. As it is now, the fallback will also be called. And if fallback service also requires shipping info, it will also return Some thoughts: |
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.
Tested. Verified working per test instructions.
Merging this though I see a CI test error |
Resolves #4817
Issue:
Add ability to have two tax services configured and enabled, one primary and one fallback. The fallback should be used only when the primary is down, to ensure that orders can still be placed with taxes.
Changes
Updates
Shop Tax Settings
form to allow selection of a fallback tax service. Stores the value in the package DB entry undersettings
field asfallbackTaxServiceName
.Changed previous
active
-tax service nomenclature toprimary
, to reflect the addition of a fallbackChanged existing
getActiveTaxServiceForShop
togetTaxServicesForShop
. Now, getTaxServicesForShop returns both the primary and fallback tax services enabled for the shop.Add tests for
getTaxServicesForShop
capturing how it should behave with different inputsUpdate tax calculation step to use fallback config when primary returns
null
. This happens before falling back to default 0 tax (if forceZeroes is set)Breaking Changes
None. From my checks, the modified functions and names are all private to the core tax setup.
A migration is included for the schema field name change. An app's tax setting running previous release should work same even after getting this update.
Testing
Requirements: Two tax services should be provided. Reaction already includes a "custom-rates" tax plugin. I made a clone of the custom rates plugin and updated parts of it to enable using it as an extra tax service. You can pull that from here and add it as a custom plugin.
custom tax
, configure a rate with values like these:Country: US, Region: CA, Postal: 90405, Rate: 6
rapid-tax
(i.e the custom test plugin), configure a rate with values like these:Country: US, Region: CA, Postal: 90405, Rate: 100
calculateOrderTaxes
function in the custom plugin. Here you will change this line of code to make the plugin return null. This is so that the fallback tax config can kick in. After changing that, wait for the reaction app to restart.Note about Tax Codes