Commit 38f33857 authored by Sebastien Robin's avatar Sebastien Robin

simulation: fix FIFO and FILO solvers, they were unable to work with several movements

parent 521b48ad
......@@ -9,6 +9,9 @@ for solver_process in delivery.getSolverValueList():
draft_solver_process = solver_process
if draft_solver_process is not None:
# Fully clean it to avoid having some solver decisions in double
id_list = [x for x in draft_solver_process.objectIds()]
draft_solver_process.manage_delObjects(ids=id_list)
draft_solver_process.buildSolverDecisionList(delivery)
else:
delivery.getPortalObject().portal_solver_processes.newSolverProcess(delivery)
......@@ -160,7 +160,7 @@
</item>
<item>
<key> <string>line_groupable</string> </key>
<value> <int>0</int> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>permission</string> </key>
......
......@@ -67,17 +67,29 @@
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
<item>
<key> <string>acquire_local_roles</string> </key>
<value> <int>1</int> </value>
......@@ -136,17 +148,13 @@
<none/>
</value>
</item>
<item>
<key> <string>last_id</string> </key>
<value> <string>2</string> </value>
</item>
<item>
<key> <string>line_exclusive</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>line_groupable</string> </key>
<value> <int>0</int> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>permission</string> </key>
......@@ -166,6 +174,10 @@
<key> <string>solver_action_title</string> </key>
<value> <string>Split and Differ</string> </value>
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>QuantitySplitSolver</string> </value>
</item>
</dictionary>
</pickle>
</record>
......@@ -176,6 +188,21 @@
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
......@@ -183,7 +210,22 @@
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="6" aka="AAAAAAAAAAY=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
......
......@@ -77,13 +77,16 @@ class FIFODeliverySolver(XMLObject):
return result
simulation_movement_list = self._getSimulationMovementList()
for movement in simulation_movement_list:
if remaining_quantity:
quantity = movement.getQuantity()
if quantity < remaining_quantity:
result.append((movement, quantity))
remaining_quantity -= quantity
movement.edit(quantity=0, delivery_ratio=0, activate_kw=activate_kw)
else:
# only append movement if we decrease the quantity, which means we
# would surely split it. If remaining quantity is 0, the code is
# just used to update delivery ratio
if remaining_quantity:
result.append((movement, remaining_quantity))
movement_quantity = quantity - remaining_quantity
delivery_ratio = 1.
......@@ -103,6 +106,6 @@ class FIFODeliverySolver(XMLObject):
simulation_movement_list = self.getDeliveryValueList()
if len(simulation_movement_list) > 1:
return sorted(simulation_movement_list,
key=lambda x:x.getExplainationValue().getStartDate(), reverse=True)
key=lambda x:x.getExplanationValue().getStartDate(), reverse=True)
else:
return simulation_movement_list
......@@ -63,6 +63,6 @@ class LIFODeliverySolver(FIFODeliverySolver):
simulation_movement_list = self.getDeliveryValueList()
if len(simulation_movement_list) > 1:
return sorted(simulation_movement_list,
key=lambda x:x.getExplainationValue().getStartDate())
key=lambda x:x.getExplanationValue().getStartDate())
else:
return simulation_movement_list
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