From e534221245a01aff8613e89b3c2556bc6c87e34c Mon Sep 17 00:00:00 2001 From: Raffael Meyer Date: Wed, 24 Apr 2019 16:22:34 +0200 Subject: [PATCH] fix: validate IBAN only if it exists --- erpnext/accounts/doctype/bank_account/bank_account.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/bank_account/bank_account.py b/erpnext/accounts/doctype/bank_account/bank_account.py index e71fca256ea..20ce7ca9a4c 100644 --- a/erpnext/accounts/doctype/bank_account/bank_account.py +++ b/erpnext/accounts/doctype/bank_account/bank_account.py @@ -21,9 +21,7 @@ class BankAccount(Document): def validate(self): self.validate_company() - - if self.iban: - self.validate_iban() + self.validate_iban() def validate_company(self): if self.is_company_account and not self.company: @@ -33,6 +31,10 @@ class BankAccount(Document): ''' Algorithm: https://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN ''' + # IBAN field is optional + if not self.iban: + return + def encode_char(c): # Position in the alphabet (A=1, B=2, ...) plus nine return str(9 + ord(c) - 64)