Commit 34ee54aa authored by Julien Muchembled's avatar Julien Muchembled

Move local function out of a loop to avoid excessive indentation

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34643 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent faab72c9
...@@ -163,24 +163,8 @@ class AmountGeneratorMixin: ...@@ -163,24 +163,8 @@ class AmountGeneratorMixin:
raise ValueError( raise ValueError(
'context must implement IMovementCollection, IAmount or IAmountList') 'context must implement IMovementCollection, IAmount or IAmountList')
# Each amount in amount_list creates a new amount to take into account # First define the method that will browses recursively
# We thus need to start with a loop on amount_list # the amount generator lines and accumulate applicable values
for delivery_amount in amount_list:
# Initialize base_amount with per amount properties
amount_property_dict = self._getAmountPropertyDict(delivery_amount,
amount_list=amount_list, rounding=rounding)
base_amount.update(amount_property_dict)
# Initialize base_amount with total_price for each amount applications
#for application in delivery_amount.getBaseApplicationList(): # Acquired from Resource - XXX-JPS ?
application_list = delivery_amount.getBaseContributionList() # or getBaseApplicationList ?
if application_list:
total_price = delivery_amount.getTotalPrice()
for application in application_list: # Acquired from Resource - seems more normal
base_amount[application] = total_price
# Browse recursively the trade model and accumulate
# applicable values - first define the recursive method
def accumulateAmountList(amount_generator_line): def accumulateAmountList(amount_generator_line):
amount_generator_line_list = amount_generator_line.contentValues( amount_generator_line_list = amount_generator_line.contentValues(
portal_type=self.getPortalAmountGeneratorLineTypeList()) portal_type=self.getPortalAmountGeneratorLineTypeList())
...@@ -286,8 +270,7 @@ class AmountGeneratorMixin: ...@@ -286,8 +270,7 @@ class AmountGeneratorMixin:
amount = portal_roundings.getRoundingProxy(amount, amount = portal_roundings.getRoundingProxy(amount,
context=amount_generator_line) context=amount_generator_line)
result.append(amount) result.append(amount)
for base_application, property_dict in \ for base_application, property_dict in value_amount_aggregate.iteritems():
value_amount_aggregate.iteritems():
# property_dict should include # property_dict should include
# base_contribution_list - needed to produce reports with # base_contribution_list - needed to produce reports with
# getTotalPrice # getTotalPrice
...@@ -302,6 +285,22 @@ class AmountGeneratorMixin: ...@@ -302,6 +285,22 @@ class AmountGeneratorMixin:
for base_key in property_dict['base_contribution_list']: for base_key in property_dict['base_contribution_list']:
base_amount[base_key] += value base_amount[base_key] += value
# Each amount in amount_list creates a new amount to take into account
# We thus need to start with a loop on amount_list
for delivery_amount in amount_list:
# Initialize base_amount with per amount properties
amount_property_dict = self._getAmountPropertyDict(delivery_amount,
amount_list=amount_list, rounding=rounding)
base_amount.update(amount_property_dict)
# Initialize base_amount with total_price for each amount applications
#for application in delivery_amount.getBaseApplicationList(): # Acquired from Resource - XXX-JPS ?
application_list = delivery_amount.getBaseContributionList() # or getBaseApplicationList ?
if application_list:
total_price = delivery_amount.getTotalPrice()
for application in application_list: # Acquired from Resource - seems more normal
base_amount[application] = total_price
# Browse recursively the trade model and accumulate # Browse recursively the trade model and accumulate
# applicable values - now execute the method # applicable values - now execute the method
accumulateAmountList(self) accumulateAmountList(self)
......
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