7 public var code : String;
8 public var name : String;
9 public var comment : String;
10 public var delivery: Date;
12 private var qoh_cache : Int;
13 private var stock_id_cache : String;
15 public function new(row : Dynamic) {
16 var obj = php.Lib.objectOfAssociativeArray(row);
18 name = obj.location_name;
19 comment = obj.delivery_address;
20 var config_date = untyped __call__('OrderXtraConfig::delivery', code);
21 delivery = config_date != null ? Date.fromString(config_date) : null;
24 public function quantityOnOrder(stock_id) : Int {
26 var sql = 'SELECT SUM(quantity_ordered - quantity_received) as quantity
27 FROM '+TB+'purch_order_details
28 NATURAL JOIN '+TB+'purch_orders
29 WHERE item_code = "'+stock_id+'" AND into_stock_location = "'+code+'"
30 AND quantity_ordered > quantity_received
31 ORDER by delivery_date' ;
33 var result = FA.query(sql);
34 if(result.hasNext()) {
35 var row = php.Lib.objectOfAssociativeArray(result.next());
44 public function quantityOnHand(stock_id, date) : Null<Int> {
45 if(qoh_cache == null || stock_id != stock_id_cache) {
46 qoh_cache = untyped __call__('get_qoh_on_date', stock_id, code, date);
47 stock_id_cache = stock_id;