Problem with shipping tax where gift voucher exceeds total


  • Default avatar
    webdesco    
     13 years ago
    0

    Hi, I've just come across another issue with regards to a gift voucher value being higher that good + shipping totals

    ----CART----
    Subtotal (inc. VAT): £23.96

    Total (inc. VAT): £23.96
    VAT Included: £3.99

    ---- APPLY £50 voucher ----
    Info: The Value of the Coupon is greater than the current Order Total, so the Coupon Value was temporarily set to £23.96
    Subtotal (inc. VAT): £23.96
    Coupon Discount: - £23.96

    Total (inc. VAT): £0.00
    VAT Included: £3.99

    ---- CHECKOUT ----
    Subtotal (inc. VAT): £23.96
    Coupon Discount: - £23.96

    Total (inc. VAT): £0.00
    VAT Included: £0.00

    Note: because this is a Gift Certificate the VAT included should be £3.99

    ---- Select Shipping Method (Royal Mail with a Tax code of 0% as you can't claim vat on uk postage) ----

    Subtotal (inc. VAT): £23.96
    Shipping and Handling Fee: £4.41
    Coupon Discount: - £28.37

    Total (inc. VAT): £0.00
    VAT Included: -£0.73

    Note: Vat Included shows a negative amount of-£0.73 because it has applied the goods vat percent to the shipping total
  • Your avatar
    seyi    
     13 years ago
    0

    I see what you mean and what you want. First, remember that AwoCoupon calculates the discount that needs to be given and sends it back to Virtuemart to do with it as it pleases. All the taxes are calculated within Virtuemart itself. And Virtuemart does not differentiate between a coupon and a gift certificate. Your situation is so unique, i think you just need to write your own tax rules. There are 3 places I can think of this needs to be done:

    - www/administrator/components/com_virtuemart/html/basket.php (calculates tax shown in the basket)
    - www/administrator/components/com_virtuemart/html/ro_basket.php (calculates tax shown on the confirmation page)
    - www/administrator/components/com_virtuemart/classes/ps_checkout.php function calc_order_tax (calculates tax that is stored in the db)

    You will need to look at the $_SESSION['coupon_code'] and check to see if it is a gift certificate, function_type=giftcert, in awocoupon. If so, show the tax in full, otherwise, calculate the discount.

  • Default avatar
    webdesco    
     13 years ago
    0

    Thanks for the info, could you explain why my situation is so unique as surely anyone wanting to sell gift vouchers in the uk will experience the same problem.
  • Your avatar
    seyi    
     13 years ago
    0

    Maybe so, but this is the first request I have seen where the expectation is that the tax is calculated differently depending on the type of coupon used.
  • Default avatar
    webdesco    
     13 years ago
    0

    is there any reason why in ps_coupon_process.php around line 1116 you've manually set $_SESSION['coupon_type'] = 'gift'; // always call cleanup function

    rather than

    $_SESSION['coupon_type'] = $coupon->function_type;

  • Your avatar
    seyi    
     13 years ago
    0

    so the coupon cleanup code is always called.
  • Default avatar
    webdesco    
     13 years ago
    0

    how can I test it (as you suggested), if it's permanently set to 'gift'? Could you please tell me what are the knock-on effects if I change it to how it should be and where is the coupon cleanup code, could it be changes so as it checks for 'giftcert' etc.

    Your help and assistance is much appreciated.
  • Your avatar
    seyi    
     13 years ago
    0

    changing it would not be good. it is specifically for virtuemart telling virtuemart to call the cleanup code. Within virtuemart if it is a permanent coupon the cleanup code is never called as there is nothing to do. If it is a 1 time gift, then the clean up code is called to unpublish the coupon after it has been used. Within AwoCoupon, the cleanup code needs to be called for coupons since you control the number of uses. It needs to be checked and unpublish a coupon if needed. It also adds the order to the history of uses for all coupons/giftcerts.

    take a look at www/administrator/components/com_virtuemart/classes/ps_checkout.php, function add. This is the only place it is used.
  • Default avatar
    webdesco    
     13 years ago
    0

    so basically I can't use it to check to see if Im using a coupon or a Gift Voucher. I'm guessing that I need to create a new $_SESSION

    $_SESSION['coupon_genre'] = $coupon->function_type;

    so as I can do as you suggest. Right?
  • Your avatar
    seyi    
     13 years ago
    0

    yes, that would be much better
  • Default avatar
    webdesco    
     13 years ago
    0

    GREAT!
    I'm getting there, came across something that I need your help on please

    When I buy 4 items at £11.38 each it gives me a total of £45.52 which is correct!
    When I apply a £50 coupon or gift certificate I get an alert telling me that the coupon value has been reduced to £45.52 which should then be applied to the order giving me a total of £0.00

    However I'm getting -£0.00

    When I dump the value of $_SESSION['coupon_discount'] I get a value of 45.52333333333 so naturally when virtuemart calculates the total the result is -0.0033333333

    it looks like the $coupon_product_value is not rounded to 2 decimal places, but I'm unsure where to change the ps_coupon_process.php code


    Your help, as always, is greatly appreciated.
  • Your avatar
    seyi    
     13 years ago
    0

    In html/basket.php and html/ro_basket.php, you could change
    <?php
        $order_total_display 
    $GLOBALS['CURRENCY_DISPLAY']->getFullValue($order_total);
    ?>


    to
    <?php
        $order_total_display 
    $GLOBALS['CURRENCY_DISPLAY']->getFullValue(round($order_total,2));
    ?>