yolk/valvat — pull request #15 by kirichkov (2013-02-24 11:33:58+00:00)
Title: Added Checksum::BG

Some notes:
I've checked in two commits on purpose. So far I've identified three types of validatable VAT IDs which use different checksum algorithms - legal entities, local natural persons, foreign natural persons.

Unfortunately local and foreign natural persons cannot be programatically distinguished. They both have 10 digits length and can only differ by their checksum digit. The solution I did is not very elegant, but I preferred it to making changes in the other code and possibly breaking something else. Please check the method check_digit_natural_person in lib/valvat/checksum/bg.rb as it can use some refactoring.

The test case's IDs are randomly generated using the algorithm, as according to Bulgarian law that data is treated as protected by privacy law. I've done testing on real IDs, to which I have lawful access, prior to switching them to randomly generated ones.