From 0e6513050f92ee44064d2e89f0f8dc8ba7b99589 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Tue, 23 Feb 2010 06:34:58 +0000
Subject: [PATCH] some checks for applied payment simulation rule.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32992 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testAccountingRules.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/product/ERP5/tests/testAccountingRules.py b/product/ERP5/tests/testAccountingRules.py
index 850d26ba3a..d2fdd783a6 100644
--- a/product/ERP5/tests/testAccountingRules.py
+++ b/product/ERP5/tests/testAccountingRules.py
@@ -1232,7 +1232,22 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase):
   def stepCheckPaymentRuleIsApplied(self, sequence, **kw) :
     """ checks that a payment rule is applied for the total amount
       of receivable """
-    # TODO
+    invoice_line = sequence.get('invoice_line')
+    simulation_movement = invoice_line.getDeliveryRelatedValue()
+    applied_rule_list = simulation_movement.objectValues()
+    # Invoice Transaction Rule and Trade Model Rule
+    self.assertEquals(2, len(applied_rule_list))
+    applied_rule = [x for x in applied_rule_list \
+                    if x.getSpecialiseReference() == \
+                    'default_invoice_transaction_rule'][0]
+    simulation_movement_list = [x for x in applied_rule.objectValues() \
+                                if x.getSourceTitle() in ('Receivable',
+                                                          'Payable')]
+    self.assertEquals(1, len(simulation_movement_list))
+    simulation_movement = simulation_movement_list[0]
+    applied_rule_list = simulation_movement.objectValues()
+    self.assertEquals(1, len(applied_rule_list))
+    payment_applied_rule = applied_rule_list[0]
 
   def stepPlanInvoice(self, sequence, **kw) :
     """ put the invoice in the `planned` state, which will
-- 
2.30.9