Discount calculated always after tax


  • Default avatar
    christos    
     11 years ago
    0

    Hi seyi,

    wishing a happy 2013! We have the following issue with latest awocoupon and vm2.0.16:

    the discount amount is always calculated after tax even if we have selected the appropriate option in awocoupon backend (calculate before tax)

    is there anything else that we should check?

    you can check this in our website:

    www.quality-tuning.co.uk (you may use 10% test coupon TEST10)

    thanks in advance!

    rgrds,
    chris
  • Your avatar
    seyi    
     11 years ago
    0

    Hi Chris,

    This was working before vm 2.0.16 right? Looking at vm code, it looks like it now overrides the tax calculation from awocoupon plugin. Try this: in www/administrator/components/com_virtuemart/helpers/calculationh.php, around line 701 is this code:
    <?php
            
    if((!empty($this->_cartPrices['billDiscountAmount']) and isset($this->_cartData['VatTax']) and count($this->_cartData['VatTax'])==1) or !empty($cart->couponCode)){
    ?>


    Change it to this:
    <?php
            
    //if((!empty($this->_cartPrices['billDiscountAmount']) and isset($this->_cartData['VatTax']) and count($this->_cartData['VatTax'])==1) or !empty($cart->couponCode)){
            
    if(1!=1) {
    ?>
  • Default avatar
    christos    
     11 years ago
    0

    Hi Seyi,

    Thanks for the suggestion, but it didn't work, discount is still calculated after tax; to be honest i hadn't tested this prior to 2.0.16 but i know that the VM team did some changes indeed in the calculationh.php.

    Any other ideas?

    Thanks,
    Chris
  • Your avatar
    seyi    
     11 years ago
    0

    Hi Chris,

    How did you set up your tax rule? Is it tax per product or tax per basket?

    Also what is your tax rate?
  • Default avatar
    christos    
     11 years ago
    0

    Hi seyi,

    it is vat tax per product (VatTax) and the tax rate is 17%.

    rgrds,
    chris
  • Your avatar
    seyi    
     11 years ago
    0

    Hi Chris,

    Did some calculations and the discount, total, and tax amount actually comes out correct. Here are the before and after pics:
    before:
    http://i45.tinypic.com/auyqma.png

    after:
    http://i46.tinypic.com/ea4gtg.png


    At 17%
    Product before tax --> 338.34/1.17 = 289.1795
    Product tax --> 338.34-289.1795 = 49.1605

    Shipping before tax --> 37.24/1.17 = 31.82905
    Shipping tax --> 37.24-31.82905 = 5.4109

    Total Tax --> 49.1605+5.4109 = 54.5714
    Total --> 338.34 + 37.24 = 375.58

    This is the totals before adding a discount, now we add a 10% discount before tax on products:
    Product before tax --> 289.1795*0.90 = 260.26155
    Product tax --> 260.26155*0.17 = 44.2445

    Product total after tax --> 260.26155+44.2445 = 304.50605

    Total tax --> 44.2445+5.4109 = 49.6554
    Total --> 304.50605+37.24 = 341.74605

    The total tax and total match what is in the after image of calculating discount before tax.
  • Default avatar
    christos    
     11 years ago
    0

    Hi Seyi,

    Thanks for your time and effort; at the end it seems to be all ok and calculations are correct indeed. However, please note in the 2nd pic (after), that the discount amount shown is 33.83. This is wrong and misleading. The 33.83 is wrongly calculated from the price after tax (338.34 * 0.10). The correct discount amount before tax should be 289.1795 * 0.10 = 28.92.

    Would appreciate your comments on how to fix that!

    Rgrds,
    Chris
  • Your avatar
    seyi    
     11 years ago
    0

    It would have to be fixed within your template. It is showing the salespricecoupon, which shows the overall discount including tax savings. You want it to show the couponvalue, which shows no tax amount. If having trouble with it, then contact the opc developer.
  • Default avatar
    christos    
     11 years ago
    0

    Thanks seyi, i will check this out ;)
  • Default avatar
    james2    
     11 years ago
    0

    I too am have the same issue. I am not using VAT but do have to collect tax on sales in Michigan. I created a tax per bill of 6% I am running VM 2.018a (i upgraded because from what I could read it was an issue I thought they fixed) I did make the changes above and it did not help. Any ideas would be great. the site is sinfulnspice.com and the coupon code is jan20off. I made sure that the Calculate the discount before tax (Coupons) is set to yes

    Thanks,
    Jim
  • Your avatar
    seyi    
     11 years ago
    0

    Hi Jim,

    Try this:
    in www/administrator/components/com_awocoupon/helpers/estore/virtuemart/couponhandler.php, around line 128 is this
    <?php
            $this
    ->vmcartPrices['couponTax'] = $coupon_session['product_discount_tax'] + $coupon_session['shipping_discount_tax'];
            
    $this->vmcartPrices['couponValue'] = $coupon_session['product_discount_notax'] + $coupon_session['shipping_discount_notax'];
            
    $this->vmcartPrices['salesPriceCoupon'] = $coupon_session['product_discount'] + $coupon_session['shipping_discount'];
    ?>


    change it to this
    <?php
            $coupon_taxbill 
    0;
            if(
    $this->coupon_discount_before_tax && !empty($this->vmcartData['taxRulesBill'])) {
                
    $billtaxrate 0;
                foreach(
    $this->vmcartData['taxRulesBill'] as $rate) {
                    if(
    $rate['calc_value_mathop']=='+%'$billtaxrate += $rate['calc_value'];
                    elseif(
    $rate['calc_value_mathop']=='-%'$billtaxrate -= $rate['calc_value'];
                }
                if(!empty(
    $billtaxrate)) {
                    
    $billtaxrate /= 100;
                    
    $coupon_taxbill = ($coupon_session['product_discount'] + $coupon_session['shipping_discount'])*$billtaxrate;
                }
                
            }
            
    $this->vmcartPrices['couponTax'] = $coupon_session['product_discount_tax'] + $coupon_session['shipping_discount_tax'] + $coupon_taxbill;
            
    $this->vmcartPrices['couponValue'] = $coupon_session['product_discount_notax'] + $coupon_session['shipping_discount_notax'];
            
    $this->vmcartPrices['salesPriceCoupon'] = $coupon_session['product_discount'] + $coupon_session['shipping_discount'] + $coupon_taxbill;
            
    $this->vmcartData['vmVat'] = false;
    ?>


    You should now receive the 6% discount before tax