Commit a2c89713 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Titouan Soulard

builder: Supply builder check date movement before integrating it

parent 31a57069
...@@ -453,12 +453,6 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -453,12 +453,6 @@ class BuilderMixin(XMLObject, Amount, Predicate):
# Prepare period_list # Prepare period_list
limit_date = getPreviousValidDate(getPreviousValidDate(from_date) - 0.1) limit_date = getPreviousValidDate(getPreviousValidDate(from_date) - 0.1)
# evaluate future inventory at date
future_inventory_to_date = portal.portal_simulation.getFutureInventory(
to_date=limit_date,
resource_uid=resource_value.getUid(),
node_uid=supply.getDestinationUid(),
)
limit_date_list = [] limit_date_list = []
last_date = getPreviousValidDate(history_list[-1][0]) last_date = getPreviousValidDate(history_list[-1][0])
while limit_date <= last_date: while limit_date <= last_date:
...@@ -468,6 +462,13 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -468,6 +462,13 @@ class BuilderMixin(XMLObject, Amount, Predicate):
# Hackish and dangerous # Hackish and dangerous
next_start_date=limit_date)).earliestTime() next_start_date=limit_date)).earliestTime()
# evaluate future inventory at date
future_inventory_to_date = portal.portal_simulation.getFutureInventory(
to_date=limit_date_list[0],
resource_uid=resource_value.getUid(),
node_uid=supply.getDestinationUid(),
)
min_stock_value = supply.getMinOrderQuantity() / default_quantity_unit_flow_quantity_unit_conversion_ratio min_stock_value = supply.getMinOrderQuantity() / default_quantity_unit_flow_quantity_unit_conversion_ratio
factor = supply.getMinFlow() factor = supply.getMinFlow()
next_period_history_list = [] next_period_history_list = []
...@@ -485,6 +486,9 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -485,6 +486,9 @@ class BuilderMixin(XMLObject, Amount, Predicate):
next_next_period_start_date == next_period_start_date: next_next_period_start_date == next_period_start_date:
period_history_list = next_period_history_list[:] period_history_list = next_period_history_list[:]
while history_list and history_list[0][0] < next_period_start_date: while history_list and history_list[0][0] < next_period_start_date:
if history_list[0][0] < period_start_date:
history_list.pop(0)
else:
period_history_list.append(history_list.pop(0)) period_history_list.append(history_list.pop(0))
# Using period history list calculate min stock # Using period history list calculate min stock
......
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