changeset 4dff0dd49e8d in modules/bank:6.4
details: https://hg.tryton.org/modules/bank?cmd=changeset&node=4dff0dd49e8d
description:
        Test country code and bank/branch code when guessed BIC is different

        In France the same bank code can have multiple BIC, schwifty guess only 
the
        last one so we must check that the current bank does not have a valid 
country
        and bank/branch code for the IBAN.

        issue11508
        review445091003
        (grafted from faf70819ff374f4de414b986f817768489660e88)
diffstat:

 bank.py  |  10 ++++++++--
 setup.py |   2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r b1dd3c2696de -r 4dff0dd49e8d bank.py
--- a/bank.py   Tue May 31 23:53:01 2022 +0200
+++ b/bank.py   Tue May 31 23:59:02 2022 +0200
@@ -136,9 +136,15 @@
     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 -r b1dd3c2696de -r 4dff0dd49e8d setup.py
--- a/setup.py  Tue May 31 23:53:01 2022 +0200
+++ b/setup.py  Tue May 31 23:59:02 2022 +0200
@@ -138,7 +138,7 @@
     python_requires='>=3.7',
     install_requires=requires,
     extras_require={
-        'SWIFT': ['schwifty'],
+        'SWIFT': ['schwifty>=2020.01.0'],
         'test': tests_require,
         },
     dependency_links=dependency_links,

Reply via email to