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,28 +109,23 @@ class TradeModelLine(Predicate, XMLMatrix, Amount): ...@@ -101,28 +109,23 @@ 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):
# create movement lists from context
movement_list = [context]
else: else:
if callable(context.isMovement): # create movement list for delivery's movements
is_movement = context.isMovement() movement_list = []
else: for movement in context.getMovementList():
is_movement = context.isMovement
if is_movement:
# we need to create aggreageted amount on context itself
movement_list = [context]
else:
# XXX: filtering shall be in getMovementList # XXX: filtering shall be in getMovementList
movement_list = [] # add only movement which are input (i.e. resource use category
for movement in context.getMovementList(): # is in the normal resource use preference list). Output will
# add only movement wich are input (i.e. resource use category # be recalculated
# is in the normal resource use preference list). Output will movement_resource = movement.getResourceValue()
# be recalculated if movement_resource is not None:
movement_resource = movement.getResourceValue() if movement_resource.getUse() in \
if movement_resource is not None: normal_resource_use_category_list:
if movement_resource.getUse() in \ movement_list.append(movement)
normal_resource_use_category_list:
movement_list.append(movement)
aggregated_amount_list = AggregatedAmountList() aggregated_amount_list = AggregatedAmountList()
base_application_list = self.getBaseApplicationList() base_application_list = self.getBaseApplicationList()
......
...@@ -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