Skip to main content

VAT validation for Python

Project description

https://travis-ci.org/iconfinder/pyvat.png?branch=master

With EU VAT handling rules becoming ever more ridiculous and complicated, businesses within the EU are faced with the complexity of having to validate VAT numbers. pyvat was built for Iconfinder’s marketplace to handle just this problem.

Validation of VAT numbers is performed in two steps: firstly, the VAT number is checked against an expression for the given country if one such is available, after which it is checked against a registry if one such is available.

Supported countries and registries

As of the current version, pyvat has VAT number validation expressions for the following countries:

ISO 3166-1-alpha-2

Country

Reference

AT

Austria

VIES FAQ Q11

BE

Belgium

VIES FAQ Q11

BG

Bulgaria

VIES FAQ Q11

CY

Cyprus

VIES FAQ Q11

CZ

Czech Republic

VIES FAQ Q11

DE

Germany

VIES FAQ Q11

DK

Denmark

VIES FAQ Q11

EE

Estonia

VIES FAQ Q11

EL

Greece

VIES FAQ Q11

ES

Spain

VIES FAQ Q11

FI

Finland

VIES FAQ Q11

FR

France

VIES FAQ Q11

GB

United Kingdom

VIES FAQ Q11

HU

Hungary

VIES FAQ Q11

IE

Ireland

VIES FAQ Q11

IT

Italy

VIES FAQ Q11

LT

Lithuania

VIES FAQ Q11

LU

Luxembourg

VIES FAQ Q11

LV

Latvia

VIES FAQ Q11

MT

Malta

VIES FAQ Q11

NL

The Netherlands

VIES FAQ Q11

PL

Poland

VIES FAQ Q11

PT

Portugal

VIES FAQ Q11

RO

Romania

VIES FAQ Q11

SE

Sweden

VIES FAQ Q11

SK

Slovakia

VIES FAQ Q11

The VAT numbers for the following countries can furthermore be validated against a registry:

ISO 3166-1-alpha-2

Country

Registry

AT

Austria

VIES web service

BE

Belgium

VIES web service

BG

Bulgaria

VIES web service

CY

Cyprus

VIES web service

CZ

Czech Republic

VIES web service

DE

Germany

VIES web service

DK

Denmark

VIES web service

EE

Estonia

VIES web service

EL

Greece

VIES web service

ES

Spain

VIES web service

FI

Finland

VIES web service

FR

France

VIES web service

GB

United Kingdom

VIES web service

HU

Hungary

VIES web service

IE

Ireland

VIES web service

IT

Italy

VIES web service

LT

Lithuania

VIES web service

LU

Luxembourg

VIES web service

LV

Latvia

VIES web service

MT

Malta

VIES web service

NL

The Netherlands

VIES web service

PL

Poland

VIES web service

PT

Portugal

VIES web service

RO

Romania

VIES web service

SE

Sweden

VIES web service

SK

Slovakia

VIES web service

Installation

To install requests, do yourself a favor and don’t use anything other than pip:

$ pip install pyvat

Usage

pyvat exposes its functionality through two simple methods:

pyvat.is_vat_number_valid(vat_number, country_code=None)

Test if a VAT number is valid.

If possible, the VAT number will be checked against available registries.

Parameters:
  • vat_number – VAT number to validate.

  • country_code – Optional country code. Should be supplied if known, as there is no guarantee that naively entered VAT numbers contain the correct alpha-2 country code prefix for EU countries just as not all non-EU countries have a reliable country code prefix. Default None prompting detection.

Returns:

True if the VAT number can be fully asserted as valid or False if not, otherwise None indicating that the VAT number may or may not be valid.

pyvat.is_vat_number_format_valid(vat_number, country_code=None)

Test if the format of a VAT number is valid.

Parameters:
  • vat_number – VAT number to validate.

  • country_code – Optional country code. Should be supplied if known, as there is no guarantee that naively entered VAT numbers contain the correct alpha-2 country code prefix for EU countries just as not all non-EU countries have a reliable country code prefix. Default None prompting detection.

Returns:

True if the VAT number can be fully asserted as valid or False if not, otherwise None indicating that the VAT number may or may not be valid.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvat-1.1.0.tar.gz (5.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page