Magento &贝宝税务四舍五入问题 [英] Magento & Paypal tax rounding issue

查看:20
本文介绍了Magento &贝宝税务四舍五入问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Paypal 和 Magento 1.7.0.2 时遇到一些四舍五入问题 - 网站上的所有价格均含税,税费按 20% (VAT) 计算.

I have some rounding issues with Paypal and Magento 1.7.0.2 - All prices on the site include tax and the tax is worked out at 20% (VAT).

我去结帐,一切都正确:

I will go to checkout and everything is correct:

然后我会点击下订单,Paypal 会是这样的,这是不正确的,因为现在总计少了 1p.这似乎是由于税收的四舍五入方式造成的.

I will then click on place order, and Paypal will be like this, which is incorrect because the grand total is now 1p less. This appears to be cause by how the tax is rounded.

在某些情况下,它可以正常工作,但在其他情况下,税收四舍五入不正确.我曾尝试更改 app/code/core/Mage/Tax/Model/Calculation.php

In some cases, it works ok, but in others the tax is rounded incorrectly. I have tried making changes to the tax calculation method calcTaxAmount() in app/code/core/Mage/Tax/Model/Calculation.php

我将此添加到 calcTaxAmount 方法中,该方法似乎修复了它,但它会导致产品页面上的价格不正确(少 1p).

I added this to the calcTaxAmount method which seemed to fix it, but it cause the prices on the product page to then be incorrect (1p less).

$amount = $this->roundUp($amount);

我很确定这是一个错误,但我没有想法.如果有人以前遇到过这个问题并且有解决方案,我会很高兴听到它.非常感谢任何帮助.

I'm pretty certain this is a bug, but I'm out of ideas. If anyone has come across this before and has a solution I'd be happy to hear it. Any help much appreciated.

这是我在 Magento 中的税务设置

推荐答案

这个问题一直困扰着我(从这个问题来看,magento 社区已经多年),感谢 ShopWorks 朝着正确的方向推动(包括他的代码片段),谢谢伙计!但是,如果从快速结账返回购物车,它会出错,添加了一个签入来防止这种情况.)我想出了以下修复(/hack)的 $request 参数:

This problem has been plaguing me (and by looks of it the magento community for ages), thanks to ShopWorks push in the right direction (inclusive of his code snippet, thanks mate! However it would bug out if going back to the cart from express checkout, added a check in to prevent this.) of the $request parameters I came up with the following fix (/hack):

在 Nvp.php 的第 606 行放置以下内容:

On line 606 of Nvp.php place the following:

$totalValue = $request['TAXAMT'] + $request['ITEMAMT'];
$finalValue = $totalValue - $request['AMT'];

if($request['SHIPPINGAMT'] > 0) {
    $request['SHIPPINGAMT'] = ($request['AMT'] - ($request['TAXAMT'] + $request['ITEMAMT']));
    $totalValue = $request['TAXAMT'] + $request['ITEMAMT'] + $request['SHIPPINGAMT'];
    $finalValue = $totalValue - $request['AMT'];
}

if($request['AMT'] != $totalValue) {
    if($totalValue > $request['AMT']) {
        $request['TAXAMT'] = $request['TAXAMT'] - $finalValue;
    } elseif($totalValue < $request['AMT']) {
        $request['TAXAMT'] = $request['TAXAMT'] + $finalValue;
    } else {
        $request['AMT'] = $request['TAXAMT'] + $request['ITEMAMT'];
    }
}

另外,在 call() 函数中还需要放置以下内容(Nvp.php 的第 938 行):

Additionally, the following needs to be also placed within the call() function (line 938 of Nvp.php):

$totalValue = $request['TAXAMT'] + $request['ITEMAMT'] + $request['SHIPPINGAMT'];
$finalValue = $totalValue - $request['AMT'];

if($request['AMT'] != $totalValue) {
    if($totalValue > $request['AMT']) {
        if($finalValue > 0) {
            // its preferable that we change the tax amount over the grand total amount
            $request['TAXAMT'] = $request['TAXAMT'] - $finalValue;
        } else {
            $request['AMT'] = $totalValue;
        }
    } elseif($totalValue < $request['AMT']) {
        if($finalValue > 0) {
            // its preferable that we change the tax amount over the grand total amount
            $request['TAXAMT'] = $request['TAXAMT'] + $finalValue;
        } else {
            $request['AMT'] = $totalValue;
        }
    } else {
        $request['AMT'] = $totalValue;
    }
}

这是一个黑客,并以此对待它.我的同事目前正在测试它,但目前似乎还可以,按单价设置税收计算方法也很有帮助(我们的会计师对这种安排很满意,但这是针对英国的,我不确定是否其他国家会不赞成这种特定的税收计算方法).

This is a hack, and treat it as such. My colleague is currently testing it but seems to be OK for the moment, it is also helpful to set the tax calculation method by unit price (our accountants are happy with this arrangement, but this is for the UK, i'm not sure if other countries will frown upon that particular tax calculation method).

我操作 $request['AMT'] 的原因是因为有时 $finalValue 变量的计算会产生一个 -0.9999 重复整数,这对任何人都没有用,我的数学很糟糕,所以如果有人想改进对此,请这样做!

The reason I am manipulating the $request['AMT'] is because occasionally the calculation of the $finalValue variable would produce a -0.9999 repeating integer which is of no use to anyone, my maths sucks so if anyone wants to improve upon this, please do so!

一如既往,不要覆盖核心目录中的 nvp.php,创建单独的重写模块或在 app/local/mage 中执行此操作.首选第一个!:-)

As always don't overwrite the nvp.php in the core directory, create a seperate rewrite module or do this in app/local/mage. First option preferably! :-)

这篇关于Magento &amp;贝宝税务四舍五入问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆