Commit a4c9e4d6 authored by Guillaume Michon's avatar Guillaume Michon

Adapted to target properties removal


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2885 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b89b54e3
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
from Products.ERP5.Tool.SimulationTool import registerTargetSolver from Products.ERP5.Tool.SimulationTool import registerTargetSolver
from CopyToTarget import CopyToTarget from CopyToTarget import CopyToTarget
from zLOG import LOG
class ProfitAndLoss(CopyToTarget): class ProfitAndLoss(CopyToTarget):
""" """
...@@ -44,15 +45,18 @@ class ProfitAndLoss(CopyToTarget): ...@@ -44,15 +45,18 @@ class ProfitAndLoss(CopyToTarget):
Movement difference as a profit (ie. a quantity coming from nowhere) Movement difference as a profit (ie. a quantity coming from nowhere)
Accumulate into delivered movement Accumulate into delivered movement
""" """
target_quantity = movement.getTargetQuantity() LOG('profit and loss called on movement', 0, repr(movement))
new_target_quantity = new_target.target_quantity previous_quantity = getattr(movement, '_v_previous_quantity', None)
if target_quantity != new_target_quantity: if previous_quantity is None:
previous_profit_quantity = movement.getProfitQuantity() return
movement.setProfitQuantity(new_target_quantity - target_quantity) added_quantity = movement.getQuantity() - previous_quantity
new_profit_quantity = movement.getProfitQuantity() profit_quantity = movement.getProfitQuantity()
delivery_value = movement.getDeliveryValue() if profit_quantity is None:
if delivery_value is not None: profit_quantity = 0.
delivery_value.setProfitQuantity(delivery_value.getProfitQuantity() + new_profit_quantity - previous_profit_quantity) movement.setQuantity(previous_quantity)
CopyToTarget.solve(self, movement, new_target) movement.setProfitQuantity(profit_quantity - added_quantity)
# The calling method must call Delivery.updateSimulationDeliveryProperties once
# all the movements have been solved
registerTargetSolver(ProfitAndLoss) registerTargetSolver(ProfitAndLoss)
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