Tax Calculation after discount


  • Default avatar
    Ekovax    
     11 years ago
    0

    Seyi,

    Thanks for your AWO Coupon, which works great! But I have a client who wants things to look differently in the cart view. It is for a winery and they wanted to have a 10% automatic discount taken when a customer orders a case (12 bottles or more), so I have that set up and working. Originally, I had the tax calculating after discount, which is what they wanted, but they want the the 10% discount to display exactly as 10%, so for instance, $19 on $190.00, a subtotal ($171, for instance) and the Tax display below at 6% of the $171 (which would be $10.26), the shipping total (let's say 25), and then a final total, which would be $206.26.

    Right now if I set up the discount after tax, it adds it to the discount, making a discount of $20.14 and a tax of $11.40 rather than subtract it from the total tax. It calculates perfectly correct to $206.26, of course, but the client prefers it to display like this.

    Product prices result $190
    Case Discount -$19
    Subtotal $171
    Shipping $25
    Tax $10.26
    Total $206.26

    Is this possible?
  • Default avatar
    Ekovax    
     11 years ago
    0

    Sorry, should have said...working with Joomla 2.5.9 and Virtuemart 2.0.18a
  • Your avatar
    seyi    
     11 years ago
    0

    Hello,

    I believe what you want is actually discount before tax. Discount after tax does not discount the tax. Discount before tax does. The total will not make a difference on percentage discount, but it will on amount discounts.
  • Default avatar
    Ekovax    
     11 years ago
    0

    That was my solution, but that's not what my client wants. With the "Calculate the discount before tax" checked to "yes" it reads:

    Product prices result $119.88
    Case Discount -$12.71
    Shipping $27.56
    Tax (6%) $7.19
    Total $141.92

    With the "Calculate the discount before tax" checked to "no" it reads:

    Product prices result $119.88
    Case Discount -$11.99
    Shipping $27.56
    Tax (6%) $7.19
    Total $142.64

    What the client wants is this:

    Product prices result $119.88
    Case Discount -$11.99
    Subtotal $107.89
    Shipping $27.56
    Tax (6%) $6.47
    Total $141.92

    So essentially this tax is calculated off the subtotal. The total is perfectly right when it Calculates before tax...I'm just not sure how to make it display as the client wants.
  • Your avatar
    seyi    
     11 years ago
    0

    Hello,

    You will need to update the template to have the numbers display as you want.

    The virtuemart core file is located here:
    www/components/com_virtuemart/views/cart/tmpl/default_pricelist.php

    If there is a template override, then it would be calling this file instead:
    www/templates/[your_template]/html/com_virtuemart/cart/default_pricelist.php

    You would have to update the totals to subtract as you need. You can access the coupon discounts with and without tax, like such:

    <?php
        $session 
    JFactory::getSession();
        
    $coupon_sess $this->session->get('coupon''''awocoupon');
        if(!empty(
    $coupon_sess ) ){
            
    $coupon_sess unserialize($coupon_sess );
            
    $coupon_sess['product_discount']; // coupon discount including tax
            
    $coupon_sess['product_discount_notax']; // coupon discount not including tax
            
    $coupon_sess['product_discount_tax'];  // coupon tax
        
    }
    ?>
  • Default avatar
    Ekovax    
     11 years ago
    0

    Seyi,

    Is this code that I could put into the default_pricelist.php or just a "for instance"? This has been the file that I've been messing about with, and I was pretty sure this is where I needed to make the changes, but being a complete and utter novice I was truly afraid I would break all calculation rules in doing so...
  • Your avatar
    seyi    
     11 years ago
    0

    The code I wrote just shows you how to get access to the coupon amounts/tax. You would need to for instance, on the subtotal line, subtract the coupon without tax ($coupon_sess['product_discount_notax').