In one of the project I was supposed to use the custom tax instead of magento tax and it was used for the display purpose. In our case Tax percent was associated with each product through custom attribute field ..
To achieve this I have analyzed magento default tax calsses and few blog links.

To start with below are the steps we need to follow :

Step 1 : In config.xml file do the below changes :

[codesyntax lang=”php”] <global>
……
<blocks>
…..
<sales>
<rewrite>
<order_totals>TW_<Yourmodule>_Block_Sales_Totals</order_totals>
</rewrite>
</sales>
<adminhtml>
<rewrite>
<sales_order_totals>TW_<Yourmodule>_Adminhtml_Block_Sales_Order_Totals</sales_order_totals>
<sales_order_invoice_totals>TW_<Yourmodule>_Adminhtml_Block_Sales_Order_Invoice_Totals</sales_order_invoice_totals>
<sales_order_creditmemo_totals>TW_<Yourmodule>_Adminhtml_Block_Sales_Order_Creditmemo_Totals</sales_order_creditmemo_totals>
</rewrite>
</adminhtml>

</blocks>
<sales>
<quote>
<totals>
<customtax>
<class><yourmodule>/sales_total_quote_customtax</class>
<after>subtotal,shipping,tax</after>
<before>grand_total</before>
</customtax>
</totals>
</quote>
<order_invoice>
<totals>
<customtax>
<class><yourmodule>/sales_order_total_invoice</class>
<after>subtotal,shipping,tax</after>
<before>grand_total</before>
</customtax>
</totals>
</order_invoice>
<order_creditmemo>
<totals>
<customtax>
<class><yourmodule>/sales_order_total_creditmemo</class>
<after>subtotal,shipping,tax</after>
<before>grand_total</before>
</customtax>
</totals>
</order_creditmemo>
</sales>
</global>[/codesyntax]

Step 2: To add your custom tax to the subtotal we to calculate the tax and add it to the total collection .

[codesyntax lang=”php”] < ?php
class TW_Model_Sales_Total_Quote_Customtax extends Mage_Sales_Model_Quote_Address_Total_Abstract {
public function __construct()
{
$this->setCode(‘custom_tax’);
}
/**
* Get label
*
* @return string
*/
public function getLabel()
{
return Mage::helper(‘quickcheckout’)->__(‘Tax’);
}
/**
* Collect totals information about insurance
*
* @param Mage_Sales_Model_Quote_Address $address
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
parent::collect($address);
if (($address->getAddressType() == ‘billing’)) {
return $this;
}
$tax_amount = $this->calculateCustomTax($address);

if ($tax_amount) {
$this->_addAmount($tax_amount);
$this->_addBaseAmount($tax_amount);
}

return $this;

}
/**
* Add giftcard totals information to address object
*
* @param Mage_Sales_Model_Quote_Address $address
*/
public function fetch(Mage_Sales_Model_Quote_Address $address)
{

if (($address->getAddressType() == ‘billing’)) {
return;
}
$tax_amount = $this->calculateCustomTax($address);
if ($tax_amount != 0) {
$address->addTotal(array(
‘code’ => $this->getCode(),
‘title’ => $this->getLabel(),
‘value’ => $tax_amount
));
}

return $this;
}
protected function calculateCustomTax(){
$items = $this->_getAddressItems($address);
$tax_amount = 0;
foreach ($items as $item) {
$qty = $item->getQty();
$price = $item->getPrice();
$product = Mage::getModel(‘catalog/product’)->load($item->getProductId());
$tax = $product->getItemTax();
$tax = trim($tax,”%”); // I am using % symbol in the text field so I trim it
$tax_amount += ($price * $qty)*$tax/100;
}

return $tax_amount;
}
}[/codesyntax] [codesyntax lang=”php”] < ?php
class TW__Model_Sales_Order_Total_Invoice extends Mage_Sales_Model_Order_Invoice_Total_Abstract
{
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
{
$order = $invoice->getOrder();
$taxAmount = Mage::helper(”)->calculateTax($order);
if ($taxAmount) {
$invoice->setGrandTotal($invoice->getGrandTotal() + $taxAmount);
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $taxAmount);
}

return $this;
}
}[/codesyntax] [codesyntax lang=”php”] < ?php
class TW__Model_Sales_Order_Total_Creditmemo extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
{
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
$amount = Mage::helper(”)->calculateTax($order);
if ($amount) {
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $amount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $amount);
}

return $this;
}
}[/codesyntax]

Step 3 :
After that the total price will be calculated with your fee, but you will not see your total row anywhere except cart/checkout page. So there are 3 blocks (order, invoice, creditmemo) where you need to add your total, we need to rewrite it which we already mentioned in the config file .

[codesyntax lang=”php”] < ?php
class TW__Block_Sales_Order_Totals extends Mage_Sales_Block_Order_Totals
{
/**
* Initialize order totals array
*
* @return Mage_Sales_Block_Order_Totals
*/
protected function _initTotals()
{
parent::_initTotals();
$orderModel = $this->getOrder();
$amount = Mage::helper(”)->calculateTax($orderModel);
if ($amount) {
$this->addTotalAfter(new Varien_Object(array(
‘code’ => ‘customtax’,
‘value’ => $amount,
‘base_value’=> $amount,
‘label’ => $this->helper(‘quickcheckout’)->__(‘Tax’),
), array(‘shipping’, ‘tax’)));
}

return $this;
}
}[/codesyntax] [codesyntax lang=”php”] < ?php
class TW__Adminhtml_Block_Sales_Order_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals
{
/**
* Initialize order totals array
*
* @return Mage_Adminhtml_Block_Sales_Order_Totals
*/
protected function _initTotals()
{
parent::_initTotals();
$orderModel = $this->getOrder();
$amount = Mage::helper(”)->calculateTax($orderModel);
if ($amount) {
$this->addTotalAfter(new Varien_Object(array(
‘code’ => ‘customtax’,
‘value’ => $amount,
‘base_value’=> $amount,
‘label’ => $this->helper(”)->__(‘Tax’),
), array(‘shipping’, ‘tax’)));
}

return $this;
}

}[/codesyntax] [codesyntax lang=”php”] < ?php
class TW__Adminhtml_Block_Sales_Order_Creditmemo_Totals extends Mage_Adminhtml_Block_Sales_Order_Creditmemo_Totals
{
/**
* Initialize order totals array
*
* @return Mage_Adminhtml_Block_Sales_Order_Creditmemo_Totals
*/
protected function _initTotals()
{
parent::_initTotals();
$orderModel = $this->getOrder();
$amount = Mage::helper(”)->calculateTax($orderModel);
if ($amount) {
$this->addTotalAfter(new Varien_Object(array(
‘code’ => ‘customtax’,
‘value’ => $amount,
‘base_value’=> $amount,
‘label’ => $this->helper(”)->__(‘Tax’),
), array(‘shipping’, ‘tax’)));
}

return $this;
}

}[/codesyntax] [codesyntax lang=”php”] < ?php
class TW__Adminhtml_Block_Sales_Order_Invoice_Totals extends Mage_Adminhtml_Block_Sales_Order_Invoice_Totals
{
/**
* Initialize order totals array
*
* @return Mage_Adminhtml_Block_Sales_Order_Invoice_Totals
*/
protected function _initTotals()
{
parent::_initTotals();
$orderModel = $this->getOrder();
$amount = Mage::helper(”)->calculateTax($orderModel);
if ($amount) {
$this->addTotalBefore(new Varien_Object(array(
‘code’ => ‘customtax’,
‘value’ => $amount,
‘base_value’=> $amount,
‘label’ => $this->helper(”)->__(‘Tax’),
), array(‘shipping’, ‘tax’)));
}

return $this;
}

}[/codesyntax]

Step 4: In the helper calss we will add the calculateTax function which is being called in all the classes..

[codesyntax lang=”php”] < ?php
class TW__Helper_Data extends Mage_Core_Helper_Abstract
{
public function calculateTax($order){
$tax_amount = 0;
foreach ($order->getAllItems() as $item) {
$qty = $item->getQtyOrdered();
$price = $item->getPrice();
$product = Mage::getModel(‘catalog/product’)->load($item->getProductId());
$tax = $product->getItemTax();
$tax_amount += ($price * $qty)*$tax/100;

}
return $tax_amount;
}
}[/codesyntax]