Zen Cart Logo
Forums / Bug Reports / tax calculation problem with coupons and multiple products

tax calculation problem with coupons and multiple products

Locked

Views: 16,028

Results 41 to 54 of 54
This thread is locked. New replies are disabled.
3 Apr 2007, 11:48 PM
#41
mikeyg avatar

mikeyg

Totally Zenned

Join Date:
May 2005
Posts:
515
Plugin Contributions:
0

tax calculation problem with coupons and multiple products

Hi,

Has this issue been resolved.

I have been looking at this all night with the various options ticked in all the combinations available and I still don't understand how it is working it out and what is right or wrong.

So far I have

£130.97 Sub-Total:
-£6.63 Discount Coupon: 5%
£18.36 Includes VAT @ 17.5%:
£123.27 Total:

I think it should be
sub total 130.97
Discount -£6.55
tax £18.55
total 124.42

How can this be so different for every combination of options and not get one right?

Help any one please.

4 Apr 2007, 12:34 AM
#42
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: tax calculation problem with coupons and multiple products

No, its not been resolved I don't think. I think the key is... for most of us it rarely comes up :) So nobody's giving it a priority. I hope it gets fixed sooner or later (pref sooner).

-= Steven

4 Apr 2007, 8:02 AM
#43
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: tax calculation problem with coupons and multiple products

At least one user (infocom, also from the UK, so I think they use the same tax settings) has reported in another thread the fixes posted by Steven (in additon to Jeff's?) seem to work for them.

So you could give that a shot, and let us know if it works for you too (not that that would mean it's resolved, but it might be interesting and usefull to know).

4 Apr 2007, 11:59 AM
#44
mikeyg avatar

mikeyg

Totally Zenned

Join Date:
May 2005
Posts:
515
Plugin Contributions:
0

Re: tax calculation problem with coupons and multiple products

Paulm and S_mack

I think I have been through that other thread and cetainly followed your own thoughts but It just seemed to get the numbers closer but not right. I either get the tax showing correctly but not the total. The discount showing correctly but not the tax or tax showing on the discount coupon and incorrect in the tax field and the total right or of course option four everything wrong.

Tick which one you would like to use and which is not going to annoy/confuse the customer.

I tried the links to the down loads in that thread but I think paulm link was not longer showing the file and the JeffD link the file was corrupt when opening with winzip. ( I tried both a couple of times)

Is this as case of back to the drawing board with the logic to rework the maths?

I am not a programmer so I hope this can be sorted soon.

MG

5 Apr 2007, 9:57 AM
#45
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: tax calculation problem with coupons and multiple products

Hi Mikey,

I removed mine because it was a testversion only, typical for my situation, and it would surely not work for all.

But since Jeff's file indeed seems corrupted I will attach my file again.

Notes:

  • it does not listen (correctly) to some of the settings
  • there are no plans to improve or support it
  • it might work for some including tax stores that happen to be configured the same as mine.
5 Apr 2007, 10:09 AM
#46
mikeyg avatar

mikeyg

Totally Zenned

Join Date:
May 2005
Posts:
515
Plugin Contributions:
0

Re: tax calculation problem with coupons and multiple products

Paulm Thank you for that I look forward to testing over Easter break.

Hopefully it will just help me understand how to tweak the file if necessary to work for my own situation.

Best regards

MG

7 Apr 2007, 1:45 AM
#47
redmonds avatar

redmonds

Zen Follower

Join Date:
Jan 2006
Posts:
108
Plugin Contributions:
1

Re: tax calculation problem with coupons and multiple products

I am experiencing the same problems and have been following closely. I know next to nothing about coding so am looking for someone else to solve the problem.

I have installed the new ot_coupon by paulm and played with all of the settings and have go to a usable state although still not correct.

The state I have reached is
Coupon value incorrect (shown + 10% GST) ie put in $20 shows as $22.
Sub total correct
GST correct based on using the incorrect coupon value as above
Total Correct based on incorrect coupon value

SO all I have to do is enter my coupon values as ex tax value. I have not yet investigated if there are any other issues with this.

My store configuration as such:
Australia
Display tax = true
Basis of Product Tax = Shipping
Basis of shipping tax = Shipping (this should be store. I always pay tax on shipping no matter where it is going but this breaks the calculations)
Tax = 10% GST
ot_coupon settings are
sort order = 280
include shipping = false
include tax = false
re-calculate tax = standard
tax class = none

Transaction example coupon value = $20.00
Sub-Total: $174.90
Postage(incl $1 handling, $1 insurance) $9.57
Discount Coupon: test : -$22.00
GST: $14.77
Total: $162.47

I think the most important thing is that the total is correct and that the GST is correct as a portion of the total otherwise I would be in breach of the Tax Laws. That is what is happening above. I can deal with having to compensate the coupon value down -10%.

However I suspect that if I am shipping O/S which I don't have to charge GST on the the calculations will then be out. But I have not got this working yet so am not sure.

I know that the ZC team is working on bigger and better projects but for us the ability to confidently use coupons especially with the Abandon Cards mod would be invaluable.

Thanks

Raoul

10 Apr 2007, 7:53 PM
#48
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: tax calculation problem with coupons and multiple products

My "solution" to the above is:

In "admin|Modules|Order Total" I have set "Include tax" to "false". I know this is the wrong setting (in my case), but it gives the right results f.t.b. (so the file I posted is buggy, as expected ;-) ).

13 Apr 2007, 9:41 AM
#49
agamic avatar

agamic

New Zenner

Join Date:
Apr 2007
Posts:
24
Plugin Contributions:
0

Re: tax calculation problem with coupons and multiple products

s_mack:

Ahh.. oops. Ignore the above...
in addition to the above... find ```
case 'Standard':
$ratio = $od_amount['total']/$this->get_order_total();
$products = $_SESSION['cart']->get_products();
for ($j=0; $j<sizeof($products); $j++) {
$t_prid = zen_get_prid($products[$j]['id']);
$cc_result = $db->Execute("select products_tax_class_id
from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");

                    if ($is_valid_results) {
                      $tax_rate = zen_get_tax_rate($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                      $tax_desc = zen_get_tax_description($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                      if ($tax_rate > 0) {

// $od_amount[$tax_desc] += (($products[$j]['final_price'] * $products[$j]['quantity']) * $tax_rate)/100 * $ratio;
$od_amount[$tax_desc] += round(((($products[$j]['final_price'] * $products[$j]['quantity']) * $tax_rate) + .5)/100 * $ratio, 2);
$od_amount['tax'] += $od_amount[$tax_desc];
}
}
}
break;
and replace with
case 'Standard':
$ratio = $od_amount['total']/$this->get_order_total();
$t_prid = zen_get_prid($products[$i]['id']);
$cc_result = $db->Execute("select products_tax_class_id from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");
$tax_rate = zen_get_tax_rate($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
$tax_desc = zen_get_tax_description($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
if ($tax_rate > 0) {
$od_amount[$tax_desc] += round(((($products[$i]['final_price'] * $products[$i]['quantity']) * $tax_rate) + .5)/100 * $ratio, 2); // JTD:08/30/05 - Tax Calc bug fix
$od_amount['tax'] += $od_amount[$tax_desc];
}
break;

> 
>  - Steven
Thanks to S_Mack and everyone who worked on this. It has also solved my coupon/multi item checkout tax problem. It also calculates the %discount correctly where as before it was out. (Based in the UK)
13 Apr 2007, 9:48 AM
#50
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: tax calculation problem with coupons and multiple products

There's a discussion of another problem that affects carts that show prices including taxes and use group discounts (and a fix) over at

http://www.zen-cart.com/forum/showthread.php?p=358182

It might be of interest to those following this thread.

Scott

15 Apr 2007, 4:29 PM
#51
dasonix avatar

dasonix

New Zenner

Join Date:
Sep 2006
Posts:
79
Plugin Contributions:
0

Re: tax calculation problem with coupons and multiple products

which file is S_macks fix for?

I seem to have lost track in the thread

20 Dec 2008, 2:23 AM
#52
mygreygoose avatar

mygreygoose

New Zenner

Join Date:
Jun 2007
Posts:
91
Plugin Contributions:
0

Re: tax calculation problem with coupons and multiple products

This thread is 1.5 years old, but I had this problem tonight, so I'll recap the fix for anyone else just arriving at this issue.

I'm using 1.3.7. The tax was not calculating correctly when I used a discount promo code coupon AND had 2 or more products. Apparently, a lot of people had the same problem. I'll post the code below that I grabbed from earlier in this thread, with a couple of clarifying notes.

NOTE: I've only bug-tested this fix for 10 minutes, and so far so good, but I'm not 100% sure of any other side effects this may cause. And it fixes the problem for me as stated above, but according to previous posts in this thread it may not cure all situations, e.g., if you are using group pricing (although I tried it w/ my group pricing and so far so good).

The file in question is: includes/modules/order_total/ot_coupon.php

There are 2 sections of identical code that needs to be replaced (one for Fixed coupons and one for Percentage coupons). So, replace the 2 instances of:

                    case 'Standard':
                      $ratio = $od_amount['total']/$this->get_order_total();
                      $products = $_SESSION['cart']->get_products();
                      for ($j=0; $j<sizeof($products); $j++) {
                        $t_prid = zen_get_prid($products[$j]['id']);
                        $cc_result = $db->Execute("select products_tax_class_id
                                                   from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");

                        if ($is_valid_results) {
                          $tax_rate = zen_get_tax_rate($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                          $tax_desc = zen_get_tax_description($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                          if ($tax_rate > 0) {
//                            $od_amount[$tax_desc] += (($products[$j]['final_price'] * $products[$j]['quantity']) * $tax_rate)/100 * $ratio;
                            $od_amount[$tax_desc] += round(((($products[$j]['final_price'] * $products[$j]['quantity']) * $tax_rate) + .5)/100 * $ratio, 2);
                            $od_amount['tax'] += $od_amount[$tax_desc];
                          }
                        }
                      }
                    break;
```with:

```php
                    case 'Standard':
                      $ratio = $od_amount['total']/$this->get_order_total();
                      $t_prid = zen_get_prid($products[$i]['id']);
                      $cc_result = $db->Execute("select products_tax_class_id from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");
                      $tax_rate = zen_get_tax_rate($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                      $tax_desc = zen_get_tax_description($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                      if ($tax_rate > 0) {
                        $od_amount[$tax_desc] += round(((($products[$i]['final_price'] * $products[$i]['quantity']) * $tax_rate) + .5)/100 * $ratio, 2); // JTD:08/30/05 - Tax Calc bug fix
                        $od_amount['tax'] += $od_amount[$tax_desc];
                      }
                    break;
6 Jan 2009, 6:18 AM
#53
ewodzien avatar

ewodzien

New Zenner

Join Date:
Sep 2007
Posts:
8
Plugin Contributions:
0

Re: tax calculation problem with coupons and multiple products

Thanks for this consise post with fix... You saved me tons of time slogging through the original post! This community rocks.

T H A N K Y O U!!!!

7 Mar 2009, 8:48 AM
#54
robax avatar

robax

Zen Follower

Join Date:
Mar 2006
Posts:
187
Plugin Contributions:
0

Re: tax calculation problem with coupons and multiple products

Thanks everyone for sorting this issue out and for the summary above :clap: