bankster
bankster copied to clipboard
Add structure to allow guessing of BIC based on IBAN
This is a functionality I need for my own project, but I can imagine it would be useful for others as well so I'm submitting it.
As a side note before I explain my changes, this also adds support for Sudan (SD) and Lybia (LY) to the IBAN list.
Basically, I've gone through all the IBAN regexes and added capturing groups to separately capture what can identify the exact bank the IBAN belongs to. In all cases, this is either a single group for just the bank (either directly as a string or as some numerical code) or two groups in which the first is the bank identifier and the second is the branch identifier.
Because there are significantly more banks than there are countries, I've only added proof-of-concept support for The Netherlands (my country), but the approach should be largely similar. After analyzing the IBAN with the associated regex, the captured groups can be passed along to the calculate_bic method. This method should be specifically implemented per country because every country has their own way they denote bank information in their IBAN. Hopefully, users of this library that want to support their own countries can create patches as needed.
There's a good amount of IBANs to which I did not yet add capturing groups. These are annotated with # No auto-BIC and are unsupported because I could not figure out what country they belong to or that countries particular IBAN structure.
Many thanks for your PR. I'll review it soon, but currently I've a lot of work and unfortunately no time.