PHP7 compatibility fixes.
[fa-stable.git] / purchasing / includes / supp_trans_class.inc
index 547d833e3012f0031f8b394649019cdfe9e36667..8a70e41488f47b4565511838be523cf5f42c8fe4 100644 (file)
@@ -43,12 +43,13 @@ class supp_trans
        var $ov_gst;
        var $gl_codes_counter=0;
        var $credit = 0;
-       var $tax_algorithm;
-       var $stored_algorithm;
        var $currency;
        var $tax_overrides = array();           // array of taxes manually inserted during sales invoice entry
 
-       function supp_trans($trans_type, $trans_no=0)
+       var $dimension,
+               $dimension2;
+
+       function __construct($trans_type, $trans_no=0)
        {
                $this->trans_type = $trans_type;
                /*Constructor function initialises a new Supplier Transaction object */
@@ -142,25 +143,29 @@ class supp_trans
         if ($tax_group_id == null)
                $tax_group_id = $this->tax_group_id;
         $taxes = get_tax_for_items($items, $prices, $shipping_cost, $tax_group_id, 
-               $this->tax_included, null, $this->tax_algorithm);
+               $this->tax_included);
+
+               if (isset($this->tax_overrides))
+                       foreach($this->tax_overrides as $id => $value) // add values entered manually
+                       {
+                               $taxes[$id]['Override'] = $value;
+                       }
 
-               if ($gl_codes)
+               // Taxes included in gl_codes table have exact value, but count to overrides as well.
+               // Therefore when we want to now taxes only for items (gl_codes==false),
+               // we have to subtract gl_taxes from override values.
+               foreach ($this->gl_codes as $gl_code)
                {
-                       foreach ($this->gl_codes as $gl_code)
+                       $index = is_tax_account($gl_code->gl_code);
+                       if ($index !== false)
                        {
-                               $index = is_tax_account($gl_code->gl_code);
-                               if ($index !== false)
-                               {
+                               if ($gl_codes)
                                        $taxes[$index]['Value'] += $gl_code->amount;
-                               }
+                               elseif (isset($this->tax_overrides))
+                                       $taxes[$index]['Override'] -= $gl_code->amount;
                        }
                }
 
-               if(isset($this->tax_overrides))
-                       foreach($this->tax_overrides as $id => $value) // add values entered manually
-                       {
-                               $taxes[$id]['Override'] = $value;
-                       }
         return $taxes;
     }
        //
@@ -225,7 +230,7 @@ all the info to do the necessary entries without looking up ie additional querie
        var $gl_code;
        var $tax_included;
 
-       function grn_item ($id, $po_detail_item, $item_code, $item_description, $qty_recd, 
+       function __construct($id, $po_detail_item, $item_code, $item_description, $qty_recd, 
                $prev_quantity_inv, $this_quantity_inv, $order_price, $chg_price,
                $std_cost_unit, $gl_code, $tax_included)
        {
@@ -269,7 +274,7 @@ class gl_codes
        var $amount;
        var $memo_;
 
-       function gl_codes ($Counter, $gl_code, $gl_act_name, $gl_dim, $gl_dim2, $amount, $memo_)
+       function __construct($Counter, $gl_code, $gl_act_name, $gl_dim, $gl_dim2, $amount, $memo_)
        {
 
        /* Constructor function to add a new gl_codes object with passed params */
@@ -283,4 +288,3 @@ class gl_codes
        }
 }
 
-?>