# 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: str, timeout: float = 30, verify: bool | str = True) → dict[str, str | bool | date]

  Use the EU VIES service to validate the provided number.

  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 argument specifies the network timeout in seconds.

  The verify argument is either a boolean that determines whether the server’s certificate is validate or a string which must be a path the CA certificate bundle to use for verification.

  Returns a dict-like object.

stdnum.eu.vat.check_vies_approx(number: str, requester: str, timeout: float = 30, verify: bool | str = True) → dict[str, str | bool | date]

  Use the EU VIES service to validate the provided number.

  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 argument specifies the network timeout in seconds.

  The verify argument is either a boolean that determines whether the server’s certificate is validate or a string which must be a path the CA certificate bundle to use for verification.

  Returns a dict-like object.

stdnum.eu.vat.compact(number: str) → str

  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: str) → list[str]

  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: str) → bool

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

stdnum.eu.vat.validate(number: str) → str

  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).