Merge branch 'add_jquery_sortable'
[order_line_extra.git] / haxe / Location.hx
index 5390eb50c5cf8c108e1b79fbd5ae3f21ebdddd6d..b5a529d49e5b1232fb8d8aa81108e345a2ecaf7e 100644 (file)
@@ -7,16 +7,24 @@ class Location {
        public var code : String;
        public var name : String;
        public var comment : String;
-       public var qoh : Int;
+       public var delivery: Date;
+
+       private var qoh_cache : Int;
+       private var stock_id_cache : String;
 
        public function new(row : Dynamic) {
                var obj = php.Lib.objectOfAssociativeArray(row);
                code = obj.loc_code;
                name = obj.location_name;
                comment = obj.delivery_address;
+               delivery = Date.fromString("2013-06-10");
        }
 
-       private function quantityOnHand(stock_id, date) {
-               return untyped __call__('get_qoh_on_date', stock_id,  code, date);
+       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);
+                       stock_id_cache = stock_id;
+               }
+               return qoh_cache;
        }
 }