Code Monkey home page Code Monkey logo

business-tax-vat-validation's Introduction

NAME

    Business::Tax::VAT::Validation - Validate EU VAT numbers against VIES

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 VAT numbers' syntax,
    and if they has been registered by the competent authorities.

    It asks the EU database (VIES) for this, using its SOAP API. Basic
    checks that the supplied VAT number fit the expected format for the
    specified EU member state are performed first, to avoid unnecessarily
    sending queries to VIES for input that could never be valid.

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 VAT 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 VAT number exists in the VIES database

          $ok=$hvatn->check($vatNumber, [$countryCode]);

      You may either provide the VAT number under its complete form (e.g.
      BE-123456789, BE123456789) or specify the VAT and MSC (vatNumber and
      countryCode) 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

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

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

    informations - Returns informations related to the last validated VAT
    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 VAT number is valid.

	* 0 Unknown MS code : Internal checkup failed (Specified Member
	State does not exist)

	* 1 Invalid VAT number format : Internal checkup failed (bad
	syntax)

	* 2 This VAT number doesn't exist in EU database : distant checkup

	* 3 This VAT 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 EU database is unable to reach
	the requested member's database.

	* 19 The EU database is too busy.

	* 20 Connexion to the VIES database failed.

	* 21 The VIES 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 VIES server encountered an internal server error. Error
	500 : soap:Server TIMEOUT Error 500 : soap:Server MS_UNAVAILABLE

      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.

SEE ALSO

    LWP::UserAgent

    http://ec.europa.eu/taxation_customs/vies/faqvies.do for the FAQs
    related to the VIES service.

FEEDBACK

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

AUTHOR

    Original author: Bernard Nauwelaerts <[email protected]>

    Maintainership since 2015: David Precious (BIGPRESH)
    <[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, VIES interface changes,... (sorted by last
    intervention) :

      * Gregor Herrmann, Debian.

      * Graham Knop.

      * Bart Heupers, Netherlands.

      * Martin H. Sluka, noris network AG, Germany.

      * Simon Williams, UK2 Limited, United Kingdom & Benoî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

    GPL3. Enjoy! See COPYING for further information on the GPL.

DISCLAIMER

    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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.