diff --git a/bank.py b/bank.py index 52ba173bc5..4bd4d7a616 100644 --- a/bank.py +++ b/bank.py @@ -136,9 +136,15 @@ class Account(DeactivableMixin, ModelSQL, ModelView): def check_bank(self): if not self.bank or not self.bank.bic: return - if IBAN: + if IBAN and BIC: iban = IBAN(self.iban) - if iban.bic and iban.bic != self.bank.bic: + bic = BIC(self.bank.bic) + if (iban.bic + and iban.bic != bic + and ( + iban.country_code != bic.country_code + or (iban.bank_code or iban.branch_code) + not in bic.domestic_bank_codes)): raise AccountValidationError( gettext('bank.msg_invalid_iban_bic', account=self.rec_name, diff --git a/setup.py b/setup.py index a400d22bad..abbcedc8e4 100755 --- a/setup.py +++ b/setup.py @@ -138,7 +138,7 @@ setup(name=name, python_requires='>=3.7', install_requires=requires, extras_require={ - 'SWIFT': ['schwifty'], + 'SWIFT': ['schwifty>=2020.01.0'], 'test': tests_require, }, dependency_links=dependency_links,