Commit a6e8e34b authored by Łukasz Nowak's avatar Łukasz Nowak

- create local isMovement to simplify decision code

 - do not analyse passed context in getAggregatedAmountList to simplify it, assume that movement or delivery is passed
 - add some comments and explanations to decision process
 - follow change for context in getAggregatedAmountList - TradeModelRule is passing simulation movement instead of applied rule


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27604 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8d13a6f9
...@@ -37,6 +37,14 @@ from Products.ERP5Type.Utils import cartesianProduct ...@@ -37,6 +37,14 @@ from Products.ERP5Type.Utils import cartesianProduct
from Products.ERP5.AggregatedAmountList import AggregatedAmountList from Products.ERP5.AggregatedAmountList import AggregatedAmountList
import zope.interface import zope.interface
def isMovement(document):
"""Hides isMovement method or variable complexity"""
if callable(document.isMovement):
is_movement = document.isMovement()
else:
is_movement = document.isMovement
return is_movement
class TradeModelLine(Predicate, XMLMatrix, Amount): class TradeModelLine(Predicate, XMLMatrix, Amount):
"""Trade Model Line is a way to represent trade transformation for movements """Trade Model Line is a way to represent trade transformation for movements
...@@ -101,21 +109,16 @@ class TradeModelLine(Predicate, XMLMatrix, Amount): ...@@ -101,21 +109,16 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
# if temp_movements are passed as parameters, we want to use it, # if temp_movements are passed as parameters, we want to use it,
# otherwise, we will search for simulation movements # otherwise, we will search for simulation movements
if len(movement_list) == 0: if len(movement_list) == 0:
if context.getPortalType() == 'Applied Rule': # no movements passed, need to find some
movement_list = [context.getParentValue()] if isMovement(context):
else: # create movement lists from context
if callable(context.isMovement):
is_movement = context.isMovement()
else:
is_movement = context.isMovement
if is_movement:
# we need to create aggreageted amount on context itself
movement_list = [context] movement_list = [context]
else: else:
# XXX: filtering shall be in getMovementList # create movement list for delivery's movements
movement_list = [] movement_list = []
for movement in context.getMovementList(): for movement in context.getMovementList():
# add only movement wich are input (i.e. resource use category # XXX: filtering shall be in getMovementList
# add only movement which are input (i.e. resource use category
# is in the normal resource use preference list). Output will # is in the normal resource use preference list). Output will
# be recalculated # be recalculated
movement_resource = movement.getResourceValue() movement_resource = movement.getResourceValue()
......
...@@ -119,8 +119,8 @@ class TradeModelRule(TransformationRule): ...@@ -119,8 +119,8 @@ class TradeModelRule(TransformationRule):
if trade_condition is None or business_process is None: if trade_condition is None or business_process is None:
return movement_list return movement_list
for amount in trade_condition.getAggregatedAmountList(applied_rule):
context_movement = applied_rule.getParentValue() context_movement = applied_rule.getParentValue()
for amount in trade_condition.getAggregatedAmountList(context_movement):
# everything static # everything static
movement_kw = self._getStaticPropertyDict(context_movement) movement_kw = self._getStaticPropertyDict(context_movement)
......
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