2012-01-27 149 views
4

我正在運行Magento 1.5.1.0,並用於對發票總計進行稅務計算問題。雖然我的商店中所有總計的計算都是正確的,但後端發票視圖和pdf發票將顯示不正確的總計。 (簡短的版本:小計將包括船舶噸稅,雖然運費稅航運已經icluded) http://i731.photobucket.com/albums/ww318/vitamin6/orderview_fixed.jpgMagento:關於發票總計的稅額計算錯誤

錯誤,顯示值和修正值之間的差異可以在這個圖片中可以看出

所以我在freelancer.com上發佈了這個問題,並且有人設法解決了這個問題。但是,後來我發現,修復並未涵蓋所有情況 - 如果訂單已免費送貨,發票小計仍然不正確。下面是截圖以示區別: http://i731.photobucket.com/albums/ww318/vitamin6/orderview_freeship.jpg

自由職業者編輯以下文件來修復錯誤的稅額計算: 應用程序\代碼\本地\法師\銷售\型號\訂單\發票\共\小計。 PHP

在有以下代碼:

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

替換爲這一個:

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

有人可以指出我正確的方向,我將不得不進一步修改文件以使訂單免費送貨的修復工作? 如果需要,可以提供有關稅務設置等的更多詳情 - 預先感謝您!

+0

通過修改兩個核心文件自己修復它。 – loeffel 2012-04-02 16:23:16

+0

也爲我修復它。不明白爲什麼。 – 2012-05-15 11:14:50

+0

你能告訴我你自己做了什麼來修復它嗎? – mniess 2012-07-04 12:01:52

回答

0

這是很久以前的事,對我的問題得到了與Magento的更新(我是1.8.1.0的時刻)的一個解決。 我通過舊文件去了,所有我能找到的是這個編輯:

應用程序\代碼\核心\法師\銷售\型號\訂單\發票\共\ Subtotal.php (從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 [email protected] 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; 
    } }