Minor bugs in deleting fiscal years. Apmuthu.
[fa-stable.git] / purchasing / includes / po_class.inc
index 2324d25dbd6c70c2d73a0249b7244b0c738d868b..dff291a7c16bfc5ef8b70c5716582b3d9733c08a 100644 (file)
@@ -33,8 +33,10 @@ class purch_order
        var $tax_group_array = null; // saves db queries
        var $tax_included; // type of prices
        var $terms;
-       
+       var $ex_rate;
+
        var $reference;
+       var $tax_overrides = array();           // array of taxes manually inserted during sales invoice entry (direct invoice)
        
        function purch_order()
        {
@@ -55,7 +57,7 @@ class purch_order
        
        function add_to_order($line_no, $stock_id, $qty, $item_descr, $price, $uom, $req_del_date, $qty_inv, $qty_recd)
        {
-               if ($qty != 0 && isset($qty))
+               if (isset($qty) && $qty != 0)
                {
                        $this->line_items[$line_no] = new po_line_details($line_no, $stock_id, $item_descr, $qty, $price, $uom, 
                                $req_del_date, $qty_inv, $qty_recd);
@@ -148,7 +150,11 @@ class purch_order
                        $val = $taxes['1']['Value'];
                        $val1 = (floatval((intval(round(($val*20),0)))/20));
                        $taxes['1']['Value'] = $val1;
-               } 
+               }
+               foreach($this->tax_overrides as $id => $value) // add values entered manually
+               {
+                       $taxes[$id]['Override'] = $value;
+               }
                return $taxes;
        }
 
@@ -230,6 +236,22 @@ class po_line_details
                $this->standard_cost =0;
                $this->grn_item_id = $grn_item_id;
        }
+
+       // Deprecated, use with care. If you need line value as it is calculated in invoice, use taxfree_charge_value below.
+       function taxfree_charge_price($po)
+       {
+               return get_tax_free_price_for_item($this->stock_id, $this->price,
+                 $po->tax_group_id, $po->tax_included, $po->tax_group_array);
+       }
+
+       //
+       // GRN line tax free value.
+       //
+       function taxfree_charge_value($po)
+       {
+               return get_tax_free_price_for_item($this->stock_id, $this->receive_qty*$this->price,
+                 $po->tax_group_id, $po->tax_included, $po->tax_group_array);
+       }
 }
 
 ?>