stdnum.lv.pvn

PVN (Pievienotās vērtības nodokļa, Latvian VAT number).

The PVN is a 11-digit number that can either be a reference to a legal entity (in which case the first digit > 3) or a natural person (in which case it should be the same as the personal code (personas kods)). Personal codes start with 6 digits to denote the birth date in the form ddmmyy.

>>> validate('LV 4000 3521 600')
'40003521600'
>>> validate('40003521601')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('161175-19997')  # personal code
'16117519997'
>>> validate('161375-19997')  # invalid date
Traceback (most recent call last):
    ...
InvalidComponent: ...
stdnum.lv.pvn.calc_check_digit_pers(number: str) str

Calculate the check digit for personal codes. The number passed should not have the check digit included.

stdnum.lv.pvn.checksum(number: str) int

Calculate the checksum for legal entities.

stdnum.lv.pvn.compact(number: str) str

Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

stdnum.lv.pvn.get_birth_date(number: str) date

Split the date parts from the number and return the birth date.

stdnum.lv.pvn.is_valid(number: str) bool

Check if the number is a valid VAT number.

stdnum.lv.pvn.validate(number: str) str

Check if the number is a valid VAT number. This checks the length, formatting and check digit.