Commit 6509dfad authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

builder: use flow unit for min stock calculation

parent aba9cf68
...@@ -299,6 +299,7 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -299,6 +299,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
resource_value = supply.getResourceValue() resource_value = supply.getResourceValue()
default_quantity_unit_value = resource_value.getDefaultQuantityUnitValue() default_quantity_unit_value = resource_value.getDefaultQuantityUnitValue()
order_quantity_unit_value = supply.getOrderQuantityUnitValue() order_quantity_unit_value = supply.getOrderQuantityUnitValue()
flow_quantity_unit_value = supply.getFlowQuantityUnitValue()
time_quantity_unit_value = supply.getTimeQuantityUnitValue() time_quantity_unit_value = supply.getTimeQuantityUnitValue()
time_second_ratio = resource_value.getQuantityUnitDefinitionRatio(portal.portal_categories.quantity_unit.time.second) time_second_ratio = resource_value.getQuantityUnitDefinitionRatio(portal.portal_categories.quantity_unit.time.second)
min_delay = supply.getMinDelay() min_delay = supply.getMinDelay()
...@@ -342,6 +343,13 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -342,6 +343,13 @@ class BuilderMixin(XMLObject, Amount, Predicate):
else: else:
default_quantity_unit_order_quantity_unit_conversion_ratio = 1 default_quantity_unit_order_quantity_unit_conversion_ratio = 1
if flow_quantity_unit_value is not None:
flow_quantity_unit_relative_url = flow_quantity_unit_value.getCategoryRelativeUrl()
flow_quantity_unit_default_quantity_unit_conversion_ratio = resource_value.convertQuantity(1, flow_quantity_unit_relative_url, default_quantity_unit_relative_url)
default_quantity_unit_flow_quantity_unit_conversion_ratio = 1 / flow_quantity_unit_default_quantity_unit_conversion_ratio
else:
default_quantity_unit_flow_quantity_unit_conversion_ratio = 1
def getPreviousValidDate(date): def getPreviousValidDate(date):
# We suppose the system has not been configured to handled per hour commands # We suppose the system has not been configured to handled per hour commands
return DateTime(supply.getNextPeriodicalDate( return DateTime(supply.getNextPeriodicalDate(
...@@ -453,7 +461,7 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -453,7 +461,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
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_order_quantity_unit_conversion_ratio, conversion_ratio=default_quantity_unit_flow_quantity_unit_conversion_ratio,
) )
quantity = 0 quantity = 0
......
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