-
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
Improve tax API, split out Custom Rates plugin #4785
Improve tax API, split out Custom Rates plugin #4785
Conversation
Return some additional necessary details from getFulfillmentGroupTaxes
- fix #4687. Apply multiple custom tax rates - respect item.taxCode when calculating custom taxes
Added Akarshit as a reviewer as he is testing out the API by actually writing a tax plugin |
Testing this in the "classic UI" I don't get tax showing at all. |
Also get this error when checking out
|
So it looks like taxes are not being calculated because |
So even when I set It also appears that something about the migration is not working as the default product is not getting |
Even when creating a new product I can't set "Taxable" in the PDP |
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.
I'm not able to get taxes to calculate in either Classic or Storefront. Also not able to set "Taxable" on products in the PDP
imports/plugins/included/product-variant/containers/variantFormContainer.js
Show resolved
Hide resolved
@Akarshit @zenweasel Here is a starterkit branch with the UI fix: reactioncommerce/example-storefront#424 It should work with that branch of storefront and this branch of Reaction API |
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.
@aldeed This is still not working for me. If I have a product (like the default sample product) that has options and I set "isTaxable
on the variant, this is not properly being carried over to the options so isTaxable
is being set to false
on all options which is where the tax calculator looks to see if something is taxable so taxes never show up.
@aldeed Also, do we need a migration to set the Tax Code for all existing products to RC_TAX if Custom Rates are in use? It seems like you were saying that this Tax Code needs to be set for it to calculate tax as well. |
@zenweasel It is now working when purchasing options, and I fixed the Publish button indicator for the tax fields. I'm nervous about trying to automatically figure out "if custom rates is enabled" since in the past you could enable multiple tax plugins at once. I wouldn't want to set all variants to Some possible ideas:
@spencern Any thoughts on this? |
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.
Still does not appear to be calculating tax correctly when "Charge tax on shipping" is set
Multi-jurisdiction pricing does seem to be working |
} | ||
|
||
/** | ||
* @summary Modifies a fulfillment group, adding `taxRate` and `tax` properties to each item |
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.
I don't think this function actually modified the group
object.
|
@aldeed @zenweasel I lean towards option 2:
|
We should have a way to charge tax on shipping for the custom rates - on a per-locale basis. If that's not been implemented to this point, it could be a separate bit of work. |
@aldeed Question: tax plugins can add additional settings still, correct? I know Avalara has about another 10-15 settings that they require the user to set. I think what's probably missing with "charge tax on shipping' would be a "shipping tax code". I know with Avalara that was how it determined how to charge or exclude shipping from the 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.
We still have the issue of charging tax on shipping but that probably needs to be separate from this PR. So approving so we can get this merged and move forward.
@aldeed I am trying to place a order with tax and am getting the following pop-up: |
imports/plugins/core/orders/server/no-meteor/mutations/createOrder.js
Outdated
Show resolved
Hide resolved
Individual tax service plugins should implement this setting if necessary
when creating a new variant
Do not require the item tax code to match in order to charge taxes if the tax rate record does not include a taxCode. If the fix to filtering Custom Rates taxes by tax code is an undesired breaking change, you can revert to the old behavior by clearing out the "Tax Code" field in the Custom Rates definition now.
Co-Authored-By: aldeed <aldeed@gmail.com>
OK, so I've addressed the remaining things for now:
@Akarshit That checkout error appears to be an issue with storefront, that it isn't including the tax when trying to create the order. I'll fix that in the starterkit repo. Pretty sure this branch should be good to merge now, but I'll let it hang out for another day or two while you're still testing the custom plugin against it. |
@Akarshit Actually I was wrong. I believe that error would mean that your plugin's calculation function is returning |
I'm going to merge this since it's big and approved. Any more issues that are found can be submitted and fixed in a follow-up PR. |
Resolves #4710
Resolves #4711
Resolves #4712
Resolves #4687
Impact: breaking
Type: feature
Related docs updates: reactioncommerce/reaction-docs#707
Changes
taxes-rates
plugin in theincluded
folder, and all features related to custom rates have been moved there. This includes the "Custom Rates" panel in tax settings; theTaxes
collection and its related schemas; the "taxes/addRate", "taxes/editRate", and "taxes/deleteRate" Meteor methods, and the "Taxes" Meteor publication.taxes
plugin, the general settings have been converted to React, in aGeneralTaxSettings
component. This new component now allows you to set a single active tax service (or none). This replaces the previous way of enabling or disabling each service. All services are now enabled, but only one is active per shop.taxes
plugin has a new API for registering tax services (such as the included "Custom Rates" service, or a custom Avalara service for example). They are registered by passing in ataxServices
array toregisterPackage
:Every service must provide one function:
calculateOrderGroupTaxes
. It may also provide agetTaxCodes
function to return a list of tax codes so that operators can select from a list of tax codes rather than having to enter as free text. Refer to updated public docs for more information about these functions.taxes
plugin. This is true for both SimpleSchemas and GraphQL schemas.taxes
plugin has two new GraphQL queries:taxCodes
andtaxServices
taxes
plugin also has two new React HOCs that can be used for getting the list of tax codes or registered tax services:withTaxCodes
andwithTaxServices
taxes
plugin adds agetFulfillmentGroupTaxes
mutation (internal mutation, not GraphQL). This is called by theorder
andcart
plugins to (re)calculate taxes for orders and carts. Most of the actual calculation work is done by thecalculateOrderGroupTaxes
function that was registered by the active tax service.taxes
array, which now has a different schema and appears for individual items as well as the full cart or order fulfillment group.Products
documents,taxable
is nowisTaxable
. This change had previously been made in theCatalog
schema and now is made inProducts
to match.Breaking changes
These changes are breaking in a number of ways. There are breaking changes since 2.0.0-rc.5 release, but this also completes a broader set of breaking changes between 1.x and 2.x. The major version breaking changes are listed above.
In particular, for the Custom Rates plugin, be aware that the
taxCode
value is now used for filtering which products should be taxed at that rate. This requires a review of all your products to ensure that they have a tax code specified, in addition to being marked as taxable. If you'd rather not do this review, you can revert to the old behavior of ignoring tax codes by editing each of your Custom Rates entries, clearing the the "Tax Code" field, and saving.If you are upgrading from 1.x and use only Custom Rates for taxes, data migrations should provide a seamless transition. Most changes are breaking only for third-party non-included tax plugins. However, please verify after upgrading that the correct tax service is active.
Testing