SYNOPSIS

  use Business::Tax::VAT::Validation;

  my $hvatn=Business::Tax::VAT::Validation->new();

  # Check number
  if ($hvatn->check($VAT, [$member_state])){
        print "OK\n";
  } else {
        print $hvatn->get_last_error;
  }

DESCRIPTION

This class provides an easy api to check european \s-1VAT\s0 numbers' syntax, and if they has been registered by the competent authorities.

It asks the \s-1EU\s0 database (\s-1VIES\s0) for this, using its \s-1SOAP\s0 interface methods.

CONSTRUCTOR

new Class constructor.

$hvatn=Business::Tax::VAT::Validation->new();

If your system is located behind a proxy :

$hvatn=Business::Tax::VAT::Validation->new(-proxy => ['http', 'http://example.com:8001/']);

Note : See LWP::UserAgent for proxy options.

PROPERTIES

member_states Returns all member states 2-digit codes as array

@ms=$hvatn->member_states;

regular_expressions - Returns a hash list containing one regular expression for each country

If you want to test a \s-1VAT\s0 number format ouside this module, e.g. embedded as javascript in a web form. %re=$hvatn->regular_expressions; returns ( AT => 'U[0-9]{8}', ... SK => '[0-9]{10}', );

METHODS

check - Checks if a \s-1VAT\s0 number exists in the \s-1VIES\s0 database

$ok=$hvatn->check($vatNumber, [$countryCode]); You may either provide the \s-1VAT\s0 number under its complete form (e.g. \s-1BE-123456789\s0, \s-1BE123456789\s0) or specify the \s-1VAT\s0 and \s-1MSC\s0 (vatNumber and countryCode) individually. Valid \s-1MS\s0 values are : AT, BE, BG, CY, CZ, DE, DK, EE, EL, ES, FI, FR, GB, HU, IE, IT, LU, LT, LV, MT, NL, PL, PT, RO, SE, SI, SK

local_check - Checks if a \s-1VAT\s0 number format is valid This method is based on regexps only and \s-1DOES\s0 \s-1NOT\s0 ask the \s-1VIES\s0 database

$ok=$hvatn->local_check($VAT, [$member_state]);

informations - Returns informations related to the last validated \s-1VAT\s0 number

%infos=$hvatn->informations();

get_last_error_code - Returns the last recorded error code
get_last_error - Returns the last recorded error

my $err = $hvatn->get_last_error_code(); my $txt = $hvatn->get_last_error(); Possible errors are :

  • -1 The provided \s-1VAT\s0 number is valid.

  • 0 Unknown \s-1MS\s0 code : Internal checkup failed (Specified Member State does not exist)

  • 1 Invalid \s-1VAT\s0 number format : Internal checkup failed (bad syntax)

  • 2 This \s-1VAT\s0 number doesn't exist in \s-1EU\s0 database : distant checkup

  • 3 This \s-1VAT\s0 number contains errors : distant checkup

  • 17 Time out connecting to the database : Temporary error when the connection to the database times out

  • 18 Member Sevice Unavailable: The \s-1EU\s0 database is unable to reach the requested member's database.

  • 19 The \s-1EU\s0 database is too busy.

  • 20 Connexion to the \s-1VIES\s0 database failed.

  • 21 The \s-1VIES\s0 interface failed to parse a stream. This error occurs unpredictabely, so you should retry your validation request.

  • 257 Invalid response, please contact the author of this module. : This normally only happens if this software doesn't recognize any valid pattern into the response document: this generally means that the database interface has been modified, and you'll make the author happy by submitting the returned response !!!

  • 500 The \s-1VIES\s0 server encountered an internal server error. Error 500 : soap:Server \s-1TIMEOUT\s0 Error 500 : soap:Server \s-1MS_UNAVAILABLE\s0

If error_code > 16, you should temporarily accept the provided number, and periodically perform new checks until response is \s-1OK\s0 or error < 17 If error_code > 256, you should temporarily accept the provided number, contact the author, and perform a new check when the software is updated.

RELATED TO Business::Tax::VAT::Validation…

LWP::UserAgent

http://ec.europa.eu/taxation_customs/vies/faqvies.do for the FAQs related to the \s-1VIES\s0 service.

FEEDBACK

If you find this module useful, or have any comments, suggestions or improvements, feel free to let me know.

AUTHOR

Bernard Nauwelaerts <[email protected]>

CREDITS

Many thanks to the following people, actively involved in the development of this software by submitting patches, bug reports, new members regexps, \s-1VIES\s0 interface changes,... (sorted by last intervention) :

  • Gregor Herrmann, Debian.

  • Graham Knop.

  • Bart Heupers, Netherlands.

  • Martin H. Sluka, noris network \s-1AG\s0, Germany.

  • Simon Williams, \s-1UK2\s0 Limited, United Kingdom & Benoi\*^t Galy, Greenacres, France & Raluca Boboia, Evozon, Romania

  • Dave O., POBox, U.S.A.

  • Kaloyan Iliev, Digital Systems, Bulgaria.

  • Tom Kirkpatrick, Virus Bulletin, United Kingdom.

  • Andy Wardley, individual, United Kingdom.

  • Robert Alloway, Service Centre, United Kingdom.

  • Torsten Mueller, Archesoft, Germany

LICENSE

\s-1GPL\s0. Enjoy! See \s-1COPYING\s0 for further information on the \s-1GPL\s0.

DISCLAIMER

See http://ec.europa.eu/taxation_customs/vies/viesdisc.do to known the limitations of the \s-1EU\s0 validation service.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.