Search code examples
phpmagentoentity-attribute-value

Magento: tax deducted instead of added


My excluding tax amounts are treated as if they are including tax. Now I know you would say I've my settings messed up but they are correctly set on excluding tax. If I enable the tax settings for the row it does show 10 jeans for 10 euro each, makes a 100 euro ex and 119 (19% dutch tax) including tax.

Example:

Subtotal:           100
Shipping:           50
Grand Total ex:     121,5
TAX:                28,5
Grand Total In:     150

I've found one other case with the same problem but sadly enough no answer... http://www.magentocommerce.com/answers/Catalog-prices-do-not-include-tax-but-if-I-check-excluding-tax-my-prices-change

CopyPaste example

Subtotal (Excl. Tax)    € 65,20
Subtotal (Incl. Tax)    € 77,59
Shipping Excl. Tax (Flat Rate - Fixed)  € 50,00
Shipping Incl. Tax (Flat Rate - Fixed)  € 59,50 
Totaal Excl. BTW    € 93,31
BTW € 21,89
Totaal Incl. BTW    € 115,20 

Solution

  • It is far far far from pretty, but the following works!

    19% is the dutch tax amount

    class Mage_Sales_Model_Quote_Address_Total_Grand extends Mage_Sales_Model_Quote_Address_Total_Abstract
    {
        /**
         * Collect grand total address amount
         *
         * @param   Mage_Sales_Model_Quote_Address $address
         * @return  Mage_Sales_Model_Quote_Address_Total_Grand
         */
        public function collect(Mage_Sales_Model_Quote_Address $address)
        {
            $grandTotal     = $address->getGrandTotal();
            $baseGrandTotal = $address->getBaseGrandTotal();
    
            $totals     = array_sum($address->getAllTotalAmounts());
            $baseTotals = array_sum($address->getAllBaseTotalAmounts());
    
            $address->setGrandTotal(($grandTotal+$totals) * 1.19);
            $address->setBaseGrandTotal(($grandTotal+$totals) * 1.19);
            return $this;
        }
    
        /**
         * Add grand total information to address
         *
         * @param   Mage_Sales_Model_Quote_Address $address
         * @return  Mage_Sales_Model_Quote_Address_Total_Grand
         */
        public function fetch(Mage_Sales_Model_Quote_Address $address)
        {
            $address->addTotal(array(
                'code'  => $this->getCode(),
                'title' => Mage::helper('sales')->__('Grand Total'),
                'value' => $address->getGrandTotal(),
                'area'  => 'footer',
            ));
            return $this;
        }
    }