Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

Modify Magento TAX Calculation


Change the following file: magento\app\code\core\Mage\Tax\Model\Calculation.php

/**
     * Calculate rated tax abount based on price and tax rate.
     * If you are using price including tax $priceIncludeTax should be true.
     *
     * @param   float $price
     * @param   float $taxRate
     * @param   boolean $priceIncludeTax
     * @return  float
     */
    public function calcTaxAmount($price, $taxRate, $priceIncludeTax=false, $round=true)
    {
        $taxRate = 10;
		$taxRate = $taxRate/100;
		$this->insertInLog('taxRate', $taxRate);
		$this->insertInLog('price', $price);
        if ($priceIncludeTax) {
            $amount = $price*(1-1/(1+$taxRate));
        } else {
            $amount = $price*$taxRate;
        }
		$this->insertInLog('Amount', $amount);
        if ($round) {
            return $this->round($amount);
        } else {
            return $amount;
        }
    }


    /**
     * Insert in to Log Table. It helps to trace and stores in table
     *
     * @param   varchar $title
     * @param   varchar $desc
     */

	function insertInLog($title, $desc){		
		mysql_connect("localhost","root","");
		mysql_select_db("magento");
		$sql = "insert into log_tbl values('".$title."', '".$desc."', '".date("Y-m-d h:i:s")."')";
		mysql_query($sql);
	}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: