Tax included calculation problem when more than 1 tax type in a group
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 24 Feb 2010 09:34:32 +0000 (09:34 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 24 Feb 2010 09:34:32 +0000 (09:34 +0000)
Small layout fixes

CHANGELOG.txt
admin/backups.php
reporting/rep107.php
reporting/rep110.php
taxes/tax_calc.inc

index 26b8882ab143c0714c962a4d67de13ddb2f31b1d..408d9cf82971ee51df269828169a1c2992ca4495 100644 (file)
@@ -19,6 +19,14 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+24-Feb-2010 Joe Hunt
+# Tax included calculation problem when more than 1 tax type in a group
+$ /taxes/tax_calc.inc
+! Small layout fixes
+$ /admin/backups.php
+  /reporting/rep107.php
+  /reporting/rep110.php
+  
 21-Feb-2010 Joe Hunt
 # Exchange rate doesn't update table immediately when adding new rate 
   and no exchange rates there before.
index 4bf99a4207a82c558ee02fb332ece51e98b67b00..9f6efa55a9a41c7f51ec9d96e8743b0973184de7 100644 (file)
@@ -99,7 +99,7 @@ function compress_list_row($label, $name, $value=null)
     if (function_exists("gzopen"))
        $ar_comps['gzip'] = "gzip";
 
-       echo "<tr><td>$label</td><td>";
+       echo "<tr><td class='label'>$label</td><td>";
        echo array_selector('comp', $value, $ar_comps);
        echo "</td></tr>";
 }
index e3bd2065207de7463d6ea976ae327143362d651c..e9df284d6d63eb519c40e410d05787ce6d925886 100644 (file)
@@ -179,7 +179,7 @@ function print_invoices()
                        if ($tax_item['included_in_price'])
                        {
                                        $rep->TextCol(3, 7, $doc_Included . " " . $tax_item['tax_type_name'] .
-                                               " (" . $tax_item['rate'] . "%) " . $doc_Amount . ":" . $DisplayTax, -2);
+                                               " (" . $tax_item['rate'] . "%) " . $doc_Amount . ": " . $DisplayTax, -2);
                                }
                        else
                        {
index 3116978072c9c6c8fdb80dd29ba6ee6291423d01..9f418f7c712746a3e8b0aff0b725259638a3e5b3 100644 (file)
@@ -174,7 +174,7 @@ function print_deliveries()
                                if ($tax_item['included_in_price'])
                                {
                                                $rep->TextCol(3, 7, $doc_Included . " " . $tax_item['tax_type_name'] .
-                                                       " (" . $tax_item['rate'] . "%) " . $doc_Amount . ":" . $DisplayTax, -2);
+                                                       " (" . $tax_item['rate'] . "%) " . $doc_Amount . ": " . $DisplayTax, -2);
                                        }
                                else
                                {
index db98540842b321e134efa61fca56db60725c3a7c..f0be73231fcf1fb5e8d8def1ebfcb0dc545ec898 100644 (file)
@@ -162,13 +162,10 @@ function get_tax_for_items($items, $prices, $shipping_cost, $tax_group, $tax_inc
                        {
                                $index = $item_tax['tax_type_id'];
                                if($tax_included==1) {// 2008-11-26 Joe Hunt Taxes are stored without roundings
-                                 //$ret_tax_array[$index]['Value'] += round($prices[$i] * $item_tax['rate'] 
-                                 //    / ($item_tax['rate'] + 100),  user_price_dec());
-                                 $ret_tax_array[$index]['Value'] += ($prices[$i] * $item_tax['rate'] / ($item_tax['rate'] + 100));
-                                 $ret_tax_array[$index]['Net'] += ($prices[$i] * 100 / ($item_tax['rate'] + 100));
+                                 $nprice = get_tax_free_price_for_item($items[$i], $prices[$i], $tax_group, $tax_included);
+                                 $ret_tax_array[$index]['Value'] += ($nprice * $item_tax['rate'] / 100);
+                                 $ret_tax_array[$index]['Net'] += $nprice;
                                } else {
-                                 //$ret_tax_array[$index]['Value'] += 
-                                 //    round($prices[$i] * $item_tax['rate'] / 100,  user_price_dec());
                                  $ret_tax_array[$index]['Value'] += ($prices[$i] * $item_tax['rate'] / 100);
                                  $ret_tax_array[$index]['Net'] += $prices[$i];
                                }
@@ -182,18 +179,26 @@ function get_tax_for_items($items, $prices, $shipping_cost, $tax_group, $tax_inc
                $item_taxes = get_shipping_tax_as_array();
                if ($item_taxes != null) 
                {
+                       if ($tax_included == 1)
+                       {
+                               $tax_rate = 0;
+                               foreach ($item_taxes as $item_tax)
+                               {
+                                       $index = $item_tax['tax_type_id'];
+                                       if(isset($ret_tax_array[$index])) {
+                                               $tax_rate += $item_tax['rate'];
+                                       }
+                               }
+                               $shipping_net = round2($shipping_cost / (1 + ($tax_rate / 100)), user_price_dec());
+                       }       
                        foreach ($item_taxes as $item_tax) 
                        {
                                $index = $item_tax['tax_type_id'];
                                if(isset($ret_tax_array[$index])) {
                                  if($tax_included==1) {// 2008-11-26 Joe Hunt Taxes are stored without roundings
-                                       //$ret_tax_array[$index]['Value'] += round($shipping_cost * $item_tax['rate'] 
-                                       //  / ($item_tax['rate'] + 100),  user_price_dec());
-                                       $ret_tax_array[$index]['Value'] += ($shipping_cost * $item_tax['rate'] / ($item_tax['rate'] + 100));
-                                   $ret_tax_array[$index]['Net'] += ($shipping_cost * 100 / ($item_tax['rate'] + 100));
+                                       $ret_tax_array[$index]['Value'] += ($shipping_net * $item_tax['rate'] / 100);
+                                   $ret_tax_array[$index]['Net'] += $shipping_net;
                                  } else {
-                                       //$ret_tax_array[$index]['Value'] += 
-                                       //  round($shipping_cost * $item_tax['rate'] / 100,  user_price_dec());
                                        $ret_tax_array[$index]['Value'] += ($shipping_cost * $item_tax['rate'] / 100);
                                    $ret_tax_array[$index]['Net'] += $shipping_cost;
                                 }