From 9da864a690fbf398ecb5aad3bf5189979a2060a4 Mon Sep 17 00:00:00 2001
From: Kevin Deldycke <kevin@nexedi.com>
Date: Wed, 22 Jun 2005 12:29:32 +0000
Subject: [PATCH] Bug in Bank Account Numbers generation

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3308 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/BankAccount.py | 29 ++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/product/ERP5/Document/BankAccount.py b/product/ERP5/Document/BankAccount.py
index 6a7db6b6bf..4486e63b7f 100755
--- a/product/ERP5/Document/BankAccount.py
+++ b/product/ERP5/Document/BankAccount.py
@@ -38,11 +38,14 @@ import string
 
 class BankAccount(Folder, Coordinate):
     """
-    A bank account number holds a collection of numbers and codes (ex. SWIFT, RIB, etc.) which may be used to identify a bank account.
+      A bank account number holds a collection of numbers and codes
+        (ex. SWIFT, RIB, etc.) which may be used to identify a bank account.
 
-    A Bank Account is owned by a Person or an Organisation. A Bank Account contain Agents with Agent Privileges used by the owner to delegate the management of the bank account to trusted third-party Persons.
+      A Bank Account is owned by a Person or an Organisation. A Bank Account
+        contain Agents with Agent Privileges used by the owner to delegate the
+        management of the bank account to trusted third-party Persons.
 
-    BankAccount inherits from Base and from the mix-in Coordinate.
+      BankAccount inherits from Base and from the mix-in Coordinate.
     """
 
     meta_type = 'ERP5 BankAccount'
@@ -128,10 +131,10 @@ class BankAccount(Folder, Coordinate):
         branch = self.getBranch()
         ban    = self.getBankAccountNumber()
         key    = self.getBbanKey()
-        if bank   == None: bank       = ''
-        if branch == None: branch     = ''
-        if ban    == None: account_id = ''
-        if key    == None: key        = ''
+        if bank   == None: bank   = ''
+        if branch == None: branch = ''
+        if ban    == None: ban    = ''
+        if key    == None: key    = ''
         return (bank + branch + ban + key).upper()
 
 
@@ -144,10 +147,10 @@ class BankAccount(Folder, Coordinate):
         branch = self.getBranch()
         ban    = self.getBankAccountNumber()
         key    = self.getBbanKey()
-        if bank   == None: bank       = ''
-        if branch == None: branch     = ''
-        if ban    == None: account_id = ''
-        if key    == None: key        = ''
+        if bank   == None: bank   = ''
+        if branch == None: branch = ''
+        if ban    == None: ban    = ''
+        if key    == None: key    = ''
         return sep.join([bank, branch, ban, key]).upper()
 
 
@@ -170,10 +173,12 @@ class BankAccount(Folder, Coordinate):
         if bank   == None: bank   = ''
         if branch == None: branch = ''
         if ban    == None: ban    = ''
+        if len(bank + branch + ban) == 0:
+          return ''
 
         bank   += ('0' * (5 - len(bank)))
         branch += ('0' * (5 - len(branch)))
 
         s = (bank + branch + ban).upper()
         key = str(97 - ((transcode(s) * 100) % 97))
-        return key.zfill(2)
+        return key.zfill(2)
\ No newline at end of file
-- 
2.30.9