Commit 8595f818 authored by Yusei Tahara's avatar Yusei Tahara

Move the movement matching condition block to a new method and make

the condition changable. This fixes a bug tested on
test_tradeModelLineWithEmptyBaseContributionMovement.
Override the condition in PaymentCondition and make PaymentCondition
appliable to any movements.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35473 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 63b98e10
......@@ -74,3 +74,8 @@ class PaymentCondition(TradeModelLine):
method = self._getTypeBasedMethod('calculateMovement')
return method
def _isMatchedMovement(self, movement, base_application_list, tmp_movement):
"""Override the original implementation and allow payment condition to
match to any movements
"""
return True
......@@ -314,14 +314,7 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
# movements (current_aggregated_amount_list).
# if the quantity is not defined, take it by searching all movements
# that used this base_amount
if (len(base_application_list) == 0 or \
len(movement.getBaseContributionList()) == 0 or \
set(base_application_list).intersection( \
set(movement.getBaseContributionList()))) and \
(len(movement.getVariationCategoryList()) == 0 or \
len(tmp_movement.getVariationCategoryList()) == 0 or \
set(movement.getVariationCategoryList()).intersection( \
set(tmp_movement.getVariationCategoryList()))):
if self._isMatchedMovement(movement, base_application_list, tmp_movement):
# at least one base application is in base contributions and
# if the movement have no variation category, it's the same as
# if he have all variation categories
......@@ -406,3 +399,15 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
aggregated_amount_list.append(tmp_movement)
return aggregated_amount_list
def _isMatchedMovement(self, movement, base_application_list, tmp_movement):
return (
set(base_application_list).intersection(
set(movement.getBaseContributionList())) and
(len(movement.getVariationCategoryList()) == 0 or
len(tmp_movement.getVariationCategoryList()) == 0 or
set(movement.getVariationCategoryList()).intersection(
set(tmp_movement.getVariationCategoryList()))
)
)
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