Commit f0608ffd authored by Fabien Morin's avatar Fabien Morin

try to clean a bit the code, add comments


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27596 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4f452336
...@@ -87,19 +87,19 @@ class TradeModelLine(Predicate, XMLMatrix, Amount): ...@@ -87,19 +87,19 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
if not self.test(context): if not self.test(context):
# This model_line should not be applied # This model_line should not be applied
return [] return []
if movement_list is None:
movement_list = []
if current_aggregated_amount_list is None:
current_aggregated_amount_list = []
normal_resource_use_category_list = self.\ normal_resource_use_category_list = self.\
portal_preferences.getPreferredNormalResourceUseCategoryList() portal_preferences.getPreferredNormalResourceUseCategoryList()
if normal_resource_use_category_list is None: if normal_resource_use_category_list is None:
raise ValueError('preferred_normal_resource_use_category is not ' + \ raise ValueError('preferred_normal_resource_use_category is not ' + \
'configured in System Preferences') 'configured in System Preferences')
if current_aggregated_amount_list is None:
current_aggregated_amount_list = []
if movement_list is None:
movement_list = []
# XXX - really unreadable - more comments please # 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 len(movement_list) == 0:
if context.getPortalType() == 'Applied Rule': if context.getPortalType() == 'Applied Rule':
movement_list = [context.getParentValue()] movement_list = [context.getParentValue()]
...@@ -115,6 +115,9 @@ class TradeModelLine(Predicate, XMLMatrix, Amount): ...@@ -115,6 +115,9 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
# XXX: filtering shall be in getMovementList # XXX: filtering shall be in getMovementList
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
# is in the normal resource use preference list). Output will
# be recalculated
movement_resource = movement.getResourceValue() movement_resource = movement.getResourceValue()
if movement_resource is not None: if movement_resource is not None:
if movement_resource.getUse() in \ if movement_resource.getUse() in \
...@@ -195,17 +198,13 @@ class TradeModelLine(Predicate, XMLMatrix, Amount): ...@@ -195,17 +198,13 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
set(tmp_movement.getVariationCategoryList())): set(tmp_movement.getVariationCategoryList())):
quantity = tmp_movement.getQuantity(0.0) quantity = tmp_movement.getQuantity(0.0)
modified = 1 modified = 1
tmp_movement.edit( tmp_movement.setQuantity(quantity + movement.getTotalPrice())
quantity = quantity + movement.getTotalPrice()
)
else: else:
# if the quantity is defined, we use it # if the quantity is defined, we use it
modified = 1 modified = 1
if tmp_movement.getPrice() in (0, None): if tmp_movement.getPrice() in (0, None):
# if price is not defined, it the same as 100 % # if price is not defined, it the same as 100 %
tmp_movement.edit( tmp_movement.setPrice(1)
price = 1
)
# check if slices are used # check if slices are used
salary_range_list = tmp_movement.getVariationCategoryList(\ salary_range_list = tmp_movement.getVariationCategoryList(\
...@@ -223,13 +222,9 @@ class TradeModelLine(Predicate, XMLMatrix, Amount): ...@@ -223,13 +222,9 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
base_application = tmp_movement.getQuantity(0.0) base_application = tmp_movement.getQuantity(0.0)
if base_application-model_slice_min>0: if base_application-model_slice_min>0:
if base_application <= model_slice_max: if base_application <= model_slice_max:
tmp_movement.edit( tmp_movement.setQuantity(base_application-model_slice_min)
quantity = base_application-model_slice_min
)
elif model_slice_max: elif model_slice_max:
tmp_movement.edit( tmp_movement.setQuantity(model_slice_max-model_slice_min)
quantity = model_slice_max-model_slice_min
)
if not update: if not update:
if modified: if modified:
......
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