mdomke / schwifty

IBAN parsing and validation
https://schwifty.readthedocs.io
MIT License
205 stars 78 forks source link

Branch_code merged by error in account_code for some country like France #3

Closed splanquart closed 2 years ago

splanquart commented 7 years ago

Hello,

Thanks for your work on this lib.

I start to test it and I discover that you don't return a branch_code for IBAN start by 'FR'. I discover that the spec for FR IBAN is : On wikipedia we can read that the official format is FRkk bbbb bsss sscc cccc cccc cxx with sssss represent the branch code and xx the National check digits (ref: https://en.wikipedia.org/wiki/International_Bank_Account_Number).

Why you decide to merge bank code and account number ? What is the best way to fix this problem ?

A+

mdomke commented 7 years ago

Hi @splanquart, schwifty uses the IBAN registry provided by SWIFT to parse the country specific structure of the IBAN. I'm referring to this document, which gets automatically parsed and transformed into a JSON-file that is included in the source. If you say that this is wrong, it might be necessary to patch the parse result.

splanquart commented 7 years ago

This document is correct, we can read FR2!n5!n5!n11!c2!n for IBAN structure et 5!n5!n11!c2!n for BBAN structure.

I try to use scripts/get_iban_registry.py without success for moment.

$ python get_iban_registry.py
Traceback (most recent call last):
  File "get_iban_registry.py", line 49, in <module>
    codes = re.findall(r'[A-Z]{2}', row['country code as defined in iso 3166'])
KeyError: 'country code as defined in iso 3166'

I suppose the document structure was evolved between the last time that you used it and now but I don't know how to change the parser to read the new document.

acatton commented 7 years ago

Hé Stéphane,

J'ai l'impression qu'il y a une barrière de la langue. La structure de l'IBAN, et la role de chaque éléments est automatiquement générée. Le document en question ne spécifie pas quel est le role du deuxième 5!n. Le document ne dit juste que ce deuxième numéro existe.

Après quelque recherches sur le sujet, il semble que tu as raison, et que ce second numéro est en fait le "code guichet". Mais pour implémenter cette fonctionalité, il faut modifier le script qui génère l'algorithme d'interprétation de l'IBAN, et ajouter la possibilité de personaliser la génération pour certain pays sans respecter à la lettre le document original.

Vu que l'on veux aller à l'international, et peut être un jour attaquer le marcher français, c'est quelque chose que l'on veux mettre en place. Malheureusement, je ne peux pas te donner une date exacte quand ceci sera implémenté.

Si tu veux faire une pull request à ce sujet, on l'examinera et la mergera sans problème.

For non french speakers following the conversation:

Stephan,

I feel there's a language barrier here. The IBAN structure and the function of each elements is inferred from the documents linked by Martin. This document doesn't define the role of the second 5!n, it just says that it is part of the iban structure.

After some research, it appears that you're right, and this second number is actually the "code guichet" (branch code). However, to implement this we need to modify our parsing script to support to manually specify hooks for specific countries.

As we want to internationalize, and someday go to France, that is something we want to support in the future, but I can't give you an exact timeline right now.

If you want to do a pull request regarding this, we'll have no problem reviewing and merging it.