Commit c59faa44 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

SimulationTool: getNextAlertInventoryDate can look for the lowest invetory...

SimulationTool: getNextAlertInventoryDate can look for the lowest invetory inferior to the reference quantity
parent 783bd5ab
...@@ -2032,6 +2032,7 @@ class SimulationTool(BaseTool): ...@@ -2032,6 +2032,7 @@ class SimulationTool(BaseTool):
range='min', range='min',
initial_inventory_kw=None, initial_inventory_kw=None,
inventory_list_kw=None, inventory_list_kw=None,
look_for_minimal=False,
**kw): **kw):
""" """
Give the next date where the quantity is lower than the Give the next date where the quantity is lower than the
...@@ -2046,6 +2047,8 @@ class SimulationTool(BaseTool): ...@@ -2046,6 +2047,8 @@ class SimulationTool(BaseTool):
inventory_list_kw - additional parameters for looking at next movements inventory_list_kw - additional parameters for looking at next movements
(exemple: use omit_output) (exemple: use omit_output)
look_for_minimal - Return the date when the inventory is the lowest
""" """
result = None result = None
# First look at current inventory, we might have already an inventory # First look at current inventory, we might have already an inventory
...@@ -2070,7 +2073,7 @@ class SimulationTool(BaseTool): ...@@ -2070,7 +2073,7 @@ class SimulationTool(BaseTool):
inventory_method = getattr(self, "get%sInventory" % simulation_period) inventory_method = getattr(self, "get%sInventory" % simulation_period)
initial_inventory = inventory_method(at_date=from_date, initial_inventory = inventory_method(at_date=from_date,
**getAugmentedInventoryKeyword(initial_inventory_kw)) **getAugmentedInventoryKeyword(initial_inventory_kw))
if checkQuantity(initial_inventory): if checkQuantity(initial_inventory) and not look_for_minimal:
result = from_date result = from_date
else: else:
inventory_list_method = getattr(self, inventory_list_method = getattr(self,
...@@ -2086,7 +2089,11 @@ class SimulationTool(BaseTool): ...@@ -2086,7 +2089,11 @@ class SimulationTool(BaseTool):
total_inventory += inventory['inventory'] total_inventory += inventory['inventory']
if checkQuantity(total_inventory): if checkQuantity(total_inventory):
result = inventory['date'] result = inventory['date']
break if look_for_minimal:
reference_quantity = total_inventory
checkQuantity = getCheckQuantityMethod()
else:
break
return result return result
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment