I've just noticed something weird in the discounts calculation and am hoping that someone might tell me if I'm missing something or if it's a bug...
Using 1.5.4 clean install. For simpler calculation, I've changed Florida tax rate to 10%.
Created new coupon: 20% off and free shipping.
Added item in cart (Taxable Goods). Using Flat Rate $5.00 (Taxable Goods). Going to checkout using a Florida address.
Here are my totals before applying the coupon:
Sub-Total: 110.97
Flat Rate (Best Way): $5.00
FL TAX 10.0%: $11.60
Total: $127.57
All good.
Now I apply the coupon and this is what I get:
Sub-Total: 110.97
Flat Rate (Best Way): $5.00
Discount Coupon: test :-$27.19
FL TAX 10.0%: $9.38
Total: $98.16
I think this is wrong, isn't it? It seems to be adding shipping tax even though shipping is free.
110.97 + 5 - (22.19 + 5) = 88.78
10% tax on 88.78 should be 8.88. It seems that it's still adding the 0.50 tax from shipping.
Here's what I've done to fix it:
includes/modules/order_total/ot_coupon.php line 419-429
Code:
case 'E': // percentage & Free Shipping
$od_amount['total'] = zen_round($orderTotalDetails['orderTotal']*($coupon->fields['coupon_amount']/100), $currencyDecimalPlaces);
$od_amount['type'] = $coupon->fields['coupon_type'];
$ratio = $od_amount['total']/$orderTotalDetails['orderTotal'];
// add in Free Shipping
$od_amount['total'] = $od_amount['total'] + $orderTotalDetails['shipping'];
$od_amount['tax'] = $orderTotalDetails['shippingTax'];
if (isset($_SESSION['shipping_tax_description']) && $_SESSION['shipping_tax_description'] != '') {
$od_amount['tax_groups'][$_SESSION['shipping_tax_description']] = $od_amount['tax'];
}
break;
replace with:
Code:
case 'E': // percentage & Free Shipping
$od_amount['total'] = zen_round($orderTotalDetails['orderTotal']*($coupon->fields['coupon_amount']/100), $currencyDecimalPlaces);
$od_amount['type'] = $coupon->fields['coupon_type'];
// add in Free Shipping
$od_amount['total'] = $od_amount['total'] + $orderTotalDetails['shipping'];
$ratio = $od_amount['total']/$orderTotalDetails['orderTotal'];
$od_amount['tax'] = $orderTotalDetails['shippingTax'];
if (isset($_SESSION['shipping_tax_description']) && $_SESSION['shipping_tax_description'] != '') {
$od_amount['tax_groups'][$_SESSION['shipping_tax_description']] = $od_amount['tax'];
}
break;
Basically, I just moved the $ratio line. Of course, same "patch" needs to be done for case O.
Now, since this code was written by Ajeh a long time ago (DiscountCombo_v15B.zip), I'm just not sure if I'm missing something obvious and if it's really supposed to calculate that way OR was it just an oversight and a bug?
Bookmarks