Splitter Test written. Doesn't pass.
[order_line_extra.git] / haxe / Location.hx
index 50f2807e6f407623e227d922a559d87c052ce567..f6cbccd5176934d59c11e6997fe7b44fe092ba30 100644 (file)
@@ -21,6 +21,26 @@ class Location {
                delivery = config_date != null ? Date.fromString(config_date) : null;
        }
 
+       public function quantityOnOrder(stock_id) : Int {
+               var TB = FA.tb();
+               var sql = 'SELECT SUM(quantity_ordered - quantity_received) as quantity
+                       FROM '+TB+'purch_order_details
+                       NATURAL JOIN '+TB+'purch_orders
+                       WHERE item_code = "'+stock_id+'" AND  into_stock_location = "'+code+'"
+                       AND quantity_ordered > quantity_received
+                       ORDER by delivery_date' ;
+
+                       var result = FA.query(sql);
+                       if(result.hasNext()) {
+                                       var row = php.Lib.objectOfAssociativeArray(result.next());
+                                       return row.quantity;
+                       }
+                       else {
+                               return 0;
+                       }
+
+       }
+
        public function quantityOnHand(stock_id, date) : Null<Int> {
                if(qoh_cache == null || stock_id != stock_id_cache) {
                        qoh_cache =  untyped __call__('get_qoh_on_date', stock_id,  code, date);