Commit 289a6e59 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Klaus Wölfel

builder: Supply builder check date movement before integrating it

parent 4d8ca027
......@@ -453,12 +453,6 @@ class BuilderMixin(XMLObject, Amount, Predicate):
# Prepare period_list
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 = []
last_date = getPreviousValidDate(history_list[-1][0])
while limit_date <= last_date:
......@@ -468,6 +462,13 @@ class BuilderMixin(XMLObject, Amount, Predicate):
# Hackish and dangerous
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
factor = supply.getMinFlow()
next_period_history_list = []
......@@ -485,7 +486,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
next_next_period_start_date == next_period_start_date:
period_history_list = next_period_history_list[:]
while history_list and history_list[0][0] < next_period_start_date:
period_history_list.append(history_list.pop(0))
if history_list[0][0] < period_start_date:
history_list.pop(0)
else:
period_history_list.append(history_list.pop(0))
# Using period history list calculate min stock
# In this iteration we verify that the invetory is always superior
......
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