Magento: Incorrect tax calculation on bill amounts

I am running Magento 1.5.1.0 and had problems with tax calculation on bill amounts. While the calculation will be correct for all totals in my store, incorrect totals will be displayed on the invoice screen and in pdf invoices.

The difference between the incorrect, displayed value and the correct value can be seen in this figure: (Short version: the subtotal will include sales tax, although delivery tax is already included in the shipping cost) http://i731.photobucket.com/albums/ww318 /vitamin6/orderview_fixed.jpg

So, I posted this problem on freelancer.com, and someone managed to fix it. BUT, as I found out later, the correction does not apply to each scenario - if the order has free delivery, the invoice subtotal will still be incorrect. Here is a screenshot to show the difference: http://i731.photobucket.com/albums/ww318/vitamin6/orderview_freeship.jpg

The freelancer edited the following file to correct the incorrect tax calculation: Application \ code \ Local \ Mage \ Sales \ Model \ Order \ Account \ General \ Subtotal.php

Here is the following code:

if ($invoice->isLast()) { $subtotal = $allowedSubtotal; $baseSubtotal = $baseAllowedSubtotal; $subtotalInclTax = $allowedSubtotalInclTax; $baseSubtotalInclTax = $baseAllowedSubtotalInclTax; 

has been replaced by the following:

  if ($invoice->isLast()) { $subtotal = $allowedSubtotal; $baseSubtotal = $baseAllowedSubtotal; //$subtotalInclTax = $allowedSubtotalInclTax; //$baseSubtotalInclTax = $baseAllowedSubtotalInclTax; $subtotalInclTax = min($allowedSubtotalInclTax, $subtotalInclTax); $baseSubtotalInclTax = min($baseAllowedSubtotalInclTax, $baseSubtotalInclTax); 

Can someone point me in the right direction, how will I have to modify the file additionally to make the fix work for orders with free delivery? More information on tax settings, etc. It can be provided if necessary - thanks in advance!

+4
source share
2 answers

There is an error with sorting totals, which can cause quite serious problems.

Do you have modules that add totals?

Take a look at this: fooobar.com/questions/155014 / ...

0
source

It was a long time ago, and for me the problem was solved with one of the magento updates (now I'm on 1.8.1.0). I looked through my old files, and all I could find was this:

Application \ code \ core \ Mage \ Sales \ Model \ Order \ Account \ General \ Subtotal.php (taken from 1.7.0.2)

 <?php /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage * @package Mage_Sales * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ class Mage_Sales_Model_Order_Invoice_Total_Subtotal extends Mage_Sales_Model_Order_Invoice_Total_Abstract { /** * Collect invoice subtotal * * @param Mage_Sales_Model_Order_Invoice $invoice * @return Mage_Sales_Model_Order_Invoice_Total_Subtotal */ public function collect(Mage_Sales_Model_Order_Invoice $invoice) { $subtotal = 0; $baseSubtotal = 0; $subtotalInclTax= 0; $baseSubtotalInclTax = 0; $order = $invoice->getOrder(); foreach ($invoice->getAllItems() as $item) { if ($item->getOrderItem()->isDummy()) { continue; } $item->calcRowTotal(); $subtotal += $item->getRowTotal(); $baseSubtotal += $item->getBaseRowTotal(); $subtotalInclTax+= $item->getRowTotalInclTax(); $baseSubtotalInclTax += $item->getBaseRowTotalInclTax(); } $allowedSubtotal = $order->getSubtotal() - $order->getSubtotalInvoiced(); $baseAllowedSubtotal = $order->getBaseSubtotal() - $order->getBaseSubtotalInvoiced(); $allowedSubtotalInclTax = $allowedSubtotal + $order->getHiddenTaxAmount() + $order->getTaxAmount() - $order->getTaxInvoiced() - $order->getHiddenTaxInvoiced(); $baseAllowedSubtotalInclTax = $baseAllowedSubtotal + $order->getBaseHiddenTaxAmount() + $order->getBaseTaxAmount() - $order->getBaseTaxInvoiced() - $order->getBaseHiddenTaxInvoiced(); /** * Check if shipping tax calculation is included to current invoice. */ $includeShippingTax = true; foreach ($invoice->getOrder()->getInvoiceCollection() as $previousInvoice) { if ($previousInvoice->getShippingAmount() && !$previousInvoice->isCanceled()) { $includeShippingTax = false; break; } } if ($includeShippingTax) { $allowedSubtotalInclTax -= $order->getShippingTaxAmount(); $baseAllowedSubtotalInclTax -= $order->getBaseShippingTaxAmount(); } else { $allowedSubtotalInclTax += $order->getShippingHiddenTaxAmount(); $baseAllowedSubtotalInclTax += $order->getBaseShippingHiddenTaxAmount(); } if ($invoice->isLast()) { $subtotal = $allowedSubtotal; $baseSubtotal = $baseAllowedSubtotal; $subtotalInclTax = $allowedSubtotalInclTax; $baseSubtotalInclTax = $baseAllowedSubtotalInclTax; } else { $subtotal = min($allowedSubtotal, $subtotal); $baseSubtotal = min($baseAllowedSubtotal, $baseSubtotal); $subtotalInclTax = min($allowedSubtotalInclTax, $subtotalInclTax); $baseSubtotalInclTax = min($baseAllowedSubtotalInclTax, $baseSubtotalInclTax); } $invoice->setSubtotal($subtotal); $invoice->setBaseSubtotal($baseSubtotal); $invoice->setSubtotalInclTax($subtotalInclTax); $invoice->setBaseSubtotalInclTax($baseSubtotalInclTax); $invoice->setGrandTotal($invoice->getGrandTotal() + $subtotal); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseSubtotal); return $this; } } 
0
source

Source: https://habr.com/ru/post/1393363/


All Articles