Tax calculation errors!

Tax calculation errors!

Postby atrus80 » Mon Feb 06, 2012 6:22 pm

Hi Stan,

We face a problem with the calculation of the tax in the latest OPC versions:

More specifically, we get for example (Using 10% discount coupon and 'Subtract payment discount before tax,shipping'=YES and 'Shopper group see prices including tax'=NO) :

Subtotal€148.00
Coupon Discount-€14.80
Shipping and Handling Fee€30.75
Tax Total€26.81
Total:€190.76

Above calculation is wrong! The correct should be:

Subtotal€148.00
Coupon Discount-€14.80
Shipping and Handling Fee€30.75
Tax Total€24.59
Total:€188.54

The mistake here is that OPC calculates the tax on the UNDISCOUNTED subtotal (i.e. on the €148) which is wrong! The tax should be calculated on the DISCOUNTED subtotal, i.e. on the €133.2 (=€148-€14.8)

This was working in the previous versions; we'd appreciate your fix as soon as possible as we get compaints from our customers, thanks!

Regards,
Chris
atrus80
 
Posts: 85
Joined: Mon Feb 06, 2012 6:22 pm

Re: Tax calculation errors!

Postby admin » Wed Feb 08, 2012 5:17 pm

Hello Chris,
right after i release the next version which will fully support a swedish payment method (fortus finance) i will help you to get the results the same as i have them on my demo site - i can't replicate this any more.

Best Regards,
Stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Tax calculation errors!

Postby atrus80 » Fri Feb 10, 2012 1:44 pm

Hello Stan,

Thank you for the new version! This version corrects the problem with the tax (with the store's default currency only), this is great. The following bugs still exist:

1) Rounding Errors (these are ok with the modified ps_checkout but you told me to replace it with the old one). For example, with the modified ps_checkout the result is like

Subtotal €39.00
Coupon Discount -€3.90
Shipping and Handling Fee €37.59
Tax Total €10.90
Total: €83.59

Above is CORRECT!

But with the old ps_checkout is like:

Subtotal €39.00
Coupon Discount -€3.90
Shipping and Handling Fee €37.59
Tax Total €10.91 Wrong!
Total: €83.60 Wrong!

So, please include the modified ps_checkout in your future versions!

2) With different currencies we still have some errors, for example in USD (Rate 1.2942) the above order is like:

Subtotal $50.47
Coupon Discount -$5.05
Shipping and Handling Fee $48.65
Tax Total $16.25 Wrong! Should be $14.11 (Maybe VM multiplies with the tax rate twice?!!)
Total: $110.32 Wrong! Should be $108.18

3) In the order confirmation email above order is as follows:

SubTotal : €39.00
Coupon Discount: - €3.90
Shipping and Handling Fee : €37.59
Tax Total : €5.27 Wrong! Should be €10.90. The shipping tax is not added!
Total: €83.60

This is a Virtuemart error, but you need to correct it in ps_onepage.php:
Comment this line -> // $order_tax = $db->f("order_tax");
Add this line -> $order_tax = $db->f("order_tax") + $db->f("order_shipping_tax");


Looking forward to your comments and fixes!

Regards,
Chris
atrus80
 
Posts: 85
Joined: Mon Feb 06, 2012 6:22 pm

Re: Tax calculation errors!

Postby admin » Tue Feb 14, 2012 9:07 pm

We decided to fix this issues by changing a "buggy" virtuemart file. The original file has huge problems with tax calculation and rounding which is almost never working in EU countries.

The file in the attachment solves many of the tax and rounding issues which occur when your tax rate is not simply divisible (0.19 for example). It uses the lastest code of VM 1.1.9 and can be used for
- EU tax mode with shopper group sees taxes or not
- tax based on vendor address when the shopper group sees prices inc. taxes
- tax based on shipping address when the shopper group does not see prices inc. taxes (US and Canada)
- payment discount (and normal discount) BEFORE tax and shipping
- this file does not use SHIPPING TAX but rather adds it to the GLOBAL TAX

It is NOT well tested in these modes and will most probably not count correctly
- when multiple tax modes enabled
- payment disoucnt (and normal discount) AFTER tax and shipping (not fully tested)

This file will be a base for OPC for VM 1.1.x to count taxes.

If you find this helpfull, but notice a bug, please let us know.
Best Regards,
Stan
Attachments
ps_checkout.zip
ps_checkout.php of VM 1.1.9 with fixed taxes and rounding. Unzip to /administrator/components/com_virtuemart/classes/ps_checkout.php
(22.35 KiB) Downloaded 780 times
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Tax calculation errors!

Postby atrus80 » Fri Feb 17, 2012 3:05 pm

Great work Stan, thanks.

Just remember to uncomment the following lines in ps_checkout:

//$d['shipping_tax'] = $GLOBALS['CURRENCY']->convert( $d['shipping_tax'] );
//$d['shipping_total'] = $GLOBALS['CURRENCY']->convert( $d['shipping_total'] );

These are causing troubles with shipping tax in different currencies than the store's default one.

Rgrds,
Chris
atrus80
 
Posts: 85
Joined: Mon Feb 06, 2012 6:22 pm

Re: Tax calculation errors!

Postby admin » Thu Feb 23, 2012 2:10 pm

Hello Chris,
in verstion 311 we included a new ps_checkout.php which can be installed from the emails tab when the extended classes are enabled. This file handles rounding, and tax calculation much better than the original VM file.

If you had a chance to try it, let us know of any bugs.

Best Regards,
Stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm


Return to One Page Checkout for Virtuemart 1.1.x

cron