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
from Products.ERP5.AggregatedAmountList import AggregatedAmountList
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):
"""Trade Model Line is a way to represent trade transformation for movements
......@@ -101,28 +109,23 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
# if temp_movements are passed as parameters, we want to use it,
# otherwise, we will search for simulation movements
if len(movement_list) == 0:
if context.getPortalType() == 'Applied Rule':
movement_list = [context.getParentValue()]
# no movements passed, need to find some
if isMovement(context):
# create movement lists from context
movement_list = [context]
else:
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]
else:
# create movement list for delivery's movements
movement_list = []
for movement in context.getMovementList():
# XXX: filtering shall be in getMovementList
movement_list = []
for movement in context.getMovementList():
# add only movement wich are input (i.e. resource use category
# is in the normal resource use preference list). Output will
# be recalculated
movement_resource = movement.getResourceValue()
if movement_resource is not None:
if movement_resource.getUse() in \
normal_resource_use_category_list:
movement_list.append(movement)
# add only movement which are input (i.e. resource use category
# is in the normal resource use preference list). Output will
# be recalculated
movement_resource = movement.getResourceValue()
if movement_resource is not None:
if movement_resource.getUse() in \
normal_resource_use_category_list:
movement_list.append(movement)
aggregated_amount_list = AggregatedAmountList()
base_application_list = self.getBaseApplicationList()
......
......@@ -119,8 +119,8 @@ class TradeModelRule(TransformationRule):
if trade_condition is None or business_process is None:
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
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