Sales Tax Mismatch between Magento Checkout and PayPal – 1 Cent ($.01) Difference
on April 26, 2011
There is a one cent disparity between the sales tax that is displayed for order total in Magento and PayPal. Customers are invoiced for the correct amount of sales tax in Magento, but then if they choose PayPal as a payment method, then the sales tax displayed after the redirect to PayPal is $0.01 less.
Magento has had it’s fair share of troubles with rounding issues, not just for sales tax, but for shipping, handling fees, VAT and order totals as well. The solution to this specific issue with PayPal took awhile to figure out simply because searching for keywords, such as “Magento PayPal sales tax rounding error” yield a ton of results. There are many posts in the Magento forums deal with rounding issues that had to be sorted through as well. Unfortunately, none of these posts addresses the rounding error that leads to PayPal displaying a sales tax amount that is 1 cent less than what is shown in Magento. There are a lot of posts dealing with how Magento aggregates items / orders before applying tax and how tax is applied to shipping and handling fees, but none about the missing cent in PayPal.
The Cause
The cause of the .01 difference is due to different rounding in Magento versus PayPal. Magento 1.3.x aggregates orders before applying sales tax; however, sometimes PayPal applies sales tax to individual products and then sums up all of those totals to get the tax amount. The problem here is that PayPal rounds the sales tax totals for the individual products before adding them all together, which can result in a lower tax being reported.
For instance, say there are two products worth 55.444 each and the tax rate is 10%. If the total cost of the two products are aggregated first (as they are in Magento), the total becomes 110.888 and so tax is 11.0888, which rounds to 11.09. If tax is applied to the products before they are aggregated you get 5.5444, which rounds to 5.54 for each product. Multiply this total by 2 (for each product) and you get a final tax of 11.08.
The Fix
After sorting through all the chaff, the fix for this issue is surprisingly simple:
- Log into the Magento Admin Panel.
- Go to System > Configuration > Payment Methods.
- Scroll down to the PayPal Website Payments Standard section.
- In the “Transaction Type” drop down box, select “Aggregate Order” (instead of “Indivividual Item”).
- And you’re done. Sales Tax for orders should now match up between Magento and Paypal.
1. OK
2. There’s no PayPal in this section, PayPal have his own Link to his setting (Magento 1.4.1.1)
3. In his own link, we can find the “PayPal Website Payments Standard section” – OK
4. Ther’s no “Transaction Type” drop down setting (Magento 1.4.1.1)
5. Can’t applie this fix in this environement.
Another fix for us ?
I will try something, and tell here if i find another fix…
Best regards.
This fix works fine in Magento 1.3.2.4. Have you been able to solve the problem in 1.4.1.1?
Hi,
The problem is not solved at this time.
I have to check the code of PayPal module.
The problem is the same with the PayBox module and for this one the problem was solved.
Will right back to say if i find somthing.
Take care.
The fix for Magento 1.4.1.1 is different but simple too :
1 – Log into the Magento Admin Panel.
2 – Click on the “PayPal” link in “SALES” (“Ventes”) section on left side.
3 – In “Transfert Cart Line Items” (“Transférer les articles dans votre panier”) drop down box select “No”.
4 – Choose an appropriate wording for the “Summary Text for Aggregated Cart” (“Texte récapitulatif sur les panier validés”) like “MY SHOP – My cart” it resume all the items in cart in one word on Paypal terminal.
It works !
Hi Lirim, thanks for posting the fix for Magento 1.4.1.1. Glad you got things too work.
I can’t seem to find this in Version 1.7.0.2., can someone help??
Steps to follow:
1. Move /app/code/core/Mage/Tax/Model/Calculation.php to /app/code/local/Mage/Tax/Model/Calculation.php
2. Edit Calculation.php file and find calcTaxAmount function in it (Around line no: 466)
3. Find following code in that same function
if ($priceIncludeTax) {
$amount = $price*(1-1/(1+$taxRate));
} else {
$amount = $price*$taxRate;
}
4. Just after it, add following line of code
$amount = $this->truncate($amount, 2);
5. And test implementation at front-end.
This is tested and working for magento 1.7.0.2.
Thanks for the update, much appreciated.
Thank’s for suggestion regarding Mage 1.7.0.2, but it seems like it brakes down the prices in forntend, though it solves the paypal 1 cent issue.
You’re welcome. What exactly do you mean by saying it breaks the prices?
Well, in the store (when browsing products, as visitor/client) some products are, say 11.91 instead of 11.90 (as set in admin).
An exact example is the following: There is a product which price is 18.90 as set in admin (tax 20%). It appears in frontend as costing 18.91.
Is this happening with all products or just some?
Just some of them.
I mentioned that particular case with 18.90 (20 tax included) so you might reproduce the problem..
We’re unable to reproduce the issue. What happens when a new product is added? Could any custom code be interfering?
I have edited some core files in order to fix another 1 cent problem (within orders/invoices), but that shouldn’t be a problem (I just set 4 decimals on rounding prices)
That was needed because at some point, Magento is doing some math in views and while in db it has only 2 decimals, when recalculated, some totals were losing 1 cent.
Sounds like that might be related. We’d recommend undoing the core edits to see if that fixes it.
Yes, that is what I intend to do right now. I will come back with updates. Thank you for the promptitude of the replies!
You’re welcome. Let us know how it goes.
Unfortunately, undoing the modifications I talked about didn’t solve the problem. Funny though, truncating with a precision of 3 solved somehow the problem (didn’t find products in frontend with bad affected prices) and the only paypal order (until now in this store) having that 1 cent issue, when recreating it and tested payment with paypal sandbox, had correct sums. But, of course, I can not trust this approach (truncate with 3) while I don’t have more test cases to confirm (and no other community confirmations), so I am not confident to go live with this. I will still look around for posible interferences, and of course, I will come back here if there are any updates. Thank’s again for great and prompt feedbacks!
Can you please tell me what do you have in app\code\core\Mage\Core\Model\Store.php as second parameter for rount() function called within roundPrice method (line ~ 944) ?
So, what did finally work for me:
System->Configuration->Sals->Tax->Callculation Settings->Tax Calculation Method Based On set to “Row Total”. Remove round by 4 digits, set back to 2 in app\code\core\Mage\Core\Model\Store.php that I was asking about above (this modiffication was done in order to solve another 1 cent problem – related to invoices/orders, but this setting solved all).
Hi Michael, glad to hear you solved the issue. Thanks for posting it for others! It sounds like rounding to two different decimal lengths may have been the root cause.
I am using magento with VAT/GST and some items were showing with an extra cent added for some reason.
app\code\core\Mage\Core\Model\Store.php
return round($price, 2);
It was already set to 2 as standard for me. I just changed it to 4, and with no other changes, the 1 cent addition problem is now fixed.
This is the reverse of what Michael found for his fix.
thanks michael for the solution.