This is a discussion on Can't get discounts+taxes to calculate ok - Desperate within the osCMax v2 Installation issues forums, part of the osCMax v2.0 Forums category; I have been trying to configure discount coupons for 2 days, and I have been unable to make them work ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| ||||
| ||||
| I have been trying to configure discount coupons for 2 days, and I have been unable to make them work ok with the taxes. The total I get is not right, and I do not even seem to know where the numbers I get are coming from. I have two tax zones, 0% and 16%. With 0% tax zone the totals are right, with 16% tax zone they are not. I have "display prices with tax" true and working ok everywhere, a same item will be seen with a price of 34.48E for a 0% customer, and 40.00E for a 16% customer. I have created a discount coupon for "free shipping" and another one for 12E discount, none of them seem to work. (Note, shipping prices are "different" for the 2 types of customer so the s&h total is the same, for 16% tax zone it is 10.34+16%=12 , for 0% tax zone it is 12.00+0%=12) 0% customer with "free shipping" coupon - OK: --- Subtotal: 34.48EUR Envio Urgente (Postal Express): 12.00EUR Vales Descuento:222f6e: -12.00EUR IVA: 0.00EUR Total: 34.48EUR --- 0% customer with "12E discount" coupon - OK: --- Subtotal: 34.48EUR Envio Urgente (Postal Express): 12.00EUR Vales Descuento:de2699: -12.00EUR IVA: 0.00EUR Total: 34.48EUR --- 16% customer with "free shipping" coupon - WRONG: --- Subtotal: 40.00EUR Mensajeria (Empresa de mensajeria (CBL, MRW, UPS)): 12.00EUR Vales Descuento:222f6e: -12.00EUR IVA: 5.02EUR Total: 37.85EUR --- Total should be 40.00EUR, and IVA should be 5.52EUR. 16% customer with "12E discount" coupon - WRONG: --- Subtotal: 40.00EUR Mensajeria (Empresa de mensajeria (CBL, MRW, UPS)): 12.00EUR Vales Descuento:de2699: -12.00EUR IVA: 5.02EUR Total: 37.85EUR --- Same as above. I do not even understand where the 5.02E and 37.85E come from. If the total is 37.85E, the correct taxes should be 5.22E. If the taxes are 5.02E, since we are buying one item that costs 34.48E+taxes the total should be 39.50E. The correct ammounts would be: --- Subtotal: 40.00EUR Mensajeria (Empresa de mensajeria (CBL, MRW, UPS)): 12.00EUR Vales Descuento:de2699: -12.00EUR IVA: 5.52EUR Total: 40.00EUR --- If I change the order of taxes and discounts on admin/modules/order total, what I get is: --- Subtotal: 40.00EUR Mensajeria (Empresa de mensajeria (CBL, MRW, UPS)): 12.00EUR IVA: 7.18EUR Vales Descuento:222f6e: -12.00EUR Total: 37.85EUR --- The taxes shown are calculated based on 52E before the discount is applied so I guess that is ok (16%), but again the total is 37.85E, when it should be 40E. Strangely enough, the gift vouchers do seem to work ok. 16% customer with "12E" gift voucher - OK: --- Subtotal: 40.00EUR Mensajeria (Empresa de mensajeria (CBL, MRW, UPS)): 12.00EUR Cupón Regalo: 12.00EUR IVA: 7.18EUR Total: 40.00EUR --- The taxes shown are based on the 52EUR total, which I guess tecnically is ok, since they would paying taxes based on a 52EUR order, just paying 40E in cash/whatever and 12E with a gift voucher. Any hints on how to proceed would be greatly appreciated, since I am starting to think that this might not be a config issue, but a bug somewhere. I'll be posting my config info next. Thanks! |
| Sponsored Links | ||
| ||
|
#2
| ||||
| ||||
| My config on admin/modules/total order tight now is the following: ---- Subtotal - 1 Shipping - 2 Fixed payment charge - 10 (i think that is the english name, adds 5E if cash on delivery is chosen and 4% if Paypal is chosen) Discount coupons - 11 Gift Vouchers - 12 Taxes - 20 Total - 800 ---- Discount coupons ---- Display value - true Sort order - 11 Include shipping - true Include tax - true Re-calculate tax - Standard Tax class - Taxable item ---- (I think I have tried all the different available options... I do not quite understand the last two options, and I think that "tax class" has no effect unless "re-calculate tax" is set to "credit note") Gift vouchers ---- Display value - true Sort order - 12 Queue purchases - true Include shipping - true Include tax - true Re-calculate tax - None Tax class - None Credit including tax - false ---- I have checked the bugtrack, and have verified that this is installed on my OSCMAX: 122: discount coupon standard tax recalculation - Bug Tracker - open source Commerce Maximized :: osCMax (more...) |
|
#3
| ||||
| ||||
| And one more thing that might help. I have 2 shipping methods, one costs 6E, the other one costs 12E. When I use the "free shipping" coupon with the 6E shipping method, what I get is: 16% customer with "free shipping" coupon on 6E shipping - not so bad: --- Subtotal: 40.00EUR Correos (Carta Certificada/Paquete Azul): 6.00EUR Vales Descuento:222f6e: -6.00EUR IVA: 5.39EUR Total: 39.05EUR --- Here it appears that after a total of 46E (40+6E), a discount is being applied of 6E+taxes. Purchase 40E (34.4827+16%), shipping 6E (5.1724+16%) = 46E. Add a discount of 6E+16% = 6.96E, and we have 39,04E The total is actually 39.05E, but that could be because rounding, since the discount is actually on the shipping cost, and if taxes are being added twice it would be 5.1724+16%+16%=6.9599 , which maybe is being rounded down to 6.95 The total taxes here are ok (purchase 33.66 + taxes 5.39 = total 39.05) For testing, I created a new 6E discount coupon, and what comes out is about the same: 16% customer with "6E discount" coupon on 6E shipping - not so bad: --- Subtotal: 40.00EUR Correos (Carta Certificada/Paquete Azul): 6.00EUR Vales Descuento:7c8d4e: -6.00EUR IVA: 5.40EUR Total: 39.05EUR --- Here we have 5.40E taxes but the total is the same. Last edited by MindTwist; 09-05-2007 at 09:32 AM. |
|
#4
| ||||
| ||||
| And here some more weird results. After setting the global "display prices with tax" to false the totals change and even give me different ammounts. 16% customer with "free shipping" coupon - WRONG: --- Subtotal: 34.48EUR Correos (Carta Certificada/Paquete Azul): 5.17EUR Vales Descuento:222f6e: -5.17EUR IVA: 5.39EUR Total: 39.87EUR --- 16% customer with "6E discount" coupon - WRONG: --- Subtotal: 34.48EUR Correos (Carta Certificada/Paquete Azul): 5.17EUR Vales Descuento:7c8d4e: -6.00EUR IVA: 5.24EUR Total: 38.89EUR --- (total was 37.85E on both cases when display prices with tax was set to true) I change "re-calculate tax" to "Standard" on admin/modules/total order/discount coupons, nothing changes. I change "include tax" from false to true, nothing changes. --- Subtotal: 34.48EUR Correos (Carta Certificada/Paquete Azul): 5.17EUR Vales Descuento:222f6e: -5.17EUR IVA: 5.39EUR Total: 39.87EUR --- Subtotal: 34.48EUR Correos (Carta Certificada/Paquete Azul): 5.17EUR Vales Descuento:7c8d4e: -6.00EUR IVA: 5.24EUR Total: 38.89EUR --- I change "re-calculate tax" to "credit note" on admin/modules/total order/discount coupons, with "free shipping" coupon it is the same, with 6E discount it is different. --- Subtotal: 34.48EUR Correos (Carta Certificada/Paquete Azul): 5.17EUR Vales Descuento:7c8d4e: -6.00EUR IVA: 5.24EUR Total: 37.79EUR --- I change tax class to "taxable item" (which is 16%), and again with "free shipping" coupon it is the same, with 6E coupon it changes yet again. --- Subtotal: 34.48EUR Correos (Carta Certificada/Paquete Azul): 5.17EUR Vales Descuento:7c8d4e: -6.00EUR IVA: 5.52EUR Total: 39.17EUR --- So, as you can imagine by now, this is driving me crazy. Any hints on how to get this to work ok will be greatly appreciated, since I do not know what else to look |
|
#5
| ||||
| ||||
| Still working on this, but for now I have found the following error on OSCMAX code, file \includes\modules\order_total\ot_coupon.php Line 350 reads: Code: $god_amout=0; Code: $god_amount=0; |
|
#6
| ||||
| ||||
| Yeah, I know this looks more like a worklog than a forum, but this way I will remember the info later too. Still working on it, but I think I got everything figured out and working, I only have left doing trial orders with 0% customers and 16% customers, trying out different coupons, etc. After messing around a bit, it seems it gives me the correct total and discounts, but it was still giving me the wrong taxes. --- Subtotal: 40.00EUR Mensajeria (Empresa de mensajeria (CBL, MRW, UPS)): 12.00EUR Vales Descuento (222f6e): -12.00EUR IVA: 7.18EUR Total: 40.00EUR --- The taxes were being calculated based on products+shipping, without taking into account the discount. That means that the customer is paying 10.34E + 16% tax, and I am discounting them 12E tax free Why is it working now? It is not the only change, but I messed a little bit with the following code on \includes\modules\order_total\order_coupon.php: Code: //New code for tax recalculation fix
if ($tod_amount == 0 || $tod_amount == '') {
$pct = $order->info['tax'] / $order->info['subtotal'];
$order->info['tax'] = $order->info['tax'] - ($pct * $od_amount);
foreach ($order->info['tax_groups'] as $key => $value) {
$value = $value - ($pct * $od_amount);
$order->info['tax_groups'][$key] = $value;
$order->info['total'] -= ($pct * $od_amount);
}
}
//end new code
But this code didn't work for me for 2 reasons. First, my shipping has taxes too. So where I have: Code: $pct = $order->info['tax'] / $order->info['subtotal']; Code: $pct = $order->info['tax'] / ( $order->info['subtotal'] + $order->info['shipping_cost'] ); Second, my total was already correct, and this code is recalculating the taxes, and then whatever it sutracts from tax, it sutracts it from the total too. Didn't have to do it on my case, so I commented out the last line: Code: // $order->info['total'] -= ($pct * $od_amount); --- Subtotal: 40.00EUR Mensajeria (Empresa de mensajeria (CBL, MRW, UPS)): 12.00EUR Vales Descuento (222f6e): -12.00EUR IVA: 5.52EUR Total: 40.00EUR --- Which is what I am supposed to get with the free shipping discount. 40+12-12 = 40, so the customer has only paid 16% on those 40E, which is 5.52E. Will try to post more information later in case anyone is interested! Last edited by MindTwist; 09-05-2007 at 06:04 PM. |
|
#7
| ||||
| ||||
| Here is the problem I have left right now, with the ot_coupon.php I had before (from default OSCMAX install), when you picked a payment method, entered a discount coupon, and hit "redeem coupon", it took you to the final step on the checkout process. How I have it now, it takes me back to the same screen, with a red window on top that should show "congrats, you have redeemed a 12E coupon" or something, but shows nothing. The URL it takes me to is: http://www.twistedtienda.com/checkout_payment.php?payment_error=ot_coupon&e rror=Felicidades%2C+usted+ha+canjeado+12.00EUR+ So the text is on the URL, but not showing up anywhere on screen: ![]() Customer hits continue, and gets taken to the last screen with all the right information. I will leave this for tomorrow. |
|
#8
| ||||
| ||||
| And here is the full code for my ot_coupon.php as it is now. Please keep in mind that it has not been fully tested. It is based on a mix of ot_coupon.php from CCGV5.18.zip (from http://www.oscommerce.com/community/contributions,282) and ot_coupon.php from OSCMAX, but they are not fully merged so feel free to compare with yours. I know I have not merged a couple of lines that fixed OSCMAX bug #47 (http://bugtrack.oscmax.com/view.php?id=47) since I do not use products with attributes, so keep it in mind if you use them. BLEH, I'd say that 37k of code is too much for one single post. To bed now... |
|
#9
| |||
| |||
| I have the exact same problem as you have written about here. I could really need that full code for your ot_coupon.php. |
|
#10
| ||||
| ||||
| Here you go (if I can attach a 8k zip file). Feel free to compare it with the standard OSCMAX ot_coupon.php, but I remember I had to mess up quite a bit with it. Also, I am sure that this module as I have it might NOT work for everyone. I can tell you that on my setup, I have two kind of customers, with 0% tax and with 16% tax. Their shipping has the same tax as their products, either 0% or 16%. Shipping discounts work perfect for me. Quantity discount work perfect for me. Percentage discounts do NOT work for me, but I didn't bother fixing them. If you do a text search for "mindtwist" on the code you will find a place commented where I think the % discounts take place. After so much messing with the module I didn't feel like doing any more on it, since everything I needed worked for me, but I am sure it won't work for everyone - like I said on my last post, if you use products with attributes, that fix is not applied. |
| Sponsored Links | ||
| ||
| Thread Tools | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Desperate for Help! County Sales Tax | marcygiff | osCommerce 2.2 Modification Help | 1 | 01-19-2007 12:03 PM |
| can someone please help - really stuck, getting desperate... | obscure | osCommerce 2.2 Modification Help | 3 | 09-20-2004 12:55 PM |
| Desperate - How Much???? | LockyBoy | osCMax v1.7 Discussion | 2 | 03-04-2004 09:11 AM |
| tax will not calculate | foofoo | osCMax v1.7 Discussion | 2 | 09-26-2003 05:28 PM |
| calculate image size? | sheikyerbouti | osCommerce 2.2 Modification Help | 1 | 11-17-2002 08:37 AM |