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

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;
}

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.

$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 :

@ms=$hvatn->member_states;
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}',
);

$ok=$hvatn->check($VAT, [$member_state]);
You may either provide the VAT number under its complete form (e.g. BE-123456789, BE123456789) or either specify VAT and MS (member state) individually.
Valid MS 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
$ok=$hvatn->local_check($VAT, [$member_state]);
This method is based on regexps only and DOES NOT asks the VIES database
my $err = $hvatn->get_last_error_code();
my $txt = $hvatn->get_last_error();
Possible errors are :
If error_code > 16, you should temporarily accept the provided number, and periodically perform new checks until response is OK 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.

Just because this module's author wasn't given such time to do so. The SOAP module available at CPAN at time of writing is farly too complex to be used here, simple tasks having to be simply performed.

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

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

Bernard Nauwelaerts <bpn#it-development%be>

Many thanks to the following people, actively involved in this software development by submitting patches, bug reports, new members regexps, VIES interface changes,... :
Sorted by last intervention :

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

See http://ec.europa.eu/taxation_customs/vies/viesdisc.do 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.