stdnum.fr.tva

n° TVA (taxe sur la valeur ajoutée, French VAT number).

The n° TVA (Numéro d’identification à la taxe sur la valeur ajoutée) is the SIREN (Système d’Identification du Répertoire des Entreprises) prefixed by two digits. In old style numbers the two digits are numeric, with new style numbers at least one is a alphabetic.

>>> compact('Fr 40 303 265 045')
'40303265045'
>>> validate('23334175221')
'23334175221'
>>> validate('84 323 140 391')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('K7399859412')  # new-style number
'K7399859412'
>>> validate('4Z123456782')  # new-style number starting with digit
'4Z123456782'
>>> validate('IO334175221')   # the letters cannot by I or O
Traceback (most recent call last):
    ...
InvalidFormat: ...
stdnum.fr.tva.compact(number)

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

stdnum.fr.tva.is_valid(number)

Check if the number is a valid VAT number.

stdnum.fr.tva.validate(number)

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