From d1971f77141450ae4d39c688b8fc9af373b35c64 Mon Sep 17 00:00:00 2001 From: bMancone Date: Wed, 19 Oct 2011 16:33:34 +0000 Subject: [PATCH] // StockManager: added test for time_left in getProductCoverage() --- classes/stock/StockManager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/stock/StockManager.php b/classes/stock/StockManager.php index 012db721d..e79229ee7 100644 --- a/classes/stock/StockManager.php +++ b/classes/stock/StockManager.php @@ -482,6 +482,9 @@ class StockManagerCore implements StockManagerInterface if (!$id_product_attribute) $id_product_attribute = 0; + if ($coverage == 0 || !$coverage) + $coverage = 7; // Week by default + // gets all stock_mvt for the given coverage period $query = ' SELECT SUM(sm.`physical_quantity`) as quantity_out @@ -504,7 +507,8 @@ class StockManagerCore implements StockManagerInterface $id_product_attribute, ($id_warehouse ? array($id_warehouse) : null), true); - $time_left = round($physical_quantity / $quantity_per_day); + + $time_left = ($quantity_per_day == 0) ? 365 : round($physical_quantity / $quantity_per_day); return $time_left; }