NAME

Business::Tax::VAT::Validation - A class for european VAT numbers validation.

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 you a easy api to check validity of european VAT numbers (if the provided number exists).

It asks the EU database for this.

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 : 

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 VAT number format ouside this module, eg. embedded as javascript in web form.

%re=$hvatn->regular_expressions;

returns

    (
	AT          =>  'U[0-9]{8}',
	...
	SK	    =>  '[0-9]{10}',
    );

METHODS

check - Checks if a VAT number exists into the VIES database
$ok=$hvatn->check($VAT, [$member_state]);

You may either provide the VAT number under its complete form (e.g. BE-123456789, BE123456789 or BE 123 456 789) or either specify VAT and MS (member state) individually.

Valid MS values are :

AT, BE, CY, CZ, DE, DK, EE, EL, ES, FI, 
FR, GB, HU, IE, IT, LU, LV, MT, NL, PL,
PT, SE, SI, SK
local_check - Checks if a VAT number format is valid
$ok=$hvatn->local_check($VAT, [$member_state]);

This method is based on regexps only and DOES NOT asks the VIES database
get_last_error - Return the last recorded error
$hvatn->get_last_error();

Possible errors are :

- Unknown MS code : Internal checkup failed (Specified MS does not exists) - Invalid VAT number format : Internal checkup failed (bad syntax) - This VAT number doesn't exists in EU database : distant checkup - This VAT number contains errors : distant checkup - Time out connecting to the database : Temporary error when the connection to the database times out - Member Sevice Unavailable: The EU database is unable to reach the requested member's database. - 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.

Other documentation

Jetez un oeil sur http://www.it-development.be/software/PERL/Business-Tax-VAT-Validation/ pour la documentation en français.

Feedback

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

AUTHOR

Bernard Nauwelaerts <bpn#it-development%be>

LICENSE

GPL. Enjoy ! See COPYING for further informations on the GPL.

Credits

Thanks to Robert Alloway for providing us internal checkup regexp's for VAT numbers, and the patch adding 10 new members.
Thanks to Tom Kirkpatrick for his proxy support suggestion.
Thanks to Torsten Mueller to inform me about $baseurl modification.

Disclaimer

See http://ec.europa.eu/taxation_customs/vies/en/viesdisc.htm to known the limitations of the EU 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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 307:

Non-ASCII character seen before =encoding in 'français.'. Assuming UTF-8