Commit a525bdbe authored by Julien Muchembled's avatar Julien Muchembled

amount_generator: add _getResourceAmountAggregateKey method

This will allow Transformed Resource to merge cells.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33967 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b67530a7
...@@ -99,6 +99,31 @@ class AmountGeneratorMixin: ...@@ -99,6 +99,31 @@ class AmountGeneratorMixin:
# on the weight in tons # on the weight in tons
) )
def _getResourceAmountAggregateKey(self, amount_generator_cell):
"""Define a key in order to aggregate amounts
Transformed Resource (Transformation)
key must be None because:
- quantity and variation are defined in different cells so that the
user does not need to enter values depending on all axes
- amount_generator_cell.test should filter only 1 variant
current key = (acquired resource, acquired variation)
Assorted Resource (Transformation)
key = (assorted resource, assorted resource variation)
usually resource and quantity provided together
Payroll
key = (payroll resource, payroll resource variation)
Tax
key = (tax resource, tax resource variation)
"""
return (amount_generator_cell.getResource(),
amount_generator_cell.getVariationText()) # Variation UID, Hash ?
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getGeneratedAmountList') 'getGeneratedAmountList')
def getGeneratedAmountList(self, context, amount_list=None, rounding=False): def getGeneratedAmountList(self, context, amount_list=None, rounding=False):
...@@ -185,28 +210,7 @@ class AmountGeneratorMixin: ...@@ -185,28 +210,7 @@ class AmountGeneratorMixin:
resource = amount_generator_cell.getResource() resource = amount_generator_cell.getResource()
# Case 1: the cell defines a final amount of resource # Case 1: the cell defines a final amount of resource
if resource: if resource:
# Define a key in order to aggregate amounts key = self._getResourceAmountAggregateKey(amount_generator_cell)
# in transformations where variation and quantity
# are defined in different cells
#
# Transformed Resource (Transformation)
# key = anything (only one cell selected)
# current key = (acquired resource, acquired variation)
#
# Assorted Resource (Transformation)
# key = (assorted resource, assorted resource variation)
# usually resource and quantity provided together
#
# Payroll
#
# key = (payroll resource, payroll resource variation)
#
# Tax
#
# key = (tax resource, tax resource variation)
key = (amount_generator_cell.getResource(),
# Variation UID, Hash ?
amount_generator_cell.getVariationText())
property_dict = resource_amount_aggregate.setdefault(key, {}) property_dict = resource_amount_aggregate.setdefault(key, {})
# Then collect the mapped properties (net_converted_quantity, # Then collect the mapped properties (net_converted_quantity,
# resource, quantity, base_contribution_list, base_application...) # resource, quantity, base_contribution_list, base_application...)
......
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