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