Commit 6678f0de authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

builder: use dedicated script to evaluate min stock

parent ec2c8503
...@@ -391,9 +391,16 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -391,9 +391,16 @@ class BuilderMixin(XMLObject, Amount, Predicate):
node_uid=supply.getDestinationUid() node_uid=supply.getDestinationUid()
# XXX This should be bound to a stard and stop date # XXX This should be bound to a stard and stop date
) )
for date, inventory in history_list: while history_list:
if ordered_inventory + inventory < min_inventory: # SKU date, inventory, quantity = history_list[0]
quantity = min_inventory - inventory - ordered_inventory min_inventory = self.Base_evaluateMinInventoryForSupplyAtDate(
supply=supply,
history_list=history_list,
at_date=date,
)
if ordered_inventory + (inventory-quantity) < min_inventory: # SKU
#import pdb;pdb.set_trace()
quantity = min_inventory - (inventory-quantity) - ordered_inventory
ordered_quantity, ordered_unit, ordered_date, delivery_date, quantity = minimalQuantity(quantity, date) ordered_quantity, ordered_unit, ordered_date, delivery_date, quantity = minimalQuantity(quantity, date)
# XXX CLN This is very naive, it has to be optimized # XXX CLN This is very naive, it has to be optimized
if ordered_date <= supply.getStartDateRangeMax()\ if ordered_date <= supply.getStartDateRangeMax()\
...@@ -407,6 +414,7 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -407,6 +414,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
ordered_unit ordered_unit
) )
) )
history_list.pop(0)
return movement_list return movement_list
def _searchMovementList(self, **kw): def _searchMovementList(self, **kw):
......
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