Results 1 to 10 of 11

Hybrid View

  1. #1
    Join Date
    Nov 2011
    Posts
    34
    Plugin Contributions
    1

    Default [Fixed v1.5.1] compounding or multiple tax problem

    hi,
    i can't get compounding or multiple taxes to work properly in zen cart 1.5. But it work perfectly in 1.39h.

    So i created 2 fresh installations of both zen cart 1.39 and 1.5

    For both shops:
    The shops location is Alabama.
    The customers are from California.
    I have made 2 zone definitions (world and California).
    For Tax Classes i have only "Taxable Goods".
    I have made 2 tax rates (world 20% and California 15%).

    when I tested it on 1.39 it works perfectly:

    Sub-Total: $32.00
    Free Shipping Options (Free Shipping): $0.00
    tax 20: $6.40
    CA tax15: $4.80
    Total: $43.20

    But on 1.5 i get:

    Sub-Total: $32.00
    Free Shipping Discount Options (Free Shipping): $0.00
    CA tax15: $0.00
    tax 20: $0.00
    Total: $32.00

    After spending hours with different settings and searching on the forums, i couldn't find anything for this on it.

    But i managed to get a work around. If you open includes/classes/order.php and uncomment the if statement on line 523:

    //if ($taxDescription == $products_tax_description)...

    and replace:

    Code:
                  $taxAdd = zen_calculate_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty']
                          +  zen_round(zen_calculate_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']), $decimals);
    with this taken from v1.39:

    Code:
            $taxAdd = zen_calculate_tax($this->products[$index]['final_price']*$this->products[$index]['qty'], $taxRate)
                    +  zen_calculate_tax($this->products[$index]['onetime_charges'], $taxRate);
    then everything seems to work well.

    The reason i uncommented the IF statement ($taxDescription == $products_tax_description) was that the loop would fail every time when:

    "CA tax15" == "CA tax15 + tax 20"
    and
    "tax 20" == "CA tax15 + tax 20"

    But i'm not sure this is the right way to go about doing this! Is this a bug or am i doing something wrong???

    thanks in advance.

  2. #2
    Join Date
    Nov 2011
    Posts
    34
    Plugin Contributions
    1

    Default Re: compounding or multiple tax problem

    Anyone??

    I'm sure i'm doing something wrong! or has compounding tax been removed from v1.5?

  3. #3
    Join Date
    Nov 2011
    Posts
    34
    Plugin Contributions
    1

    Default Re: compounding or multiple tax problem

    Ok.

    I assume this is a bug in v1.5 off zen cart. Anyways i have created a fix for it with explanation in the code, if anyone can verify this then that would be great, if not then no problem:

    replace the code in includes/classes/order.php
    between the lines 508-546:

    Code:
          /*********************************************
           * Calculate taxes for this product
           *********************************************/
          $shown_price = zen_round(zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) ,$decimals) * $this->products[$index]['qty'];
          $shown_price +=  zen_round(zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']), $decimals);
    
          $this->notify('NOTIFIY_ORDER_CART_SUBTOTAL_CALCULATE', array('shown_price'=>$shown_price));
          // find product's tax rate and description
          $products_tax = $this->products[$index]['tax'];
          $products_tax_description = $this->products[$index]['tax_description'];
          $this->info['subtotal'] += $shown_price;
          $totalTaxAdd = 0;
          foreach ($taxRates as $taxDescription=>$taxRate)
          {
            $taxAdd = 0;
            if ($taxDescription == $products_tax_description)
            {
              if (DISPLAY_PRICE_WITH_TAX == 'true')
              {
                $taxAdd = zen_round($shown_price / (100 + $this->products[$index]['tax']) * $this->products[$index]['tax'], $decimals);
              } else
              {
                  $taxAdd = zen_calculate_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];
                          +  zen_round(zen_calculate_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']), $decimals);
              }
              if (isset($this->info['tax_groups'][$taxDescription]))
              {
                $this->info['tax_groups'][$taxDescription] += $taxAdd;
              } else
              {
                $this->info['tax_groups'][$taxDescription] = $taxAdd;
              }
            }
            $totalTaxAdd += $taxAdd;
          }
          $this->info['tax'] += $totalTaxAdd;
          /*********************************************
           * END: Calculate taxes for this product
           *********************************************/

    with this code:

    Code:
          /*********************************************
           * Calculate taxes for this product
           *********************************************/
    	   
          $shown_price = zen_round(zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) ,$decimals) * $this->products[$index]['qty'];
          $shown_price +=  zen_round(zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']), $decimals);
    
          $this->notify('NOTIFIY_ORDER_CART_SUBTOTAL_CALCULATE', array('shown_price'=>$shown_price));
          // find product's tax rate and description
          $products_tax = $this->products[$index]['tax'];
    	  
    	  //not required
          $products_tax_description = $this->products[$index]['tax_description'];
    	  
          $this->info['subtotal'] += $shown_price;
          $totalTaxAdd = 0;
    
          foreach ($taxRates as $taxDescription=>$taxRate)
          {
            $taxAdd = 0;
    		
            if ($taxDescription <> '0') //since $taxRates = zen_get_multiple_tax_rates(..), and the zen_get_multiple_tax_rates function sets 
    									//rate to 0 and description to unknown for no tax.
    									//therefore we can ignore when $taxRate = 0.
            {
              if (DISPLAY_PRICE_WITH_TAX == 'true')
              {
    			//Get the original price without the tax then clculate tax rate
    			$preTax_Price = $shown_price / (($this->products[$index]['tax']/100) + 1);
    			$taxAdd = zen_calculate_tax($preTax_Price, $taxRate);
    			
              } else
              {
    			  // replace $this->products[$index]['tax'] with $taxRate since $this->products[$index]['tax'] is the combined tax rate for multi tax (either summed or compounded)
    			  // and $taxRate is the tax rate for each individual tax.
                  $taxAdd = zen_calculate_tax($this->products[$index]['final_price']+$this->products[$index]['onetime_charges'], $taxRate) * $this->products[$index]['qty'];
              }
    		   
              if (isset($this->info['tax_groups'][$taxDescription]))
              {
                $this->info['tax_groups'][$taxDescription] += $taxAdd;
              } else
              {
                $this->info['tax_groups'][$taxDescription] = $taxAdd;
              }
            }
            $totalTaxAdd += $taxAdd;
          }
    	  //unset($taxRate) so it can not be used in the next round
    	  unset($taxRate);
          $this->info['tax'] += $totalTaxAdd;
          /*********************************************
           * END: Calculate taxes for this product
           *********************************************/

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

    Default Re: compounding or multiple tax problem

    Hi,

    Thanks for the report, and the fix.

    While we can confirm that there is a problem with compound taxes, we are still looking at the best way to fix this, given the initial changes (which you've removed) were meant to fix some rounding problems that we don't want to re-introduce as well.

  5. #5
    Join Date
    Nov 2011
    Posts
    34
    Plugin Contributions
    1

    Default Re: compounding or multiple tax problem

    Hi wilt,

    thanks for reply.

    Just an update on the fix i gave, i tested code with data from excel spreed sheets, and both gave similar result, there was only a difference in values after the 3rd decimal place. however i ran into problems when i added a "one time charge" to a product, thats because i included the onetimecharge with the product price, when they should of been separate, anyways here's a temporary fix for the temporary fix:

    Code:
    /*********************************************
           * Calculate taxes for this product
           *********************************************/
    	   
          $shown_price = zen_round(zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) ,$decimals) * $this->products[$index]['qty'];
          $shown_price +=  zen_round(zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']), $decimals);
    
          $this->notify('NOTIFIY_ORDER_CART_SUBTOTAL_CALCULATE', array('shown_price'=>$shown_price));
          // find product's tax rate and description
          $products_tax = $this->products[$index]['tax'];
    	  
    	  //not required
          $products_tax_description = $this->products[$index]['tax_description'];
    	  
          $this->info['subtotal'] += $shown_price;
          $totalTaxAdd = 0;
    
          foreach ($taxRates as $taxDescription=>$taxRate)
          {
            $taxAdd = 0;
    		
            if ($taxDescription <> '0') //since $taxRates = zen_get_multiple_tax_rates(..), and the zen_get_multiple_tax_rates function sets 
    									//rate to 0 and description to unknown for no tax.
    									//therefore we can ignore when $taxRate = 0.
            {
              if (DISPLAY_PRICE_WITH_TAX == 'true')
              {
    			//Get the original price without the tax then clculate tax rate
    			$preTax_Price = $shown_price / (($this->products[$index]['tax']/100) + 1);
    			$taxAdd = zen_calculate_tax($preTax_Price, $taxRate);
    			
              } else
              {
    			  // replace $this->products[$index]['tax'] with $taxRate since $this->products[$index]['tax'] is the combined tax rate for multi tax (either summed or compounded)
    			  // and $taxRate is the tax rate for each individual tax.
                  $taxAdd = zen_calculate_tax($this->products[$index]['final_price'], $taxRate) * $this->products[$index]['qty']
                  + zen_calculate_tax($this->products[$index]['onetime_charges'], $taxRate);
              }
    		   
              if (isset($this->info['tax_groups'][$taxDescription]))
              {
                $this->info['tax_groups'][$taxDescription] += $taxAdd;
              } else
              {
                $this->info['tax_groups'][$taxDescription] = $taxAdd;
              }
            }
            $totalTaxAdd += $taxAdd;
          }
    	  //unset($taxRate) so it can not be used in the next round
    	  unset($taxRate);
          $this->info['tax'] += $totalTaxAdd;
          /*********************************************
           * END: Calculate taxes for this product
           *********************************************/

  6. #6
    Join Date
    Jun 2003
    Posts
    33,715
    Plugin Contributions
    0

    Default Re: compounding or multiple tax problem

    Are you using the tax system to collect some other fee?
    I ask because the US doesn't collect taxes for more than one state like you are doing.
    Please do not PM for support issues: a private solution doesn't benefit the community.

    Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

 

 

Similar Threads

  1. Compounding state tax
    By mark8261 in forum General Questions
    Replies: 4
    Last Post: 8 Mar 2015, 07:28 PM
  2. Replies: 0
    Last Post: 29 Sep 2012, 09:05 AM
  3. Compounding Tax Problem
    By notset4life in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 3
    Last Post: 26 Jul 2007, 03:56 PM
  4. FIXED Muliple Quantities at FIXED Prices per Multiple Quantity???
    By awarrior in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 4 Apr 2007, 09:42 PM
  5. Compounding Local Tax to Zone Tax
    By LadyHLG in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 8
    Last Post: 14 Sep 2006, 08:25 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