taxjar / taxjar-woocommerce-plugin

WooCommerce Sales Tax Plugin by TaxJar
http://www.taxjar.com/woocommerce-sales-tax-plugin/
GNU General Public License v2.0
28 stars 29 forks source link

Prevent calculated tax rates from being saved to database #224

Closed welenofsky closed 2 years ago

welenofsky commented 2 years ago

Closes #221

This PR adds an optional parameter to Tax_Builder::build_line_tax_from_rate to prevent saving some tax rates to WooCommerce. This will prevent saving any tax rates that are calculated based on taxes applied to line items which are used as variables of other calculations. Another solution to this would be to expose the private method build_woocommerce_rate but I wanted to get your feedback on this. I have ran this patch both in my staging environment and production now for a few days and everything has been going smooth.

Here are some photos of the production data after the application of the patch.

taxjar-api-rate This is the tax rate for this orders ZIP code from the taxjar sales tax calculator.

rates-saved-db-rate_percent-taxjar This is the tax rate saved to the order item which is the rate percent my customer uses to send to an upstream provider as explained in #221. It now matches the correct value from taxjar sales tax calculation.

rates-saved-db-woocommerce Here are various rates that have been calculated over the course of a few days for taxable orders. All of which are now matching the taxjar sales tax calculator values.

Click-Test Versions

Specs Passing

dallendalton commented 2 years ago

Closing in favor of https://github.com/taxjar/taxjar-woocommerce-plugin/pull/225