onepica / avatax

One Pica Magento extension for sales tax calculation performed by Avatax
http://www.magentocommerce.com/magento-connect/6760.html
29 stars 34 forks source link

Wrong Coupon (by percent) calculation #9

Open carco opened 10 years ago

carco commented 10 years ago

I have a coupoun with 10% discount, and I get:

Subtotal                         $88.00     
Discount (10%)                   -$9.53
Tax                               $6.87 
-------------------------------------------
Grand Total                      $85.34

And I expect a $8.8 discount.

After (not so) few research, I think that I find the problem:

But, in helper, you have "return false" in function discountTax: https://github.com/onepica/avatax/blob/master/app/code/community/OnePica/AvaTax/Helper/Tax/Data.php#L119

The problem is, that exists some places, in magento: app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php

wich don't use Mage::helper('tax')->discountTax() to get this settings but:
$this->_config->discountTax($store) (_config is: Mage::getSingleton('tax/config'))

and, with no other settings, we have:

OnePica_AvaTax_Helper_Tax_Data::discountTax: false Mage_Tax_Model_Config::discountTax: true

My solution was to change in avatax/.../config.xml: <discount_tax>0</discount_tax> (instead 1), but, if this settings was saved before Avatax install, this will not solve the problem.

Probably you need to rewrite Mage_Tax_Model_Config (instead of Mage_Tax_Helper_Data, because helper use Config) or, at install, update in core_config_data the keys: tax/calculation/{based_on|price_includes_tax|shipping_includes_tax|apply_after_discount|discount_tax|apply_tax_on} we the needed values (same as in helper)

grikka commented 9 years ago

Hey, did you happen to do this change locally? If so, what were your before and after core_config values?