arthurdejong / python-stdnum

A Python library to provide functions to handle, parse and validate standard numbers.
https://arthurdejong.org/python-stdnum/
GNU Lesser General Public License v2.1
498 stars 206 forks source link

Swiss ESR verification #170

Closed kurtkeller closed 4 years ago

kurtkeller commented 4 years ago

Added a module for Swiss ESR numbers (reference number on Swiss payment slips).

I added this module because I started to use qrbill for creating the new standard Swiss payment slips. qrbill uses validators for IBAN validation, but sofar does not do any validation on reference numbers. I intend to change validations over from validators to stdnum, since stdnum has all the required validations, excpet for ESR, which can be added with this pull request.

arthurdejong commented 4 years ago

Hi Kurt,

Thanks for your contribution. I've merged it as a45d4f7. The changes to README, ChangeLog and documentation are more or less automatically done on release.

I've only made a few smaller changes to the code. The compact() function now strips leading zeros to ensure that all equivalent numbers end up as the same value after compact(). I've also rewritten the calc_check_digit() function to be iterative instead of recursive and made the implementation more compact.