Reputation: 3119
I finally got VAT (tax) working on my site with prices being entered in the catalog INCLUSIVE of tax. Then the decision was made to input value EXCLUSIVE of tax. A little SQL allowed me to change all the stored prices, however, when the catalog pages are displayed, the wrong values are being shown... tax is being applied twice!
The tax rate is 20% and if a product has a tax exclusive price of £10, it's showing as tax exclusive, £12.00 and tax inclusive £14.40.
If I click on the product then the product page shows the correct values of £10 and £12.
The template displaying the catalog prices is catalog/product/price.phtml and in there I see code which I'm not understanding (i.e. I assume it's correct because this is a well used product but it doesn't make sense to me!)
I see (in template/catalog/product/price.phtml), first of all, variables being set...
$_price = $_taxHelper->getPrice($_product, $_product->getPrice())
$_finalPrice = $_taxHelper->getPrice($_product, $_product->getFinalPrice())
$_finalPriceInclTax = $_taxHelper->getPrice($_product, $_product->getFinalPrice(), true)
and debug statements show these to be returning £10.00 and £12.00 as expected - and then £14.40 (not as expected!).
Further on, where the value is output I see...
<span class="price-excluding-tax <?=$groupclass?>">
<span class="label"><?php echo $this->helper('tax')->__('Excl. Tax:') ?></span>
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_price, true, false) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?>
<?php endif; ?>
</span>
</span>
So it seems to me that the final price should actually be the exclusive price but is actually including the tax, which then gets added in again!
That appears to be the mechanism but I assume I've got a setting wrong somewhere or others would have been yelling long before now!
In the configuration I've got it set saying catalog prices exclude tax and country of origin and default destination both as UK.
So what am I missing? This is Magento 1.7.0.2
Upvotes: 2
Views: 3888
Reputation: 121
I also spent a couple of days in this problem and I realized that sometimes totals are collected in the wrong order.
In particular in my case I was using catalog prices intended as including tax and I figured out Mage_Sales_Model_Quote_Address_Total_Subtotal::collect() ran before Mage_Tax_Model_Sales_Total_Quote_Subtotal::collect(), you can understand is the same issue looking at the table sales_flat_quote_item, when the base_price field is correctly set with the price value excluding tax and the price field is set with the price gross value (including tax).
You can check the execution order of collect method for each total in app/code/core/Mage/Sales/Model/Quote/Address.php around line #1004
/**
* Collect address totals
*
* @return Mage_Sales_Model_Quote_Address
*/
public function collectTotals()
{
Mage::dispatchEvent($this->_eventPrefix . '_collect_totals_before', array($this->_eventObject => $this));
foreach ($this->getTotalCollector()->getCollectors() as $model) {
// this is the loop where totals are collected
$model->collect($this);
}
Mage::dispatchEvent($this->_eventPrefix . '_collect_totals_after', array($this->_eventObject => $this));
return $this;
}
to fix this kind of issue you have to define in config.xml of a custom module totals dependencies defining <after>
and <before>
where necessary
<config>
...
<global>
<sales>
<quote>
<totals>
<tax_subtotal>
<class>tax/sales_total_quote_subtotal</class>
<after>subtotal,nominal,shipping,freeshipping</after>
<before>tax,discount</before>
</tax_subtotal>
</totals>
</quote>
</sales>
</global>
...
</config>
Thanks again Magento for making my day always more interesting!
Upvotes: 1
Reputation: 11853
In administration go to settings > sales > tax > calculation
-
And here set “tax based on” to the last item (package origin, or something like that). Terms are not perfect,
Or you can change setting accordingly as you want in your cart.
if your code it perfect then you are just missing some configuration on it.
Also you can go throw all the inner tabs fo tax calculation.
i hope it will sure help you
Upvotes: 0