Commit 2bcdd046 authored by Julien Muchembled's avatar Julien Muchembled

Add reference and causality links to generated amounts

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@37780 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ba7da5a5
...@@ -67,6 +67,7 @@ class Amount(Base, Variated): ...@@ -67,6 +67,7 @@ class Amount(Base, Variated):
, PropertySheet.SimpleItem , PropertySheet.SimpleItem
, PropertySheet.Amount , PropertySheet.Amount
, PropertySheet.Price , PropertySheet.Price
, PropertySheet.Reference
) )
# A few more mix-in methods which should be relocated # A few more mix-in methods which should be relocated
......
...@@ -711,9 +711,11 @@ class BusinessProcess(Path, XMLObject): ...@@ -711,9 +711,11 @@ class BusinessProcess(Path, XMLObject):
pass pass
kw.update(update_property_dict) kw.update(update_property_dict)
movement._edit(**kw) movement._edit(**kw)
business_link = self.getBusinessLinkValueList(trade_phase=trade_phase, context=movement) business_link = self.getBusinessLinkValueList(trade_phase=trade_phase,
business_link = map(lambda x: x.getRelativeUrl(), business_link) context=movement)
movement._setCausalityList(business_link + movement.getCausalityList()) business_link = [x.getRelativeUrl() for x in business_link]
movement._setCausalityList(business_link
+ movement.getCausalityList() + amount.getCausalityList())
result.append(movement) result.append(movement)
# result can not be empty # result can not be empty
......
...@@ -196,6 +196,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin): ...@@ -196,6 +196,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
, PropertySheet.SimpleItem , PropertySheet.SimpleItem
, PropertySheet.CategoryCore , PropertySheet.CategoryCore
, PropertySheet.Amount , PropertySheet.Amount
, PropertySheet.Reference
, PropertySheet.Task , PropertySheet.Task
, PropertySheet.Arrow , PropertySheet.Arrow
, PropertySheet.Movement , PropertySheet.Movement
......
...@@ -220,13 +220,8 @@ class AmountGeneratorMixin: ...@@ -220,13 +220,8 @@ class AmountGeneratorMixin:
property_dict.setdefault('base_application_set', property_dict.setdefault('base_application_set',
set()).add(base_application) set()).add(base_application)
#property_dict['trade_phase_list'] = amount_generator_cell.getTradePhaseList() # Required moved to MappedValue #property_dict['trade_phase_list'] = amount_generator_cell.getTradePhaseList() # Required moved to MappedValue
property_dict['reference'] = (amount_generator_cell.getReference() property_dict.setdefault('causality_value_list',
or self.getReference()) # XXX []).append(amount_generator_cell)
property_dict['id'] = amount_generator_cell.getRelativeUrl().replace('/', '_')
property_dict['title'] = self.getTitle()
property_dict['int_index'] = self.getIntIndex()
property_dict['description'] = self.getDescription()
# Case 2: the cell defines a temporary calculation line # Case 2: the cell defines a temporary calculation line
if base_contribution_list: if base_contribution_list:
# Define a key in order to aggregate amounts in cells # Define a key in order to aggregate amounts in cells
...@@ -254,6 +249,7 @@ class AmountGeneratorMixin: ...@@ -254,6 +249,7 @@ class AmountGeneratorMixin:
# base_contribution_list MUST be defined # base_contribution_list MUST be defined
property_dict['base_contribution_list'] = base_contribution_list property_dict['base_contribution_list'] = base_contribution_list
for property_dict in resource_amount_aggregate.itervalues(): for property_dict in resource_amount_aggregate.itervalues():
causality_value_list = property_dict.pop('causality_value_list')
base_application_set = property_dict['base_application_set'] base_application_set = property_dict['base_application_set']
# property_dict should include # property_dict should include
# resource - VAT service or a Component in MRP # resource - VAT service or a Component in MRP
...@@ -283,9 +279,19 @@ class AmountGeneratorMixin: ...@@ -283,9 +279,19 @@ class AmountGeneratorMixin:
continue continue
# Create an Amount object # Create an Amount object
# XXX-JPS Could we use a movement for safety ? # XXX-JPS Could we use a movement for safety ?
amount = newTempAmount(portal, property_dict.pop('id')) amount = newTempAmount(portal,
# we only want the id to be unique
causality_value_list[0].getRelativeUrl().replace('/', '_'))
amount._setCategoryList(property_dict.pop('category_list', ())) amount._setCategoryList(property_dict.pop('category_list', ()))
amount._edit(**property_dict) amount._edit(
# XXX If they are several cells, we may have duplicate references.
reference=self.getReference(),
# XXX Are title, int_index and description useful ??
title=self.getTitle(),
int_index=self.getIntIndex(),
description=self.getDescription(),
**property_dict)
amount._setValueList('causality', causality_value_list)
if rounding: if rounding:
# We hope here that rounding is sufficient at line level # We hope here that rounding is sufficient at line level
amount = getRoundingProxy(amount, context=self) amount = getRoundingProxy(amount, context=self)
...@@ -357,7 +363,7 @@ class AmountGeneratorMixin: ...@@ -357,7 +363,7 @@ class AmountGeneratorMixin:
result_list = [] result_list = []
for amount in generated_amount_list: for amount in generated_amount_list:
key = (amount.getPrice(), amount.getEfficiency(), key = (amount.getPrice(), amount.getEfficiency(),
amount.reference, amount.categories) amount.getReference(), amount.categories)
aggregated_amount = aggregated_amount_dict.get(key) aggregated_amount = aggregated_amount_dict.get(key)
if aggregated_amount is None: if aggregated_amount is None:
aggregated_amount_dict[key] = amount aggregated_amount_dict[key] = amount
......
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