while(0 >= left && locationIter.hasNext()) {
location = locationIter.next();
- var quantityForLocation : Int = location.quantityOnHand(stock_id, null);
+ var quantityForLocation : Int = location.quantityOnHand(stock_id, null) + location.quantityOnOrder(stock_id);
if(quantityForLocation == null || quantityForLocation == 0 || location.delivery == null) continue;
left += quantityForLocation;
formatLocation(location, "Delivery", left);
function purcharseOrders() {
+ var TB = FA.tb();
+ var sql = 'SELECT SUM(quantity_ordered - quantity_received) as quantity
+ into_stock_location AS location
+ FROM '+TB+'purch_order_details
+ NATURAL JOIN '+TB+'purch_orders
+ WHERE item_code = "'+this.stock_id+'"
+ AND quantity_ordered > quantity_received
+ GROUP by item_code,delivery_date, into_stock_location
+ ORDER by delivery_date' ;
+
+ return FA.query(sql);
}
public function needsUpdate():Bool {