stdnum.gb.vat

VAT (United Kingdom (and Isle of Man) VAT registration number).

The VAT number can either be a 9-digit standard number, a 12-digit standard number followed by a 3-digit branch identifier, a 5-digit number for government departments (first two digits are GD) or a 5-digit number for health authorities (first two digits are HA). The 9-digit variants use a weighted checksum.

>>> validate('GB 980 7806 84')
'980780684'
>>> validate('802311781')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('980780684')
'980 7806 84'
Traceback (most recent call last):
    ...
InvalidChecksum: ...
stdnum.gb.vat.checksum(number)

Calculate the checksum. The checksum is only used for the 9 digits of the number and the result can either be 0 or 42.

stdnum.gb.vat.compact(number)

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

stdnum.gb.vat.format(number)

Reformat the passed number to the standard format.

stdnum.gb.vat.is_valid(number)

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

stdnum.gb.vat.validate(number)

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

Previous topic

stdnum.fr.tva

Next topic

stdnum.gr.vat