Zen Cart Logo
Forums / Currencies & Sales Taxes, VAT, GST, etc. / Tax + discount coupon BUG?

Tax + discount coupon BUG?

Views: 20,150

Results 1 to 20 of 34
08 Apr 2009, 16:57
#1
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Tax + discount coupon BUG?

Hello!

PROBLEM:

  • Tax calculates wrong when using a discount coupon (fixed amount, including tax) in the checkout.

SETTINGS:

  • Zencart version 1.3.8a, fresh install with sample products, no mods installed
  • My Store -> 'Display Prices with Tax' = true
  • My Store -> 'Zone' = Florida
  • Discount coupon fixed amount of $10.00, including tax
  • 'ot_coupon' settings are: 'Include shipping' = false, 'Include tax' = true, 'recalculate tax' = none

CHECKOUT BUG: (I have added one product that costs $100.00 including tax) to make the calculation simple)

Sub-Total: $100.00
Store Pickup (Walk In): $0.00
Discount Coupon: 10 : -$10.65 (should be $10.00)
FL TAX 7.0%: $5.89
Total: $90.00

Where is the amount -$10.65 coming from? I have tried different combinations in the ot_coupons module, but with no luck. How is this supposed to work? Is there any documentation about how tax is calculated using different combinations of discounts etc?

:censored:

Best Regards

Erik

08 Apr 2009, 17:21
#2
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,828
Plugin Contributions:
3

Re: Tax + discount coupon BUG?

Hi,

Please change your settings to

include_shipping = FALSE
include_tax = FALSE
recalculate_tax = Standard

and try again.

08 Apr 2009, 17:40
#3
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Re: Tax + discount coupon BUG?

Hi wilt!

I tried your suggestion but ended up with this:

Sub-Total: $100.00
Store Pickup (Walk In): $0.00
Discount Coupon: 10 : -$10.7 (should be $10.00)
FL TAX 7.0%: $5.84 (should be $5.89)
Total: $89.30 (should be $90.00)

:no:

Thank you for a fast reply anyway

/Erik

08 Apr 2009, 17:54
#4
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,828
Plugin Contributions:
3

Re: Tax + discount coupon BUG?

k,

The settings I gave work correctly for me on a clean v138 install.

Do you have DISPLAY_PRICE_WITH_TAX = true set in the admin. If so this would cause the discount coupon value to be inflated by the tax rate.

It is also highly unusual for a US based store to have this setting set to true.

08 Apr 2009, 18:02
#5
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,828
Plugin Contributions:
3

Re: Tax + discount coupon BUG?

Further Note.

If you do have display_price_with_tax = true then there is a bug in 138 regarding the tax calculations for coupons.

I will dig out the relevant threads where I posted a fix for the behaviour

08 Apr 2009, 18:43
#6
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Re: Tax + discount coupon BUG?

Hi again

As I wrote in the original message, the DISPLAY_PRICE_WITH_TAX is set to true.

My live shop is swedish and we only sell to people in Sweden. The reason I showed a 'Florida' example with a clean install is that it simplifies for you to troubleshoot.

In Sweden, almost all 'consumer' shops show prices including tax, and the discount coupons should therefore also include tax.

Thank you for searching the threads...

/Erik

09 Apr 2009, 03:37
#7
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,828
Plugin Contributions:
3

Re: Tax + discount coupon BUG?

Hi

To fix the problem you will need to edit

includes/modules/order_totals/ot_coupon.php

line 73

replace

if (DISPLAY_PRICE_WITH_TAX == 'true') {

with

if (DISPLAY_PRICE_WITH_TAX == 'true' && $od_amount['type'] == 'P') {

Line 76

replace

if ($this->calculate_tax == "Standard") $order->info['total'] -= $tax;

with

if ($this->calculate_tax == "Standard"  && $od_amount['type'] == 'P') $order->info['total'] -= $tax;

line 347

replace

$ratio = $od_amount['total']/$order_total;

with

$ratio = $od_amount['total']/($order_total+ ( (DISPLAY_PRICE_WITH_TAX == 'true') ? $orderTotalTax : 0 ));

remember to back files up before editing

09 Apr 2009, 07:04
#8
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Re: Tax + discount coupon BUG?

Hi

Your code fix solves the problem when using a discount coupon with a value less than the total excluding tax. See attachments. The one using a $100 coupon is false...

ot_coupon settings are:

include_shipping = FALSE
include_tax = FALSE
recalculate_tax = None

(I have tried different combinations but with no luck)

Again, thank you for trying to help me out!

/Erik

09 Apr 2009, 12:58
#9
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,828
Plugin Contributions:
3

Re: Tax + discount coupon BUG?

Hi,

I get correct figures with

include_shipping = FALSE
include_tax = FALSE
recalculate_tax = Standard
display_price_with_tax = true

Sub=Total = 100.00
shipping = 0.00
discount Coupon = -100.00
Tax = 0.00
Total = 0.00

09 Apr 2009, 13:27
#10
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Re: Tax + discount coupon BUG?

Ok, strange. I get wrong values with the same settings as you. I have attached some screendumps to let you see how everything is set up.

Is there a setting I have missed? :frusty:

/Erik

09 Apr 2009, 13:58
#11
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,828
Plugin Contributions:
3

Re: Tax + discount coupon BUG?

hi

yes my fault, I missed a line from the changes you need

line 350

          if ($od_amount['total'] > $order_total) $od_amount['total'] = $order_total;

just before this line add

          $order_total += $orderTotalTax;

hopefully that should solve the problem

09 Apr 2009, 14:13
#12
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Re: Tax + discount coupon BUG?

No, the error remains. The code change does not change anything. I rechecked all the changes in ot_coupon.php and I think I´ve done it right...

/Erik

09 Apr 2009, 14:21
#13
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Re: Tax + discount coupon BUG?

Sorry!

Now it seems to work! I put the line below instead of obove... :oops:

Thank you very much for helping me. Now I just have to check a few other combinations... but this is a giant step forward.

/Erik

10 Apr 2009, 00:30
#14
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Re: Tax + discount coupon BUG?

Hello again...

Now I get wrong amounts when using a COD fee + a discount coupon. When the discount amount is the same (or near) as the subtotal of the products, the cod fee suddenly disappears without reason. See attachements.

/Erik

10 Apr 2009, 06:15
#16
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Re: Tax + discount coupon BUG?

Hi wilt

The code change does not fix my problem. Did I do right if I changed the function in /includes/classes/order_total.php?

But it seems to be a similar problem...

/Erik

10 Apr 2009, 15:53
#17
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,828
Plugin Contributions:
3

Re: Tax + discount coupon BUG?

hi,

I realised what the real problem is, and its not related to the bug I mentioned. Although putting that bugfix in is still OK.

The problem is that if a Coupon is used to pay the whole order, then the payment method is set to 'GV/Coupon'

So because the payment method is no longer set to COD, no COD fee will be charged.

There may be ways to work around this, if you really want to charge COD on orders where the balance is 0.

12 Apr 2009, 14:37
#18
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Re: Tax + discount coupon BUG?

Hi again

I could live with no COD fee for orders where the balance is 0. But the strange thing is that the balance does not have to be 0 for this to happen. If I use a discount coupon set to $99 (when having a balance of $100), the cod fee disappears too. See attachments. When applying a 99% discount, everything is fine.

I don´t know the exact limit when the cod fee disappears, but I think it differs if I change the tax to something else than 7%...

/Erik

12 Apr 2009, 14:56
#19
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Re: Tax + discount coupon BUG?

Hi,

Came across another problem (bug) when applying a flat shipping fee of $10 ($10.7 including tax). The tax is not specified in checkout when the order balance is 0 after applying a discount coupon. Do you know how to fix it? See attachments.

My ot_coupons settings are still: include_shipping = FALSE, include_tax = FALSE, recalculate_tax = Standard

/Erik

13 Apr 2009, 19:08
#20
erikallan avatar

erikallan

New Zenner

Join Date:
Dec 2008
Location:
Stockholm
Posts:
29
Plugin Contributions:
0

Re: Tax + discount coupon BUG?

Hello again

I think the "low balance when using a discount coupon problem" mentioned earlier is a really nasty bug. The big problem is that the payment method is dropped. The customers are allowed to the following:

  1. Put a $1000 product into the cart.
  2. Go to checkout.
  3. Select a shipping method (ex. flat rate).
  4. Use a coupon worth $940 and select payment method (ex. credit card).
  5. Confirm the order without beeing redirected to the 3rd party credit card payment site...

See attached file.

Am I doing something wrong? Many people must have the same basic setup and experience similar problems!?

Should I post this as a separate thread?

Best Regards

/Erik