1

I need to add new column in Reports > Sales > Tax. The column should render Total amount on which tax is implemented. I've created a renderer but don't know how to fetch values in it. There are two tables in database that seems to work for it.

1) tax_order_aggregated_created
2) tax_order_aggregated_updated

I think, I have to add join query in the getResourceCollectionName() but not sure, how it will work for the issue.

Override Mage_Adminhtml_Block_Report_Sales_Tax_Grid::_prepareColumns() and add the following code.

$this->addColumn('taxtotal', array(
    'header' => Mage::helper('sales')->__('Tax Total'),
    'index' => 'taxtotal',
    'type' => 'string',
    'renderer'  => 'RLTS_GrandTotal_Block_Adminhtml_Sales_Order_Grid_Widget_Renderer_Taxtotal',
    'sortable'      => false,
));

and then add a renderer as follow

class RLTS_GrandTotal_Block_Adminhtml_Sales_Order_Grid_Widget_Renderer_Taxtotal
    extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
    /**
     * @param Varien_Object $row
     * @return string
     */
    public function render(Varien_Object $row)
{   
    $rate = $row->getData("percent");
    $numberOfOrders = $row->getData("orders_count");
    $taxAmount = $row->getData("tax_base_amount_sum");
    if($rate > 0 ){
        $finalPrice = ( $taxAmount * 100 ) / $rate;
        return Mage::helper('core')->currency($finalPrice, true, false) ;       
    }

    return ' '; 
}
}

it gives me the 'test' phrase successfully in new added column with label Tax Total. Now what I need to add return here that will gave me actual order's total.

Update: Now I've sorted out a work around and add a column by calculating it with tax percentage and tax amount as follow.

public function render(Varien_Object $row)
    {   
        $rate = $row->getData("percent");
        $numberOfOrders = $row->getData("orders_count");
        $taxAmount = $row->getData("tax_base_amount_sum");
        if($rate > 0 ){
            $finalPrice = ( $taxAmount * 100 ) / $rate;
            return Mage::helper('core')->currency($finalPrice, true, false) ;       
        }

        return ' '; 
    }

But I don't think it is the best way. It must be joined with probably sales_order table. Also with the above solution, I'm not able to add the total of newly added column.

  • It will be helpful if you add your code what you have tried. – Jaimin Sutariya Feb 1 '17 at 13:50
  • @JaiminSutariya I've updated the question with code I've created so far. – saiid Feb 1 '17 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.