Closed okfish closed 7 years ago
Thanks for your pull request!
However, there are some problems with it. Could you try to fix the following points:
Perhaps you could add something like this (preferably with tests and docstring!):
def _get_check_digit(to_check, factors, mod=11):
return sum(int(to_check[i]) * factors[i] for i in range(len(factors))) % mod
... and then include something like this as a check:
if len(rest) == 10 and not _get_check_digit(rest, [2, 4, 10, 3, 5, 9, 4, 6, 8]) % 10 != int(rest[10]):
raise ValidationError(self.country_failure % {'country': country})
The Dutch check could then also be updated using this _get_check_digit method.
Slightly localized for Russian VAT numbers validator with additional test for checksums etc. Proudly stolen from vatnumber package, exactly fom https://github.com/eostman/vatnumber/blob/master/vatnumber/__init__.py#L389