From 1c8c68e17bae9ed29cc854ded5a611be0ebd2130 Mon Sep 17 00:00:00 2001 From: Maxime Bourget Date: Thu, 30 May 2013 16:21:26 +0100 Subject: [PATCH] Cache Location.getQuantityOnHand --- haxe/Location.hx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/haxe/Location.hx b/haxe/Location.hx index 7cf82bd..b5a529d 100644 --- a/haxe/Location.hx +++ b/haxe/Location.hx @@ -9,6 +9,9 @@ class Location { public var comment : String; 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; @@ -17,7 +20,11 @@ class Location { delivery = Date.fromString("2013-06-10"); } - public function quantityOnHand(stock_id, date) : Int { - return untyped __call__('get_qoh_on_date', stock_id, code, date); + public function quantityOnHand(stock_id, date) : Null { + 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; } } -- 2.30.2