Commit 438322fb authored by Alexandre Boeglin's avatar Alexandre Boeglin

fix bugs in invoice simulation, and added related tests:

- we should generate accounting movements after an invoice rule, but only
  after a invoice movement, and not cascade accounting movements
- we should generate payment movements after a invoice rule in some cases too


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16706 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cc2220f6
...@@ -67,14 +67,22 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -67,14 +67,22 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
""" """
Tests if the rule (still) applies Tests if the rule (still) applies
""" """
# An invoice transaction rule applies when the movement's # An invoice transaction rule applies when the movement's
# parent is an invoice rule # parent is an invoice rule
# If the parent rule is a Invoice Rule, we must also make sure that the
# movement's delivery is a Invoice Movement (and not a Accounting one)
parent = movement.getParentValue() parent = movement.getParentValue()
parent_rule_value = parent.getSpecialiseValue() parent_rule_value = parent.getSpecialiseValue()
if parent_rule_value is None: if parent_rule_value is None:
return 0 return 0
if parent_rule_value.getPortalType() in ( parent_rule_type = parent_rule_value.getPortalType()
'Invoicing Rule', 'Invoice Rule'): if parent_rule_type in ('Invoicing Rule', 'Invoice Rule'):
if parent_rule_type == 'Invoice Rule':
delivery_movement = movement.getDeliveryValue()
if delivery_movement is not None:
if delivery_movement.getPortalType() not in \
movement.getPortalInvoiceMovementTypeList():
return 0
if self._getMatchingCell(movement) is not None: if self._getMatchingCell(movement) is not None:
return 1 return 1
return 0 return 0
......
...@@ -71,9 +71,18 @@ class PaymentRule(Rule): ...@@ -71,9 +71,18 @@ class PaymentRule(Rule):
""" """
if 'receivable' in movement.getId() : ### TODO: expand 'payable' too if 'receivable' in movement.getId() : ### TODO: expand 'payable' too
parent = movement.getParentValue() parent = movement.getParentValue()
if parent.getPortalType()=='Applied Rule' \ parent_rule_value = parent.getSpecialiseValue()
and parent.getSpecialiseId()=='default_invoice_transaction_rule': if parent_rule_value is None:
#LOG('PaymentRule.test :', 0, repr(( 'applies with', movement, parent ))) return 0
parent_rule_type = parent_rule_value.getPortalType()
if parent_rule_type in ('Invoice Transaction Rule',
'Invoice Rule'):
if parent_rule_type == 'Invoice Rule':
delivery_movement = movement.getDeliveryValue()
if delivery_movement is not None:
if delivery_movement.getPortalType() not in \
movement.getPortalAccountingMovementTypeList():
return 0
return 1 return 1
return 0 return 0
......
This diff is collapsed.
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