From 0f9fe26658f3b60c63b92ba29e73b525231bd467 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 19 Oct 2010 09:41:25 +0000
Subject: [PATCH] Fix undefined source_bank_account variable.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39334 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../scripts/validatePlanActionConsistency.xml        | 12 +++++++++---
 bt5/erp5_banking_check/bt/revision                   |  2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validatePlanActionConsistency.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validatePlanActionConsistency.xml
index 5a9590385b..eb1bc3a7c1 100644
--- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validatePlanActionConsistency.xml
+++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validatePlanActionConsistency.xml
@@ -60,11 +60,15 @@ transaction = state_change[\'object\']\n
 \n
 # Test if the account balance is sufficient.\n
 bank_account_dict = {}\n
+amount_dict = {}\n
 for check_operation_line in transaction.objectValues(portal_type=\'Check Operation Line\'):\n
-  account_path = check_operation_line.getSourcePaymentValue().getRelativeUrl()\n
-  bank_account_dict[account_path] = bank_account_dict.get(account_path, 0) + check_operation_line.getPrice()\n
-for account_path, amount in bank_account_dict.items():\n
+  account_value = check_operation_line.getSourcePaymentValue()\n
+  account_path = account_value.getRelativeUrl()\n
+  bank_account_dict[account_path] = account_value\n
+  amount_dict[account_path] = bank_account_dict.get(account_path, 0) + check_operation_line.getPrice()\n
+for account_path, amount in amount_dict.items():\n
   error = context.BankAccount_checkBalance(account_path, amount)[\'error_code\']\n
+  source_bank_account = bank_account_dict[account_path]\n
   if error == 1:\n
     raise ValidationFailed, (Message(domain=\'ui\', message="Bank account $account is not sufficient.",\n
       mapping={"account": source_bank_account.getInternalBankAccountNumber()}), )\n
@@ -130,9 +134,11 @@ if transaction.getSimulationState() == "draft":\n
                             <string>_getitem_</string>
                             <string>transaction</string>
                             <string>bank_account_dict</string>
+                            <string>amount_dict</string>
                             <string>_getiter_</string>
                             <string>_getattr_</string>
                             <string>check_operation_line</string>
+                            <string>account_value</string>
                             <string>account_path</string>
                             <string>_write_</string>
                             <string>amount</string>
diff --git a/bt5/erp5_banking_check/bt/revision b/bt5/erp5_banking_check/bt/revision
index 073c57b52b..02416eb97c 100644
--- a/bt5/erp5_banking_check/bt/revision
+++ b/bt5/erp5_banking_check/bt/revision
@@ -1 +1 @@
-465
+467
\ No newline at end of file
-- 
2.30.9