From 20e8efa9b098c8e2f74f0ab728d313ac6e05dc23 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Tue, 16 Feb 2010 06:25:51 +0000
Subject: [PATCH] improve test method for payment rule based on existing
 PaymentRule.py.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32574 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../SimulationMovement_testPaymentRule.xml    | 28 +++++++++++++------
 bt5/erp5_accounting/bt/revision               |  2 +-
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/SimulationMovement_testPaymentRule.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/SimulationMovement_testPaymentRule.xml
index a69476078e..2e5fdca484 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/SimulationMovement_testPaymentRule.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/SimulationMovement_testPaymentRule.xml
@@ -55,19 +55,26 @@
             <key> <string>_body</string> </key>
             <value> <string>movement = context\n
 \n
-if movement.getId() not in (\'receivable\',):\n
-  return False\n
-\n
 parent = movement.getParentValue()\n
 if parent.getPortalType() != \'Applied Rule\':\n
   return False\n
 \n
 parent_rule = parent.getSpecialiseValue()\n
-if parent_rule.getPortalType() not in [\'Invoice Transaction Rule\']:\n
+if parent_rule.getPortalType() not in (\'Invoice Transaction Rule\',):\n
   return False\n
 \n
-delivery_movement = movement.getDeliveryValue()\n
-return delivery_movement is None or delivery_movement.getPortalType() in movement.getPortalAccountingMovementTypeList()\n
+receivable_account_type_list = (\'asset/receivable\',)\n
+payable_account_type_list = (\'liability/payable\',)\n
+\n
+for account in (movement.getSourceValue(portal_type=\'Account\'),\n
+                movement.getDestinationValue(portal_type=\'Account\')):\n
+  if account is not None:\n
+    account_type = account.getAccountType()\n
+    if account_type in receivable_account_type_list or \\\n
+        account_type in payable_account_type_list:\n
+      return True\n
+\n
+return False\n
 </string> </value>
         </item>
         <item>
@@ -108,11 +115,16 @@ return delivery_movement is None or delivery_movement.getPortalType() in movemen
                             <string>context</string>
                             <string>movement</string>
                             <string>_getattr_</string>
-                            <string>False</string>
                             <string>parent</string>
+                            <string>False</string>
                             <string>parent_rule</string>
-                            <string>delivery_movement</string>
+                            <string>receivable_account_type_list</string>
+                            <string>payable_account_type_list</string>
+                            <string>_getiter_</string>
+                            <string>account</string>
                             <string>None</string>
+                            <string>account_type</string>
+                            <string>True</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision
index 0da1d6394c..5afb033c80 100644
--- a/bt5/erp5_accounting/bt/revision
+++ b/bt5/erp5_accounting/bt/revision
@@ -1 +1 @@
-1103
\ No newline at end of file
+1104
\ No newline at end of file
-- 
2.30.9