2012-01-27 13 views
4

Magento 1.5.1.0を実行していて、請求書合計の税計算に問題がありました。計算は店舗内のすべての合計で正しく行われますが、バックエンド請求書ビューとpdf請求書では不正確な合計が表示されます。Magento:請求書合計で不適切な税計算

間違ったの違いは、値を表示し、正しい値は、この画像を見ることができる。 (ショートバージョン:税金を出荷することは既に出荷中icludedれるが小計は、配送税を含む) http://i731.photobucket.com/albums/ww318/vitamin6/orderview_fixed.jpg

私はこの問題をfreelancer.comに掲載し、誰かがそれを修正することができました。後で判明したように、この修正はすべてのシナリオに適用されるわけではありません。注文が送料無料の場合、請求書の小計は間違っています。ここでの違いを示すためのスクリーンショットです: アプリの\コードを\ローカル\メイジ\セールス\モデル\注文\納品書\合計\小計: http://i731.photobucket.com/albums/ww318/vitamin6/orderview_freeship.jpg

はフリーランサー間違った税計算を修正するために、次のファイルを編集しました。 PHP

そこには、次のコード:

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

はこの1つで置換した。

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

誰かが私に正しい方向を教えてもらえますか?送料を無料にして注文を修正するためにファイルをさらに変更する必要がありますか? 必要に応じて税金設定などの詳細を記入することができます - 事前に感謝!

+0

2つのコアファイルを変更して自分自身を修正しました。 – loeffel

+0

また、私のためにそれを修正します。理由を本当に理解していない。 –

+0

あなたはそれを自分で修正するために正確に何を教えてもらえますか? – mniess

答えて

0

合計のソートにバグがあり、これはかなり怪我をする可能性があります。

合計を追加するモジュールはありますか?

はこの1つを見てください:https://stackoverflow.com/a/11954867/288568

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; 
    } } 
関連する問題