Commit 308a4b1c authored by Łukasz Nowak's avatar Łukasz Nowak

- in testBPMCore.py do not check for causality, as it is not used anymore

 - add test to testBPMCore.py proving that changing resource will reexpannd properly
 - in TradeModelRule.py and TradeCondition.py use reference to compare documents, and set reference property on documents, as resource is not stable enough


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27727 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4f5e4d8b
...@@ -54,7 +54,7 @@ class TradeCondition(Path, Transformation, XMLMatrix): ...@@ -54,7 +54,7 @@ class TradeCondition(Path, Transformation, XMLMatrix):
business together business together
""" """
edited_property_list = ['price', 'causality','resource','quantity', edited_property_list = ['price', 'causality','resource','quantity',
'base_application_list', 'base_contribution_list'] 'reference', 'base_application_list', 'base_contribution_list']
meta_type = 'ERP5 Trade Condition' meta_type = 'ERP5 Trade Condition'
portal_type = 'Trade Condition' portal_type = 'Trade Condition'
...@@ -85,7 +85,7 @@ class TradeCondition(Path, Transformation, XMLMatrix): ...@@ -85,7 +85,7 @@ class TradeCondition(Path, Transformation, XMLMatrix):
existing_movement_list = context.getMovementList() existing_movement_list = context.getMovementList()
aggregated_amount_list = self.getAggregatedAmountList(context=context, aggregated_amount_list = self.getAggregatedAmountList(context=context,
movement_list=movement_list, **kw) movement_list=movement_list, **kw)
modified_resource_list = [] modified_reference_list = []
normal_use_list = self.getPortalObject().portal_preferences\ normal_use_list = self.getPortalObject().portal_preferences\
.getPreferredNormalResourceUseCategoryList() .getPreferredNormalResourceUseCategoryList()
# check if the existing movements are in aggregated movements # check if the existing movements are in aggregated movements
...@@ -106,16 +106,16 @@ class TradeCondition(Path, Transformation, XMLMatrix): ...@@ -106,16 +106,16 @@ class TradeCondition(Path, Transformation, XMLMatrix):
update_kw = {} update_kw = {}
for p in self.edited_property_list: for p in self.edited_property_list:
update_kw[p] = amount.getProperty(p) update_kw[p] = amount.getProperty(p)
if movement.getProperty('resource') == update_kw['resource'] and\ if movement.getProperty('reference') == update_kw['reference'] and\
movement.getVariationCategoryList() == \ movement.getVariationCategoryList() == \
amount.getVariationCategoryList(): amount.getVariationCategoryList():
movement.edit(**update_kw) movement.edit(**update_kw)
modified_resource_list.append(update_kw['resource']) modified_reference_list.append(update_kw['reference'])
keep_movement = True keep_movement = True
if not keep_movement: if not keep_movement:
movement_to_delete_list.append(movement) movement_to_delete_list.append(movement)
movement_to_add_list = [amount for amount in aggregated_amount_list if movement_to_add_list = [amount for amount in aggregated_amount_list if
amount.getResource() not in modified_resource_list] amount.getReference() not in modified_reference_list]
return {'movement_to_delete_list' : movement_to_delete_list, return {'movement_to_delete_list' : movement_to_delete_list,
'movement_to_add_list': movement_to_add_list} 'movement_to_add_list': movement_to_add_list}
......
...@@ -130,6 +130,7 @@ class TradeModelRule(TransformationRule): ...@@ -130,6 +130,7 @@ class TradeModelRule(TransformationRule):
# rule specific # rule specific
movement_kw['price'] = amount.getProperty('price') movement_kw['price'] = amount.getProperty('price')
movement_kw['resource'] = amount.getProperty('resource') movement_kw['resource'] = amount.getProperty('resource')
movement_kw['reference'] = amount.getProperty('reference')
movement_kw['quantity'] = amount.getProperty('quantity') movement_kw['quantity'] = amount.getProperty('quantity')
movement_kw['base_application_list'] = amount.getProperty( movement_kw['base_application_list'] = amount.getProperty(
'base_application_list') 'base_application_list')
...@@ -148,9 +149,13 @@ class TradeModelRule(TransformationRule): ...@@ -148,9 +149,13 @@ class TradeModelRule(TransformationRule):
if not parent_movement.isFrozen(): if not parent_movement.isFrozen():
# XXX This will change, as soon as frozen will no longer be an expand # XXX This will change, as soon as frozen will no longer be an expand
# stopper # stopper
# for now reference is used to compare movements, but as soon as Trade
# Models will create more than one movement magic have to be added -
# reference on movement have to be properly composed
add_list, modify_dict, \ add_list, modify_dict, \
delete_list = self._getCompensatedMovementList(applied_rule, delete_list = self._getCompensatedMovementList(applied_rule,
matching_property_list= ('resource',), **kw) matching_property_list = ('reference',), **kw)
for movement_id in delete_list: for movement_id in delete_list:
applied_rule._delObject(movement_id) applied_rule._delObject(movement_id)
......
...@@ -637,11 +637,6 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -637,11 +637,6 @@ class TestBPMMixin(ERP5TypeTestCase):
trade_model_simulation_movement_discount_complex.getTotalPrice() trade_model_simulation_movement_discount_complex.getTotalPrice()
) )
self.assertEqual(
business_path_discounting,
trade_model_simulation_movement_discount_complex.getCausalityValue()
)
self.assertEqual( self.assertEqual(
price_currency, price_currency,
trade_model_simulation_movement_discount_complex \ trade_model_simulation_movement_discount_complex \
...@@ -678,11 +673,6 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -678,11 +673,6 @@ class TestBPMMixin(ERP5TypeTestCase):
trade_model_simulation_movement_tax_complex.getTotalPrice() trade_model_simulation_movement_tax_complex.getTotalPrice()
) )
self.assertEqual(
business_path_taxing,
trade_model_simulation_movement_tax_complex.getCausalityValue()
)
self.assertEqual( self.assertEqual(
price_currency, price_currency,
trade_model_simulation_movement_tax_complex.getPriceCurrencyValue() trade_model_simulation_movement_tax_complex.getPriceCurrencyValue()
...@@ -737,11 +727,6 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -737,11 +727,6 @@ class TestBPMMixin(ERP5TypeTestCase):
trade_model_simulation_movement_discount_only.getTotalPrice() trade_model_simulation_movement_discount_only.getTotalPrice()
) )
self.assertEqual(
business_path_discounting,
trade_model_simulation_movement_discount_only.getCausalityValue()
)
self.assertEqual( self.assertEqual(
price_currency, price_currency,
trade_model_simulation_movement_discount_only.getPriceCurrencyValue() trade_model_simulation_movement_discount_only.getPriceCurrencyValue()
...@@ -771,11 +756,6 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -771,11 +756,6 @@ class TestBPMMixin(ERP5TypeTestCase):
getTotalPrice() * self.default_tax_ratio, getTotalPrice() * self.default_tax_ratio,
trade_model_simulation_movement_tax_only.getTotalPrice()) trade_model_simulation_movement_tax_only.getTotalPrice())
self.assertEqual(
business_path_taxing,
trade_model_simulation_movement_tax_only.getCausalityValue()
)
self.assertEqual( self.assertEqual(
price_currency, price_currency,
trade_model_simulation_movement_tax_only.getPriceCurrencyValue() trade_model_simulation_movement_tax_only.getPriceCurrencyValue()
...@@ -817,11 +797,6 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -817,11 +797,6 @@ class TestBPMMixin(ERP5TypeTestCase):
trade_model_simulation_movement.getTotalPrice() trade_model_simulation_movement.getTotalPrice()
) )
self.assertEqual(
business_path,
trade_model_simulation_movement.getCausalityValue()
)
self.assertEqual( self.assertEqual(
price_currency, price_currency,
trade_model_simulation_movement.getPriceCurrencyValue() trade_model_simulation_movement.getPriceCurrencyValue()
...@@ -1887,6 +1862,21 @@ class TestBPMTestCases(TestBPMMixin): ...@@ -1887,6 +1862,21 @@ class TestBPMTestCases(TestBPMMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def test_TradeModelRuleSimulationReexpandResourceChange(self):
"""Tests tree of simulations from Trade Model Rule with reexpanding when resource changes on model"""
sequence_list = SequenceList()
sequence_string = self.TRADE_MODEL_RULE_SIMULATION_SEQUENCE_STRING + """
CreateServiceTax
CreateServiceDiscount
OrderCreateTradeModelLine
ModifyTradeModelLineDiscount
OrderCreateTradeModelLine
ModifyTradeModelLineTax
Tic
""" + self.AGGREGATED_AMOUNT_SIMULATION_CHECK_SEQUENCE_STRING
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
TRADE_MODEL_RULE_SIMULATION_ORDER_SPECIALISED_SEQUENCE_STRING = \ TRADE_MODEL_RULE_SIMULATION_ORDER_SPECIALISED_SEQUENCE_STRING = \
ORDER_SPECIALISE_AGGREGATED_AMOUNT_COMMON_SEQUENCE_STRING + """ ORDER_SPECIALISE_AGGREGATED_AMOUNT_COMMON_SEQUENCE_STRING + """
Tic Tic
......
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