Results 1 to 10 of 17

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Posts
    25
    Plugin Contributions
    0

    Default Re: reopen thread [Done v1.3.9] Discount groups and tax calc problem with tax-include

    Hello Wilt,

    Here's what I'm trying to achieve.

    First I should say I use two tax rates: 6% and 19%
    Second I use discount groups, for loyal customers etc.
    And third the shop displays prices incl tax.

    When a customer in my discount group orders for €100.00 incl 6% tax this is what the calculation must look like:

    Sub-Total: €100.00
    Group Discount 30%: -€30.00
    Shipping cost (incl 19%): €5.65
    TAX 6%: €3.96
    TAX 19%: €0.90
    Total: €75,65

    The group discount is subtracted from the subtotal with tax included, so the tax mentioned should be calculated after the discount is subtracted

    When there are no shipping costs charged, the calculation is correct.
    Even when a customer orders products with 6% tax AND products with 19% tax the calculation is correct (as long as there are no shipping costs).

    Things only get messed up when shipping cost are charged.

    Greetings Antonios

  2. #2
    Join Date
    Sep 2008
    Posts
    25
    Plugin Contributions
    0

    Default Re: reopen thread [Done v1.3.9] Discount groups and tax calc problem with tax-include

    One thing I'd like to add:
    When a customer orders products (any tax) and is NOT in a discount group the calculation is also correct, even when shipping costs are charged.

    So it's clear that the problem is where there's a combination of shipping costs/tax and discount groups.

  3. #3
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: reopen thread [Done v1.3.9] Discount groups and tax calc problem with tax-include

    And have you tried setting your Tax settings to NOT display the tax details split into multiple lines?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Sep 2008
    Posts
    25
    Plugin Contributions
    0

    Default Re: reopen thread [Done v1.3.9] Discount groups and tax calc problem with tax-include

    Yes I've tried that, also incorrect:

    Sub-Total: €16.95
    Flat Rate (Best Way): €5.65
    Group Discount: -€4.82 (should be -€5.09)
    tax 6% + tax 19%: €1.57 (total of tax seems ok, doesn't mean that the calculation is)
    Total: €17.78 (should be €17.51)

    Like I said, the problem isn't the difference in tax rates, but the combination of group discounts and shipping tax.

    Greetings Antonios

  5. #5
    Join Date
    Sep 2008
    Posts
    25
    Plugin Contributions
    0

    Default Re: reopen thread [Done v1.3.9] Discount groups and tax calc problem with tax-include

    I've been coding and puzzling , still no result.
    If nobody knows how to fix this, I think I have to leave zen-cart for what it is and find webshop software that can calculate taxes etc.

    What a mess and what a loss ..

  6. #6
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,927
    Plugin Contributions
    4

    Default Re: reopen thread [Done v1.3.9] Discount groups and tax calc problem with tax-include

    Hi

    Here's the patch/diff that I applied to Zen Cart v139d to fix the problem.

    PHP Code:
    --- includes/modules/order_total/ot_group_pricing.php
    +++ iincludes/modules/order_total/ot_group_pricing.php
    @@ -61,14 +61,26 @@
     
    //    echo "order total = $order_total<br>";
     //    echo "order total shipping = {$order->info['shipping_cost']}<br>";
     //    echo "order total tax = {$order->info['tax']}<br>";
         
    if ($this->include_shipping != 'true'$order_total -= $order->info['shipping_cost'];
         if (
    $this->include_shipping != 'true'$order_total_tax -= $order->info['shipping_tax'];
    +    
    $taxGroups = array();
    +    foreach (
    $order->info['tax_groups'] as $key=>$value) {
    +      if (isset(
    $_SESSION['shipping_tax_description']) && $key == $_SESSION['shipping_tax_description'])
    +      {
    +        if (
    $this->include_shipping != 'true')
    +        {
    +          
    $value -= $order->info['shipping_tax'];
    +        }
    +      }
    +      
    $taxGroups[$key] = $value;
    +    }
         if (
    $this->include_tax != 'true'$order_total -= $order->info['tax'];
    //     if ($this->include_tax != "true" && $this->include_shipping != 'true') $order_total += $order->info['shipping_tax'];
    +     if ($this->include_tax != "true" && $this->include_shipping != 'true'$order_total += $order->info['shipping_tax'];

         
    $orderTotalFull $order_total;
     
    //    if (DISPLAY_PRICE_WITH_TAX != 'true') $order_total += $order_total_tax;
     //    echo "order total* = $order_total<br>";
    -    $order_total = array('totalFull'=>$orderTotalFull'total'=>$order_total'tax'=>$order_total_tax);
    +    
    $order_total = array('totalFull'=>$orderTotalFull'total'=>$order_total'tax'=>$order_total_tax'taxGroups'=>$taxGroups);
         return 
    $order_total;
       }
       function 
    calculate_deductions($order_total) {
    @@ -
    77,+89,@@
         if (
    $order_total == 0) return $od_amount;
         
    $orderTotal $this->get_order_total();
         
    $orderTotalTax $orderTotal['tax'];
    +    
    $taxGroups $orderTotal['taxGroups'];
         
    $group_query $db->Execute("select customers_group_pricing from " TABLE_CUSTOMERS " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
         if (
    $group_query->fields['customers_group_pricing'] != '0') {
           
    $group_discount $db->Execute("select group_name, group_percentage from " TABLE_GROUP_PRICING "
    @@ -104,11 +117,11 @@
               }
               
    $adjustedTax = $orderTotalTax * $ratio;
               if (
    $order->info['tax'] == 0) return $od_amount;
    -          
    $ratioTax = $adjustedTax/$order->info['tax'];
    +          
    $ratioTax = $adjustedTax/$orderTotalTax;
               reset(
    $order->info['tax_groups']);
               
    $tax_deduct = 0;
    -          foreach (
    $order->info['tax_groups'] as $key=>$value) {
    -            
    $od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratioTax;
    +          foreach (
    $taxGroups as $key=>$value) {
    +            
    $od_amount['tax_groups'][$key] = $value * $ratioTax;
                 
    $tax_deduct += $od_amount['tax_groups'][$key];
               }

    Last edited by wilt; 8 Jul 2010 at 12:51 PM.

  7. #7
    Join Date
    Sep 2008
    Posts
    25
    Plugin Contributions
    0

    Default Re: reopen thread [Done v1.3.9] Discount groups and tax calc problem with tax-include

    Wilt!
    You've just made a girl extremely happy!

    It works like a charm, with and without tax split lines, with and without shipping costs and with multiple tax rates.

    Thank you, thank you, thank you.

    I hope the zen-cart team will add this patch to their next update.

    Greetings Antonios
    Last edited by antonios; 8 Jul 2010 at 07:16 PM. Reason: typing error

  8. #8
    Join Date
    Mar 2009
    Posts
    33
    Plugin Contributions
    0

    Default Re: reopen thread [Done v1.3.9] Discount groups and tax calc problem with tax-include

    strange.. i put in the changes from your diff, and it's calculating the discount wrong. and the tax is also still wrong.

    What did i screw up?

    The discount is 20%

    Your Total

    Sub-Total:$82.50
    Group Discount:-$17.00
    Canada Post (Expedited, 2010-07-13):$9.59
    13% HST # + 13% Shipping HST #:$10.08
    Total:$85.17

 

 

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: 26
    Last Post: 19 Mar 2010, 04:45 PM
  3. Replies: 0
    Last Post: 13 Jun 2008, 12:57 PM
  4. 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
  5. Replies: 2
    Last Post: 13 Aug 2006, 11:46 AM

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