stdnum.ie.vat

VAT (Irish tax reference number).

The Irish VAT number consists of 8 or 9 digits. The number is either 7 digits and 1 letter (optionally followed by a W for married women), 7 digits and 2 letters, or 6 digits and 2 letters or symbols (in second and last position).

>>> validate('IE 6433435F')  # pre-2013 format
'6433435F'
>>> validate('IE 6433435OA')  # 2013 format
'6433435OA'
>>> validate('6433435E')  # incorrect check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('8D79739I')  # old style number
'8D79739I'
>>> validate('8?79739J')  # incorrect old style
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> convert('1F23456T')
'0234561T'
stdnum.ie.vat.calc_check_digit(number)

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

stdnum.ie.vat.compact(number)

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

stdnum.ie.vat.convert(number)

Convert an “old” style 8-digit VAT number where the second character is a letter to the new 8-digit format where only the last digit is a character.

stdnum.ie.vat.is_valid(number)

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

stdnum.ie.vat.validate(number)

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