stdnum.eu.vat

VAT (European Union VAT number).

The European Union VAT number consists of a 2 letter country code (ISO 3166-1, except Greece which uses EL) followed by a number that is allocated per country.

The exact format of the numbers varies per country and a country-specific check is performed on the number using the VAT module that is relevant for that country.

>>> compact('ATU 57194903')
'ATU57194903'
>>> validate('BE697449992')
'BE0697449992'
>>> validate('FR 61 954 506 077')
'FR61954506077'
>>> guess_country('00449544B01')
['nl']
stdnum.eu.vat.MEMBER_STATES = {'at', 'be', 'bg', 'cy', 'cz', 'de', 'dk', 'ee', 'es', 'fi', 'fr', 'gr', 'hr', 'hu', 'ie', 'it', 'lt', 'lu', 'lv', 'mt', 'nl', 'pl', 'pt', 'ro', 'se', 'si', 'sk', 'xi'}

The collection of country codes that are queried. Greece is listed with a country code of gr while for VAT purposes el is used instead. For Northern Ireland numbers are prefixed with xi of United Kingdom numbers.

stdnum.eu.vat.check_vies(number, timeout=30)

Query the online European Commission VAT Information Exchange System (VIES) for validity of the provided number. Note that the service has usage limitations (see the VIES website for details). The timeout is in seconds. This returns a dict-like object.

stdnum.eu.vat.check_vies_approx(number, requester, timeout=30)

Query the online European Commission VAT Information Exchange System (VIES) for validity of the provided number, providing a validity certificate as proof. You will need to give your own VAT number for this to work. Note that the service has usage limitations (see the VIES website for details). The timeout is in seconds. This returns a dict-like object.

stdnum.eu.vat.compact(number)

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

stdnum.eu.vat.guess_country(number)

Guess the country code based on the number. This checks the number against each of the validation routines and returns the list of countries for which it is valid. This returns lower case codes and returns gr (not el) for Greece.

stdnum.eu.vat.is_valid(number)

Check if the number is a valid VAT number. This performs the country-specific check for the number.

stdnum.eu.vat.validate(number)

Check if the number is a valid VAT number. This performs the country-specific check for the number.

stdnum.eu.vat.vies_wsdl = 'https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'

The WSDL URL of the VAT Information Exchange System (VIES).