Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Location
    United Kingdom
    Posts
    608
    Plugin Contributions
    0

    Default Order Total wrong when Group Discount Applied

    Hi,

    When allowing Group Discounts my order total is incorrect as I get the following:
    Sub-Total: £100.00
    Group Discount (10%): -£10.00
    Shipping: £10.00
    UK VAT (20%): £20.00
    Total: £122.00 (This should be £120)
    The difference is always equal to Group Discount Amount x VAT (20%) in this instance £10 * 20% = £2. This can be reproduced with any values.

    I do NOT have the same issue with discount coupons and the total is correct.

    My set-up is as follows:

    Zen Cart V1.3.9h (Upgrade from 1.3.8a)

    Group Discount

    This module is installed
    true

    Sort Order
    280

    Include Shipping
    false

    Include Tax
    false

    Re-calculate Tax
    Credit Note

    Tax Class
    VAT
    The order of my Order Total Modules is as follows:

    Sub-Total (ot_subtotal)
    Group Discount (ot_group_pricing)
    Discount Coupon (ot_coupon)
    Shipping (ot_shipping)
    Tax (ot_tax)
    Total (ot_total)
    If by the way I set "Re-calculate Tax" to "Standard" I then get an incorrect VAT amount:
    Sub-Total: £100.00
    Group Discount (10%): -£10.00
    Shipping: £10.00
    UK VAT (20%): £19.80 (Should be £20)
    Total: £119.80 (Should be £120)
    I had no problem with V1.3.8a but I had "Re-calculate Tax" set to "Standard". I did however have the various fixes installed which had long been discussed for that version.

    I do have the EU VAT Mod and Hem's Display Prices Incl/Excl VAT mod installed but I have removed both and I still seem to have the problem.

    Hours and hours of frustration have yielded no results so as usual I'm hoping someone can put me out of my misery.

    Kind regards,

    Brent

  2. #2
    Join Date
    Mar 2005
    Location
    United Kingdom
    Posts
    608
    Plugin Contributions
    0

    Default Re: Order Total wrong when Group Discount Applied

    This could be caused by the EU VAT Mod after all. I will report back.

  3. #3
    Join Date
    Mar 2005
    Location
    United Kingdom
    Posts
    608
    Plugin Contributions
    0

    Default Re: Order Total wrong when Group Discount Applied

    Making progress. I referred back to the original fixes I installed for V1.3.8a which are summarised here.

    in includes/modules.order_total/ot_shipping.php the following line was added:
    PHP Code:
                 $order->info['shipping_tax'] += $shipping_tax_amount
    But this block of code is now commented out by the EU VAT Mod.

    PHP Code:
    <?php
    /**
     * ot_shipping order-total module
     *
     * @package orderTotal
     * @copyright Copyright 2003-2009 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: ot_shipping.php 15075 2009-12-10 21:21:02Z drbyte $
     */

      
    class ot_shipping {
        var 
    $title$output;

        function 
    ot_shipping() {
          global 
    $order$currencies;
          
    $this->code 'ot_shipping';
          
    $this->title MODULE_ORDER_TOTAL_SHIPPING_TITLE;
          
    $this->description MODULE_ORDER_TOTAL_SHIPPING_DESCRIPTION;
          
    $this->sort_order MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER;

          
    $this->output = array();
          if (
    MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
            switch (
    MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
              case 
    'national':
                if (
    $order->delivery['country_id'] == STORE_COUNTRY$pass true; break;
              case 
    'international':
                if (
    $order->delivery['country_id'] != STORE_COUNTRY$pass true; break;
              case 
    'both':
                
    $pass true; break;
              default:
                
    $pass false; break;
            }

            if ( (
    $pass == true) && ( ($order->info['total'] - $order->info['shipping_cost']) >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
              
    $order->info['shipping_method'] = $this->title;
              
    $order->info['total'] -= $order->info['shipping_cost'];
              
    $order->info['shipping_cost'] = 0;
            }
          }
          
    $module substr($_SESSION['shipping']['id'], 0strpos($_SESSION['shipping']['id'], '_'));
          if (
    zen_not_null($order->info['shipping_method'])) {
    // TVA_INTRACOM REPLACE BEGIN
    //if ($GLOBALS[$module]->tax_class > 0) {
    $tva_tax $order->customer['tva_intracom_tax'];
    if (!
    $tva_tax) {
    $shipping_tax 0;
    $shipping_tax_description TEXT_NO_TAX;
    } else {
    $shipping_tax zen_get_tax_rate($GLOBALS[$module]->tax_class$order->delivery['country']['id'], $order->delivery['zone_id']);
    $shipping_tax_description zen_get_tax_description($GLOBALS[$module]->tax_class$order->delivery['country']['id'], $order->delivery['zone_id']);
    // TVA_INTRACOM REPLACE END
              
    if (!isset($GLOBALS[$module]->tax_basis)) {
                
    $shipping_tax_basis STORE_SHIPPING_TAX_BASIS;
              } else {
                
    $shipping_tax_basis $GLOBALS[$module]->tax_basis;
              }

              if (
    $shipping_tax_basis == 'Billing') {
                
    $shipping_tax zen_get_tax_rate($GLOBALS[$module]->tax_class$order->billing['country']['id'], $order->billing['zone_id']);
                
    $shipping_tax_description zen_get_tax_description($GLOBALS[$module]->tax_class$order->billing['country']['id'], $order->billing['zone_id']);
              } elseif (
    $shipping_tax_basis == 'Shipping') {
                
    $shipping_tax zen_get_tax_rate($GLOBALS[$module]->tax_class$order->delivery['country']['id'], $order->delivery['zone_id']);
                
    $shipping_tax_description zen_get_tax_description($GLOBALS[$module]->tax_class$order->delivery['country']['id'], $order->delivery['zone_id']);
              } else {
                if (
    STORE_ZONE == $order->billing['zone_id']) {
                  
    $shipping_tax zen_get_tax_rate($GLOBALS[$module]->tax_class$order->billing['country']['id'], $order->billing['zone_id']);
                  
    $shipping_tax_description zen_get_tax_description($GLOBALS[$module]->tax_class$order->billing['country']['id'], $order->billing['zone_id']);
                } elseif (
    STORE_ZONE == $order->delivery['zone_id']) {
                  
    $shipping_tax zen_get_tax_rate($GLOBALS[$module]->tax_class$order->delivery['country']['id'], $order->delivery['zone_id']);
                  
    $shipping_tax_description zen_get_tax_description($GLOBALS[$module]->tax_class$order->delivery['country']['id'], $order->delivery['zone_id']);
                } else {
                  
    $shipping_tax 0;
                }
    /*        }
              $shipping_tax_amount = zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
              $order->info['shipping_tax'] += $shipping_tax_amount;
              $order->info['tax'] += $shipping_tax_amount;
              $order->info['tax_groups']["$shipping_tax_description"] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
              $order->info['total'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
              $_SESSION['shipping_tax_description'] =  $shipping_tax_description;
              $_SESSION['shipping_tax_amount'] =  $shipping_tax_amount;
              if (DISPLAY_PRICE_WITH_TAX == 'true') $order->info['shipping_cost'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
            }
    */
            
    if ($_SESSION['shipping'] == 'free_free') {
              
    $order->info['shipping_method'] = FREE_SHIPPING_TITLE;
              
    $order->info['shipping_cost'] = 0;
            }

    // TVA_INTRACOM REPLACE BEGIN
    }
    }
    $calculated_tax zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
    if(
    $tva_tax){
    $order->info['tax'] += $calculated_tax;
    $order->info['tax_groups']["$shipping_tax_description"] += $calculated_tax;
    $order->info['total'] += $calculated_tax;
    }
              if (
    DISPLAY_PRICE_WITH_TAX == 'true'$order->info['shipping_cost'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
    //} // if ($GLOBALS[$module]->tax_class > 0)
    // TVA_INTRACOM REPLACE END
          
    }
        }

        function 
    process() {
          global 
    $order$currencies;

            
    $this->output[] = array('title' => $order->info['shipping_method'] . ':',
                                    
    'text' => $currencies->format($order->info['shipping_cost'], true$order->info['currency'], $order->info['currency_value']),
                                    
    'value' => $order->info['shipping_cost']);
        }

        function 
    check() {
          global 
    $db;
          if (!isset(
    $this->_check)) {
            
    $check_query $db->Execute("select configuration_value from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_ORDER_TOTAL_SHIPPING_STATUS'");
            
    $this->_check $check_query->RecordCount();
          }

          return 
    $this->_check;
        }

        function 
    keys() {
          return array(
    'MODULE_ORDER_TOTAL_SHIPPING_STATUS''MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER''MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING''MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER''MODULE_ORDER_TOTAL_SHIPPING_DESTINATION');
        }

        function 
    install() {
          global 
    $db;
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('This module is installed', 'MODULE_ORDER_TOTAL_SHIPPING_STATUS', 'true', '', '6', '1','zen_cfg_select_option(array(\'true\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER', '200', 'Sort order of display.', '6', '2', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Allow Free Shipping', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING', 'false', 'Do you want to allow free shipping?', '6', '3', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('Free Shipping For Orders Over', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER', '50', 'Provide free shipping for orders over the set amount.', '6', '4', 'currencies->format', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Provide Free Shipping For Orders Made', 'MODULE_ORDER_TOTAL_SHIPPING_DESTINATION', 'national', 'Provide free shipping for orders sent to the set destination.', '6', '5', 'zen_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())");
        }

        function 
    remove() {
          global 
    $db;
          
    $db->Execute("delete from " TABLE_CONFIGURATION " where configuration_key in ('" implode("', '"$this->keys()) . "')");
        }
      }
    Hopefully someone can tell me how to port these changes into the code replacements in "// TVA_INTRACOM REPLACE" as I am lost. Beyond Compare can't help me with this so I am lost.

    Kind regards,

    Brent

  4. #4
    Join Date
    Mar 2005
    Location
    United Kingdom
    Posts
    608
    Plugin Contributions
    0

    Default Re: Order Total wrong when Group Discount Applied

    I made the following change and this seems to have fixed the problem. Around line 91 I changed

    PHP Code:
    // TVA_INTRACOM REPLACE BEGIN  - edited by brent
    }
    }
    $calculated_tax zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
    if(
    $tva_tax){
    $order->info['tax'] += $calculated_tax;
    $order->info['tax_groups']["$shipping_tax_description"] += $calculated_tax;
    $order->info['total'] += $calculated_tax;
    }
              if (
    DISPLAY_PRICE_WITH_TAX == 'true'$order->info['shipping_cost'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
    //} // if ($GLOBALS[$module]->tax_class > 0)
    // TVA_INTRACOM REPLACE END 
    to

    PHP Code:
    // TVA_INTRACOM REPLACE BEGIN
    }
    }
    $calculated_tax zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
    if(
    $tva_tax){
    $order->info['shipping_tax'] += $calculated_tax//added to sort out group discount VAT bug
    $order->info['tax'] += $calculated_tax;
    $order->info['tax_groups']["$shipping_tax_description"] += $calculated_tax;
    $order->info['total'] += $calculated_tax;
    }
              if (
    DISPLAY_PRICE_WITH_TAX == 'true'$order->info['shipping_cost'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
    //} // if ($GLOBALS[$module]->tax_class > 0)
    // TVA_INTRACOM REPLACE END 
    I would also like to know if the following code which was in the original also needs porting across:
    PHP Code:
              $_SESSION['shipping_tax_description'] =  $shipping_tax_description;
              
    $_SESSION['shipping_tax_amount'] =  $shipping_tax_amount
    Once again I stress I have no idea what I am doing and this is all trial and error and following advice from various threads.

    Hopefully DrByte or Wilt will be along to tell me I haven't broken something or opened a gaping security hole.

    Keeps fingers crossed that a boffin will be along to check my work.

  5. #5
    Join Date
    Mar 2005
    Location
    United Kingdom
    Posts
    608
    Plugin Contributions
    0

    Default Re: Order Total wrong when Group Discount Applied

    Now amended as follows as the error returned as soon as my session timed out so I assume this is to do with my last question above.
    PHP Code:
    // TVA_INTRACOM REPLACE BEGIN
    }
    }
    $calculated_tax zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
    if(
    $tva_tax){
    $order->info['shipping_tax'] += $calculated_tax//added to sort out group discount VAT bug 
    $order->info['tax'] += $calculated_tax;
    $order->info['tax_groups']["$shipping_tax_description"] += $calculated_tax;
    $order->info['total'] += $calculated_tax;
    $_SESSION['shipping_tax_description'] =  $shipping_tax_description;
    $_SESSION['calculated_tax'] =  $calculated_tax;
    }
              if (
    DISPLAY_PRICE_WITH_TAX == 'true'$order->info['shipping_cost'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
    //} // if ($GLOBALS[$module]->tax_class > 0)
    // TVA_INTRACOM REPLACE END 
    I would still appreciate feedback so that I know I am on the right track.

 

 

Similar Threads

  1. Disable coupons and group discounts when quantity discount applied?
    By abcisme in forum Setting Up Categories, Products, Attributes
    Replies: 7
    Last Post: 12 Nov 2015, 12:31 PM
  2. v153 Sales taxes and order total wrong when group discount involved
    By apollowilcox in forum General Questions
    Replies: 8
    Last Post: 11 Feb 2015, 06:09 PM
  3. When is the group discount gets applied to the total?
    By yellow1912 in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 0
    Last Post: 21 Sep 2008, 06:29 PM
  4. v1.3.5 Group Discount Total Wrong
    By mrkrinkle in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 4
    Last Post: 4 Oct 2006, 08:06 AM
  5. Group Discount Total Wrong
    By mrkrinkle in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 1
    Last Post: 3 Oct 2006, 10:19 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