Page 1 of 3 123 LastLast
Results 1 to 10 of 27
  1. #1
    Join Date
    Jan 2009
    Posts
    61
    Plugin Contributions
    0

    Default [Done v1.3.9] Discount groups and tax calc problem with tax-included pricing

    Hi all,

    Really sorry to post this again from e/where on the forum. http://www.zen-cart.com/forum/showthread.php?t=119602
    It strikes me as an issue with the way tax is handled, but I need a view from a proper coder, as this facility is vital to my business. I'm sure it only requires a small alteration, but I'm struggling to find an answer:

    I have a problem with group pricing and shipping (I think).
    No Coupons
    ZC1.3.8a
    I set up a dummy product priced £100
    I added it to the cart and checked out.
    The cart shows:

    Sub-Total: £100 (inc. VAT)

    Shipping:£10.00 (inc. VAT)

    Group Discount:-£5.00 (this is application of a group discount of 5%)

    VAT 15%:£13.63

    Total:£105.00


    ot_group_pricing is set Include Shipping & Include Tax both False.

    The VAT figure should be 105 * 15% = 13.70
    What's actually happening is that the VAT is being calced thus:

    104.50 * 15% = 13.63

    The 104.50 is coming from:

    100 less 5% = 95.00
    10 less 5% = 9.50

    The 5% is the group discount.

    How do I stop the Group Discount being applied to shipping for VAT purposes? I guess it's in the tax module, but that code is a bit scary to a noob. Any help very much appreciated.

    Thanks,

    Sean

  2. #2
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,877
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: Discount groups and tax calc problem

    Hi,

    This is a bug, and has been addressed in the upcoming v139 release.

    There are a couple of files that need to be edited to fix this.

    First is includes/classes/order.php

    circa line 347 - you should see

    PHP Code:
                     'subtotal' => 0,
                            
    'tax' => 0,
                            
    'total' => 0
    which should be changed to

    PHP Code:
                     'subtotal' => 0,
                           
    'shipping_tax'=>0,
                            
    'tax' => 0,
                            
    'total' => 0
    next you need to edit includes/modules.order_total/ot_shipping.php

    circa line 67 change

    PHP Code:
              $order->info['tax'] += $shipping_tax_amount;
              
    $order->info['tax_groups']["$shipping_tax_description"] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax); 
    to

    PHP Code:
        $order->info['tax'] += $shipping_tax_amount;
                 
    $order->info['shipping_tax'] += $shipping_tax_amount;
              
    $order->info['tax_groups']["$shipping_tax_description"] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax); 
    and finally includes/modules/order_total/ot_group_pricing.php

    circa line 60
    change

    PHP Code:
        if ($this->include_shipping != 'true'$order_total -= $order->info['shipping_cost']; 
    to

    PHP Code:
        if ($this->include_shipping != 'true'$order_total -= $order->info['shipping_cost'];
        if (
    $this->include_shipping != 'true'$order_total -= $order->info['shipping_tax']; 
    Remember to backup any files you edit, in case of disasters.

  3. #3
    Join Date
    Jan 2009
    Posts
    61
    Plugin Contributions
    0

    Default Re: Discount groups and tax calc problem

    Hi Wilt,

    Thanks for the reply. Unfortunately, it didn't work. It added 6 pence to my cart total, and subtracted the same from the group discount.
    More to the point, it didn't affect the tax figure at all: I went on to try the same cart (product 100 in tax 15%, shipping 10 inc tax 15%) with a range of group discounts from 5 through 100%. The only one to figure right was (da-daaaa....) 100% discount. On some, the rounding was abominable, but that's a different issue...
    Each conformed to the pattern: calculating the total tax on a figure derived from (Subtotal + Shipping)-((Subtotal + Shipping)*groupDiscount%), with no regard to how group pricing module switches were set.

    It looks like I have to artificially raise my shipping prices, and set Include Shipping=true, in order to have the shipping discounted to the right price in the cart.
    This is unsatisfactory as hell, as it misrepresents actual prices.
    I love the functionality and adaptability of ZenCart, but I hate that it can't add up, or round out correctly.
    I know this ain't your fault, or anyones, really, I'm just stunned that it hasn't been addressed long ago....

    Here's hoping,

    Sean

  4. #4
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,877
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: Discount groups and tax calc problem with tax-included pricing

    Hi,

    My apologies, but it seems my fingers failed me.

    Where I said to change includes/modules/order_total/ot_group_pricing.php to

    PHP Code:
        if ($this->include_shipping != 'true'$order_total -= $order->info['shipping_cost'];
        if (
    $this->include_shipping != 'true'$order_total -= $order->info['shipping_tax']; 
    the second line should have been

    PHP Code:
    if ($this->include_shipping != 'true'$order_total_tax -= $order->info['shipping_tax']; 

  5. #5
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,877
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: Discount groups and tax calc problem with tax-included pricing

    Note. The above is partly plagued by the rounding error mentioned in your other thread.

    However I think I have a solution for that as well. Will post to other thread

  6. #6
    Join Date
    Jan 2009
    Posts
    61
    Plugin Contributions
    0

    Default Re: Discount groups and tax calc problem with tax-included pricing

    Aha!
    And my apologies for not spotting the obvious and sorting it out myself...still on a heck of a learning curve

    Sean

  7. #7
    Join Date
    Jan 2009
    Posts
    61
    Plugin Contributions
    0

    Default Re: Discount groups and tax calc problem with tax-included pricing

    ...except this is not yet quite fixed.
    with this mod, totals are as follows:


    Sub-Total:£100.00
    Flat Rate (Best Way):£10.00
    Group Discount:-£4.93
    VAT 15%:£13.69
    Total:£105.06

    Include Tax & Shipping both=False, Re-calculate Tax=Standard.

    The Tax is now calculating close enough, but discount is down 7p and total is up only 6p (this is without rounding mod from other thread, just trying to do one thing at a time...)

    I'm going to leave this for the moment, and concentrate on other things for a while, maybe it'll look better when I come back to it...



    Thanks for your help, so far...
    Cheers,

    Sean

  8. #8
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,877
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: Discount groups and tax calc problem with tax-included pricing

    k, have removed my previous post, as i had not quite thought things through .

    There is still a piece missing.

    If both include_tax and include-shipping are FALSE then the calculations are being done on an order_total that has in effect had the shipping tax removed twice, hence the 6p discrepancy.
    Last edited by wilt; 22 Feb 2009 at 06:56 PM.

  9. #9
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,877
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: Discount groups and tax calc problem with tax-included pricing

    The fix is to add this line

    PHP Code:
        if ($this->include_tax != "true" && $this->include_shipping != 'true'$order_total += $order->info['shipping_tax']; 
    This should be added after the similar lines we changed earlier to adjuts the shipping tax.

    I now get

    Sub-Total:£100.00
    Flat Rate (Best Way):£10.00
    Group Discount:-£5.00
    VAT 15%:£13.70
    Total:£105.00

  10. #10
    Join Date
    Jan 2009
    Posts
    61
    Plugin Contributions
    0

    Default Re: Discount groups and tax calc problem with tax-included pricing

    ...and now my numbers agree with yours. Thank you very much for this, it lifts a weight from my shoulders, for sure.

    Presumably this, together with the rounding issue, will be addressed in a future update? Is there a mechanism for ensuring that it gets in? I'm sure that it's easy for important mods to escape being included.

    Thanks again for your help,

    Regards,

    Sean

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v151 Discount coupon giving too much off with tax-included pricing enabled
    By nigelt74 in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 3
    Last Post: 16 Apr 2014, 11:05 AM
  2. Replies: 16
    Last Post: 8 Jul 2010, 08:51 PM
  3. Subtracting tax from a set price: how do I do tax-included pricing?
    By willem in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 2
    Last Post: 3 May 2009, 08:34 AM
  4. Replies: 0
    Last Post: 13 Jun 2008, 12:57 PM
  5. Tax not being calculated correctly -- with tax-included pricing
    By nkrcs in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 2
    Last Post: 11 Jun 2008, 07:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR