Commit 31e63f1b authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

builder: Reach workable calculation

parent ba0e917e
...@@ -450,7 +450,7 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -450,7 +450,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
) )
# Prepare period_list # Prepare period_list
limit_date = getPreviousValidDate(from_date) limit_date = getPreviousValidDate(getPreviousValidDate(from_date) - 0.1)
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:
...@@ -460,6 +460,9 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -460,6 +460,9 @@ class BuilderMixin(XMLObject, Amount, Predicate):
# Hackish and dangerous # Hackish and dangerous
next_start_date=limit_date)).earliestTime() next_start_date=limit_date)).earliestTime()
min_stock_value = supply.getMinOrderQuantity() / default_quantity_unit_flow_quantity_unit_conversion_ratio
factor = supply.getMinFlow()
next_period_history_list = []
#self.log(limit_date_list) #self.log(limit_date_list)
# Create a movement per period # Create a movement per period
for period_start_date in limit_date_list: for period_start_date in limit_date_list:
...@@ -470,16 +473,46 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -470,16 +473,46 @@ class BuilderMixin(XMLObject, Amount, Predicate):
next_start_date=period_start_date)).earliestTime() next_start_date=period_start_date)).earliestTime()
period_history_list = [] period_history_list = []
if next_period_history_list and\
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: while history_list and history_list[0][0] < next_period_start_date:
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
min_inventory = self.Base_evaluateMinInventoryForSupplyAtDate( # In this iteration we verify that the invetory is always superior
# to the min_stock_value
min_inventory_end_of_period = min_stock_value
# Anticipate next period need if a ratio is defined
next_period_history_list = []
next_next_period_start_date = DateTime(supply.getNextPeriodicalDate(
next_period_start_date,
next_start_date=next_period_start_date)).earliestTime()
if factor and next_next_period_start_date <= last_date:
# prepare new hixtory_list
while history_list and history_list[0][0] < next_next_period_start_date:
next_period_history_list.append(history_list.pop(0))
# Calculate need with ratio
# Here it is actually just a ratio of the next period consumption.
min_inventory_end_of_period = self.Base_evaluateMinInventoryForSupplyAtDate(
supply=supply,
history_list=next_period_history_list,
at_date=next_period_start_date,
factor=factor,
min_stock_value=min_inventory_end_of_period,
)
week_consumption = self.Base_evaluateMinInventoryForSupplyAtDate(
supply=supply, supply=supply,
history_list=period_history_list, history_list=period_history_list,
at_date=period_start_date, at_date=period_start_date,
conversion_ratio=default_quantity_unit_flow_quantity_unit_conversion_ratio, factor=1,
) )
min_inventory = min_inventory_end_of_period + week_consumption
quantity = 0 quantity = 0
if future_inventory_to_date < min_inventory: # SKU if future_inventory_to_date < min_inventory: # SKU
......
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