Results 1 to 6 of 6
  1. #1
    Join Date
    May 2007
    Location
    Des Moines, IA
    Posts
    19
    Plugin Contributions
    1

    red flag Taxes Calculated 2x in Order Total After Upgrading 1.3.7-1.3.8a

    I've just upgraded my site from 1.3.7 to 1.3.8a and there is a problem with the Order Total Calculation. The Order Total is calculating the taxes twice. It displays the "State Tax: (amount)" as well as a generic "Sales Tax: (amount is always zero)". (See image).

    The Tax States/Zone/Rates all seem to be configured fine and the State Tax is right, but the Order Total is too high.

    I've been looking at all the changed files in WinMerge (includes/functions/function_taxes.php, includes/modules/order_total/ot_*, etc.) and really don't know what would be causing this issue.

    Okay I actually found that by re-uploading the older order.php file into .../includes/classes/ it calculates it correctly. (It still displays the extra generic "Sales Tax: 0.00" but at least the calculations are correct.

    Is there any explanation as to why this would pull the sales tax twice for the total? Is this a bug that I couldn't find any documentation on?

    Thanks
    Attached Images Attached Images  

  2. #2
    Join Date
    May 2007
    Location
    Des Moines, IA
    Posts
    19
    Plugin Contributions
    1

    Default Re: Taxes Calculated 2x in Order Total After Upgrading 1.3.7-1.3.8a

    The section of code that deals with Taxes is below and the part in red is where I think the problem lies. Can anyone take a look and see if you can make out what might be going on here?

    Code:
          /*********************************************
           * Calculate taxes for this product
           *********************************************/
          $shown_price = (zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'])
          + zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
          $this->info['subtotal'] += $shown_price;
    
          // find product's tax rate and description
          $products_tax = $this->products[$index]['tax'];
          $products_tax_description = $this->products[$index]['tax_description'];
    
          // calculate the amount of tax "inc"luded in price (used if tax-in pricing is enabled)
          $current_row_tax_inc = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
    
          // calculate the amount of tax for this product (assuming tax is NOT included in the price)
          $current_row_tax_exc = zen_round(($products_tax / 100) * $shown_price, $currencies->currencies[$this->info['currency']]['decimal_places']);
    
        if (DISPLAY_PRICE_WITH_TAX == 'true') {
            // calculate the amount of tax "inc"luded in price (used if tax-in pricing is enabled)
            $tax_add = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
          } else {
            // calculate the amount of tax for this product (assuming tax is NOT included in the price)
            $tax_add = zen_round(($products_tax / 100) * $shown_price, $currencies->currencies[$this->info['currency']]['decimal_places']);
          }
          $this->info['tax'] += $tax_add;
          if (isset($this->info['tax_groups'][$products_tax_description])) {
            $this->info['tax_groups'][$products_tax_description] += $tax_add;
          } else {
            // this adds the tax rate for cases where tax is NOT included in the product
            $this->info['tax'] += $current_row_tax_exc;
            if (isset($this->info['tax_groups']["$products_tax_description"])) {
              $this->info['tax_groups']["$products_tax_description"] += $current_row_tax_exc;
            } else {
              $this->info['tax_groups']["$products_tax_description"] = $current_row_tax_exc;
            }
          }
          /*********************************************
           * END: Calculate taxes for this product
           *********************************************/
    Thanks

  3. #3
    Join Date
    May 2007
    Location
    Des Moines, IA
    Posts
    19
    Plugin Contributions
    1

    Default Re: Taxes Calculated 2x in Order Total After Upgrading 1.3.7-1.3.8a

    The fix to the display issue of having the "Sales Tax: $0.00" following the actual state tax was resolved by my daring to break the software (but it actually fixed it-and I don't know why I thought to look here, just some Files that showed up in the Developers Tool Kit) like this:

    I found that the "Sales Tax" definition is related to the "TEXT_UNKNOWN_TAX_RATE" using the Developers Tool Kit. Then I found it is mentioned in the file: ...includes/functions/functions_taxes.php.

    I changed the red 0 to 1 here (I was basically thinking if I could find the loop that spits out the tax rates, and shorten the loop so it goes around 1 fewer times then it might work):
    Code:
    // Return the tax description for a zone / class
    // TABLES: tax_rates;
      function zen_get_tax_description($class_id, $country_id, $zone_id) {
        global $db;
        $tax_query = "select tax_description
                      from (" . TABLE_TAX_RATES . " tr
                      left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id)
                      left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) )
                      where (za.zone_country_id is null or za.zone_country_id = 0
                      or za.zone_country_id = '" . (int)$country_id . "')
                      and (za.zone_id is null
                      or za.zone_id = 0
                      or za.zone_id = '" . (int)$zone_id . "')
                      and tr.tax_class_id = '" . (int)$class_id . "'
                      order by tr.tax_priority";
    
        $tax = $db->Execute($tax_query);
    
        if ($tax->RecordCount() > 0) {
          $tax_description = '';
          while (!$tax->EOF) {
            $tax_description .= $tax->fields['tax_description'] . ' + ';
            $tax->MoveNext();
          }
          $tax_description = substr($tax_description, 0, -3);
    
          return $tax_description;
        } else {
          return TEXT_UNKNOWN_TAX_RATE;
        }
      }

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Taxes Calculated 2x in Order Total After Upgrading 1.3.7-1.3.8a

    Is the issue you're encountering fixed with one of these? http://www.zen-cart.com/forum/showthread.php?t=82619
    or these? http://www.zen-cart.com/forum/forumdisplay.php?f=140
    .

    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.

  5. #5
    Join Date
    May 2007
    Location
    Des Moines, IA
    Posts
    19
    Plugin Contributions
    1

    Default Re: Taxes Calculated 2x in Order Total After Upgrading 1.3.7-1.3.8a

    I've looked through these links and I don't think it is connected to anything there. I actually looked a long time before posting as it is imperative to have this function properly for our store, and generally someone else has discovered issues like this before me.

    More about my case:
    Before doing the upgrade I did the security patch for the Admin, and have had my Admin area renamed for quite some time now.

    In addition I followed the directions to a 'T' on the upgrade, using WinMerge (for the first time) to check for changes. I do have some customizations including:

    For checkout related mods, I have a the "Low Order Fee" and "Coupons" enabled, but I've tested with them turned on and off and they don't seem to be causing any issues either way.

    I use only FedEx Ground and Express for shipping and they seem to be okay. They added correctly into the Total amount when I turned off the ot_tax module. (now it's all working okay)

    And I use PayPal Express and Google Checkout along with the Net1 module for accepting credit cards on the site which all appear to be working okay. I removed PayPal Express and re-installed it after uploading the files and performing the database upgrade as described in the documentation.

    Other Mods which seem okay:
    Google Base Feeder
    Google XML sitemaps
    Monthly Sales Report

    Other Mods that got broke:
    FedEx Automated Labels - that's okay b/c I wasn't using it.
    FedEx Product Dimensional Mod - but again I wasn't using it.
    SEO URL's - which I've turned off because it wouldn't allow the checkout process to complete with it on after the upgrade. (I can live with long url's for a while, so I'll look into this more later)

    Server Info:
    Linux CentOS 2.6.18
    Apache 2.0.63
    MySQL 4.1.20
    PHP 5.2.13 (Zend 2.2.0)


    Thanks!

  6. #6
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Taxes Calculated 2x in Order Total After Upgrading 1.3.7-1.3.8a

    The acid test:

    1. Set up a BRAND NEW, clean install of (in your case) v1.3.8a on a test folder+database, or a separate server/site. This is SEPARATE from your LIVE site.
    Install the Demo Products as part of the installation process.
    2. Using the demo products, or manually adding a test product, attempt to replicate the problem there, WITHOUT ANY ADDONS OR CUSTOMIZATIONS.

    If you can consistently recreate the problem on the new test site, then report back ALL the EXACT steps (including all settings you've changed) so one of the developers can follow those instructions to recreate the problem on *their* test sites.
    Without that information, it's extremely difficult to help you.

    If you can't consistently recreate the problem on a clean install, then the problem is generally something wrong with either your settings, or your customizations, or your addons, or in the case of an upgrade, missed files during the upgrade.


    Also remember, when upgrading, you have to also upgrade all the files in all your override folders too.
    .

    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.

 

 

Similar Threads

  1. v154 After upgrading to 1.5.4, no sales taxes are being charged in the cart.
    By delia in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 2
    Last Post: 23 Apr 2015, 03:06 PM
  2. Taxes in Order Total
    By GG01 in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 0
    Last Post: 25 Apr 2010, 03:28 AM
  3. Order Total and Taxes inaccurate with Discount Coupon
    By Luna in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 0
    Last Post: 6 Mar 2009, 08:20 AM
  4. how to add an attribute to the total after shipping is calculated
    By beedie in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 21 Oct 2008, 03:50 PM
  5. Replies: 2
    Last Post: 9 Feb 2007, 08:49 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