-
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
-
Re: Tax + discount coupon BUG?
Hi,
Please change your settings to
include_shipping = FALSE
include_tax = FALSE
recalculate_tax = Standard
and try again.
-
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
-
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.
-
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
-
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
-
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
PHP Code:
if (DISPLAY_PRICE_WITH_TAX == 'true') {
with
PHP Code:
if (DISPLAY_PRICE_WITH_TAX == 'true' && $od_amount['type'] == 'P') {
Line 76
replace
PHP Code:
if ($this->calculate_tax == "Standard") $order->info['total'] -= $tax;
with
PHP Code:
if ($this->calculate_tax == "Standard" && $od_amount['type'] == 'P') $order->info['total'] -= $tax;
line 347
replace
PHP Code:
$ratio = $od_amount['total']/$order_total;
with
PHP Code:
$ratio = $od_amount['total']/($order_total+ ( (DISPLAY_PRICE_WITH_TAX == 'true') ? $orderTotalTax : 0 ));
remember to back files up before editing
-
2 Attachment(s)
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
-
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
-
2 Attachment(s)
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
-
Re: Tax + discount coupon BUG?
hi
yes my fault, I missed a line from the changes you need
line 350
PHP Code:
if ($od_amount['total'] > $order_total) $od_amount['total'] = $order_total;
just before this line add
PHP Code:
$order_total += $orderTotalTax;
hopefully that should solve the problem
-
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
-
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
-
2 Attachment(s)
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
-
Re: Tax + discount coupon BUG?
-
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
-
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.
-
2 Attachment(s)
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
-
3 Attachment(s)
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
-
1 Attachment(s)
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
-
Re: Tax + discount coupon BUG?
Hi,
I think that unfortunately the changes we made earlier have introduced thay bug.
To fix, you will need to replace the
function pre_confirmation_check in includes/modules/order_total/ot_coupon.php with
PHP Code:
function pre_confirmation_check($order_total) {
global $order;
$od_amount = $this->calculate_deductions($order_total);
if (DISPLAY_PRICE_WITH_TAX == 'true')
{
return $od_amount['total'];
} else {
return $od_amount['total'] + $od_amount['tax'];
}
}
-
Re: Tax + discount coupon BUG?
Hello wilt
Thank you once again! :clap: That did the trick. Now I only have one more question...
If I use a 100% discount coupon that sets the order total to 0, the payment method remains the same in the last (3rd) step as the selected one in the 2nd step.
If I use a discount coupon (fixed amount in $) that covers the whole order balance or more, the payment method is set to nothing in the 3rd step.
What I would like (and need) for this to work is some kind of "Zero balance payment method". Is there any way of doing this? My PSP don't accept 0 balance calls, and there are other possible issues with this problem too...
The best would be if zencart would skip the "selection of payment method step" (or hide it) if the order balance (after any discounts) equals to 0. Wouldn't it? :yes:
Thanks again
/Erik
-
Re: Tax + discount coupon BUG?
I have tried using the freecharger and the freshipping modules but they don't seem to help me...
/E
-
Re: Tax + discount coupon BUG?
to fix the 100% discount coupon problem you need to replace
function pre_confirmation_check in includes/modules/order_total/ot_coupon.php again with
PHP Code:
function pre_confirmation_check($order_total) {
global $order;
$od_amount = $this->calculate_deductions($order_total);
if (DISPLAY_PRICE_WITH_TAX == 'true' && $od_amount['type'] != 'P')
{
return $od_amount['total'];
} else {
return $od_amount['total'] + $od_amount['tax'];
}
}
-
Re: Tax + discount coupon BUG?
Hi
Now everything seems to work. I will move the bug fixes to my live site tonight and test everthing once again. Thank you for all the help.
Are there any other critical bug fixes I need? I thougt the "check for latest version" in the admin would handle this, but it seems to be used only for major upgrades. As you know I run on 1.3.8a.
/Erik
-
Re: Tax + discount coupon BUG?
Hi
there is another bug related to shipping tax and coupons but this may not affect you with using DISPLAY_PRICES_WITH_TAX.
I am however currently reworking some of the calculation logic, as currently the way code handles the difference between DISPLAY_PRICE_WITH_TAX = true/false is a little convoluted (as you can probably tell from the problems you encountered)
Hopefully I will have that done in a day or few.
-
1 Attachment(s)
Re: Tax + discount coupon BUG?
Hello Wilt
I came across another problem related to the ot_coupon module. Sometimes the discount sum is rounded wrong. I use 2 decimals for the currency (SEK). It seems like this bug only occurs when using multiple tax classes on the same order, but I΄m not sure about that...
/Erik
-
Re: Tax + discount coupon BUG?
Quote:
Originally Posted by
wilt
there is another bug related to shipping tax and coupons but this may not affect you with using DISPLAY_PRICES_WITH_TAX.
I am however currently reworking some of the calculation logic, as currently the way code handles the difference between DISPLAY_PRICE_WITH_TAX = true/false is a little convoluted (as you can probably tell from the problems you encountered)
Hopefully I will have that done in a day or few.
Hi Wilt,
Did you get anywhere with this reworking? I'm attempting to solve a discount code and sales tax problem different to the ones fixed in this thread. The problem only occurs when DISPLAY_PRICES_WITH_TAX. I'm finding the code related to DISPLAY_PRICES_WITH_TAX quite confusing.
Cheers
-
Re: Tax + discount coupon BUG?
Hey there, sorry to dig up an old bug but..
I am running a 1.3.9g shop (upgraded from 1.3.8a) and am seeing a similar problem to this.
It occurs when redeeming a discount coupon with a higher value than the order total.
e.g. fill up the cart with £47 worth of goods, and then redeem a £100 coupon, and instead of a discount value of £47.00 it takes off the shipping tax (£0.74 in my case), so you get:
Sub-Total: £47.00
Delivery Options (Standard Delivery: Free if Order Total above £100, £4.99 if under): £4.99
Discount Coupon: HRLM : -£46.26
VAT: £0.74
Total: £5.73
Is there a quick fix for this? Somewhere around line 403 in ot_coupon.php ?
Thanks!
-
Re: Tax + discount coupon BUG?
Hi!
I have the same problem as ErikAllan had (i think). The difference is that i am running 1.3.9f and the ot_coupon.php is not the same as it were when you guys fixed it. I tried to implement the changes but nothing seems to happen.
I have the following setup:
Include Shipping
false
Include Tax
false
Re-calculate Tax
Standard
The problem i'm having is: the discount is wrongly calculated when there is VAT on the shipping.
Heres an example of an order with VAT on shipping and an 10% coupon:
Totalt:NOK 125.00
Coupon: -NOK 11.23
Shipping :NOK 63.75
25% VAT: NOK 35.25
Order Total: NOK 177.52
The Coupon SHOULD be -NOK 12,50
Here is the exact same order, but this time I have turned off VAT on shipping. Now everything is as it should be.
Totalt:NOK 125.00
Coupon: :-NOK12.50
Shipping :NOK51.00
25% VAT:NOK22.50
Order Total:NOK163.50
Anyone got an idea of how to fix this?
-
Re: Tax + discount coupon BUG?
How is the situation for these bugs in the latest version? Also having a shop in Scandinavia and trying to avoid issues with it. Currently it is discounting 10 euro discount without VAT from the order that is not really correct. I changed the settings to include the tax. Lets what happens. Just do not like to test things with a live shop...
-
Re: Tax + discount coupon BUG?
Should be good in v1.5.0. Best way to find out is to install a copy of it in a test folder+database and check it out using your own data. That's also why it's released as a BETA presently ... we're asking *you* to test it and point out any bugs.
Everyone who has subscribed to the News & Announcements section of the forum has already read about it here: http://www.zen-cart.com/forum/showthread.php?t=183626
-
Re: Tax + discount coupon BUG?
Quote:
Originally Posted by
DrByte
Should be good in v1.5.0. Best way to find out is to install a copy of it in a test folder+database and check it out using your own data. That's also why it's released as a BETA presently ... we're asking *you* to test it and point out any bugs.
Everyone who has subscribed to the News & Announcements section of the forum has already read about it here:
http://www.zen-cart.com/forum/showthread.php?t=183626
I still cant get this working correctly in 1.51.
I add the discount coupon to remove the discount, but then the vat doesn't get added on to the order at all
Please can somebody help?
Thanks
-
1 Attachment(s)
Re: Tax + discount coupon BUG?
I have a similar issue on 1.5.5.e
Only not working on Fix amount coupon, with VAT 20%
* I have the following invoice with a 833,33 Excl.Tax coupon, or 1000 Incl.Tax
Product ......2908.33 .....+20% VAT ( 581.67 ) Tax ........ 3,490,00
Coupon .......-833.33.... +16.66% (138.88) Tax ............. - 972.22
Total VAT .......442.78....... total price inc.vat ..... 2,517.78
I figured out that my coupon was at 16.66% VAT ??
I have only one tax rate, 20%
What I'm getting is this
Sub-Total:.............................3,490.00
Store Pickup (Walk In):..................0.00
Discount Coupon: abcdef :.........-972.22
VAT 20% or similar:....................442.78
Total:...................................2,517.78
What I need is this
Sub-Total:...........................3,490.00
Store Pickup (Walk In):................0.00
Discount Coupon: abcdef :... -1000.00
VAT 20% or similar: ............... .415.00
Total:................................. 2,490.00
for some reasons, its working fine with % coupon , here 28.6532951%
Sub-Total:............................3,490.00
Store Pickup (Walk In):.................0.00
Discount Coupon: 987654321 :-1,000.00
VAT 20% or similar:...................415.00
Total....................................2,490.00
this is my coupon setup
Discount Coupon
This module is installed ...............true
Sort Order.................................280
Include Shipping.........................true
Include Tax...............................false
Re-calculate Tax..................Standard
Tax Class.....................Taxable Goods