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

Add support for Belarus TIN #196

Closed unho closed 4 years ago

unho commented 4 years ago

According to http://192.167.108.132/img/VAT_by_Countries.pdf and https://en.wikipedia.org/wiki/VAT_identification_number it is called "УНП" (short for "Учетный номер плательщика") and it is a 9 digit number (for example 190190190).

arthurdejong commented 4 years ago

Hi @unho, Do you happen to know how the check digit is calculated over personal numbers? E.g. WikiPedia mentions МА1953681 but neither using the values in the area table or the values in the last table (Разлік УНП для фізічных асоб) seem to result in a valid check digit. Also, that last section seems to suggest that the check digit should also be a letter for personal numbers which the example isn't.

unho commented 4 years ago

@arthurdejong Unfortunately I have no more information on the matter than the one included in the ticket and in the links included in the ticket.

Given that the Wikipedia page provides an algorithm to calculate the check digit I was sincerely hoping this would be easy. I thought I had hit jackpot here, since looking for data on another language written on a different script than mine is not an easy task.

As you may have already noticed my focus is to add VAT number validation in stdnum, but this country is not a top priority for me, so if you feel encouraged it is all yours.

arthurdejong commented 4 years ago

I managed to find a better source for the check digit algorithm and it actually turns out the example on Wikipedia as well as in the page linked on Wikipedia was incorrect (I fixed the Wikipedia page). Researching the Russian texts was not easy. ;)

Fun fact: it turns out that the M and A in МА1953684 are actually not always the ASCII M and A but can be the Cyrillic flavour, adding another fun challenge.

unho commented 4 years ago

Great, another one down.

AFAICT in Europe we are only missing Ukraine, North Macedonia, Montenegro, Bosnia and Herzegovina, Liechtenstein and Faeroe Islands (and the Vatican?).