payment gateway - unable to add invoice fee tax in magento order total -


i working on magento 1.7. working on payment gateway have added invoice fee have add tax of invoice fee in tax group enter image description here

please solve problem here following code have tried add tax amount in taxes still not working may doing wrong

<?php  class ***_******_model_quote_taxtotal     extends mage_sales_model_quote_address_total_tax {      public function collect(mage_sales_model_quote_address $address)     {         $quote = $address->getquote();         if (($quote->getid() == null)             || ($address->getaddresstype() != "shipping")         ) {             return $this;         }          $payment = $quote->getpayment();         if (($payment->getmethod() != 'invoice')             && (!count($quote->getpaymentscollection()))         ) {             return $this;         }          try {             /**              * instead of relying on hasmethodinstance not              * work when i.e order total reloaded coupon codes,              * try instance directly instead.              */             $methodinstance = $payment->getmethodinstance();         } catch (mage_core_exception $e) {             return $this;         }          if (!$methodinstance instanceof mage_payment_model_method_abstract) {             return $this;         }          if ($methodinstance->getcode() != 'invoice') {             return $this;         }          $fee = $methodinstance->getaddressinvoicefee($address);         if(mage::getstoreconfig('payment/invoice/tax_class') == '' ){             return $this;         }          $invoicefee = $baseinvoicefee = mage::getstoreconfig('payment/invoice/_fee');          $fee = mage::helper('invoice')->getinvoicefeearray($invoicefee, $address, null);          if (!is_array($fee)) {             return $this;         }         $address->settaxamount($address->gettaxamount() + 5454+ $fee['taxamount']);         $address->setbasetaxamount(             $address->getbasetaxamount() + 5454+ $fee['base_taxamount']         );          $address->setinvoicetaxamount($fee['taxamount']);         $address->setbaseinvoicetaxamount($fee['base_taxamount']);         return $this;     }  } 

and config.xml

    <sales>         <quote>             <totals>                 <fee>                     <class>invoice/sales_quote_address_total_fee</class>                 </fee>                 <invoicetax>                     <class>invoice/quote_taxtotal</class>                     <after>subtotal,discount,shipping,tax</after>                     <before>grand_total</before>                 </invoicetax>             </totals>         </quote>     </sales> 

your code must following have following modified code

<?php  class *****_******_model_quote_taxtotal extends mage_sales_model_quote_address_total_tax {     public function collect(mage_sales_model_quote_address $address)     {         $collection = $address->getquote()->getpaymentscollection();         if ($collection->count() <= 0 || $address->getquote()->getpayment()->getmethod() == null) {             return $this;         }          $paymentmethod = $address->getquote()->getpayment()->getmethodinstance();          if ($paymentmethod->getcode() != 'invoice') {                         return $this;         }          $store = $address->getquote()->getstore();                  $items = $address->getallitems();         if (!count($items)) {             return $this;         }          $custtaxclassid = $address->getquote()->getcustomertaxclassid();          $taxcalculationmodel = mage::getsingleton('tax/calculation');         /* @var $taxcalculationmodel mage_tax_model_calculation */         $request = $taxcalculationmodel->getraterequest(             $address,             $address->getquote()->getbillingaddress(),             $custtaxclassid,             $store         );         $invoicetaxclass = mage::helper('invoice')->getinvoicetaxclass($store);          $invoicetax      = 0;         $invoicebasetax  = 0;          if ($invoicetaxclass) {             if ($rate = $taxcalculationmodel->getrate($request->setproductclassid($invoicetaxclass))) {                  if (!mage::helper('invoice')->invoicepriceincludestax()) {                     $invoicetax    = $address->getfeeamount() * $rate/100;                     $invoicebasetax= $address->getbasefeeamount() * $rate/100;                 } else {                     $invoicetax    = $address->getpaymenttaxamount();                     $invoicebasetax= $address->getbasepaymenttaxamount();                 }                  $invoicetax    = $store->roundprice($invoicetax);                 $invoicebasetax= $store->roundprice($invoicebasetax);                  $address->settaxamount($address->gettaxamount() + $invoicetax);                 $address->setbasetaxamount($address->getbasetaxamount() + $invoicebasetax);                  $this->_saveappliedtaxes(                     $address,                     $taxcalculationmodel->getappliedrates($request),                     $invoicetax,                     $invoicebasetax,                     $rate                 );             }         }          if (!mage::helper('invoice')->invoicepriceincludestax()) {             $address->setinvoicetaxamount($invoicetax);             $address->setbaseinvoicetaxamount($invoicebasetax);         }          $address->setgrandtotal($address->getgrandtotal() + $address->getpaymenttaxamount());         $address->setbasegrandtotal($address->getbasegrandtotal() + $address->getbasepaymenttaxamount());          return $this;     }      public function fetch(mage_sales_model_quote_address $address)     {                 $store = $address->getquote()->getstore();         /**          * modify subtotal          */           if (mage::getsingleton('tax/config')->displaycartsubtotalboth($store) ||             mage::getsingleton('tax/config')->displaycartsubtotalincltax($store)) {              if ($address->getsubtotalincltax() > 0) {                 $subtotalincltax = $address->getsubtotalincltax();             } else {                 $subtotalincltax = $address->getsubtotal()+ $address->gettaxamount() -                     $address->getshippingtaxamount() - $address->getpaymenttaxamount();             }                          $address->addtotal(                 array(                     'code'      => 'subtotal',                     'title'     => mage::helper('sales')->__('subtotal'),                     'value'     => $subtotalincltax,                     'value_incl_tax' => $subtotalincltax,                     'value_excl_tax' => $address->getsubtotal()                 )             );         }         return $this;     } } 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -