Giter Site home page Giter Site logo

itaibo / vies-checker Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 234 KB

European VIES VAT number validator

Home Page: https://npmjs.com/vies-checker

License: MIT License

Shell 5.69% TypeScript 94.31%
europe vies vat-number-validation vat-number validator

vies-checker's People

Contributors

itaibo avatar pano9000 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

pano9000

vies-checker's Issues

userError in response should be handled

Hi,

I have ran into some issue today, where I would get inconsistent results back from the isValid function in vies-checker:
I was testing it with a German VAT No, that I know is definitely valid but the tests flipped between showing "true" and "false" sometimes, which was a bit odd.

I then output the "internal" only response to the console, and by doing that I can see that the response actually contains an userError

const response = yield (0, request_js_1.default)(country, number);
console.log("vies response", response)
{
  isValid: false,
  requestDate: '2023-02-06T10:38:46.773Z',
  userError: 'MS_MAX_CONCURRENT_REQ',
  name: '---',
  address: '---',
  requestIdentifier: '',
  vatNumber: '123456789', //changed
  viesApproximate: {
    name: '---',
    street: '---',
    postalCode: '---',
    city: '---',
    companyType: '---',
    matchName: 3,
    matchStreet: 3,
    matchPostalCode: 3,
    matchCity: 3,
    matchCompanyType: 3
  }
}

However that userError is not taken into account currently, as far as I can tell, vies-checker only checks the isValid property and returns its value.
This can lead to some confusion (as it did in my case), as it states that the VAT is invalid, even if it did not actually do a check.

If I check the file here, I can see there are a few possible error messages mentioned:
https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl

In case of problems, the returned FaultString can take the following specific values: 
    - INVALID_INPUT: The provided CountryCode is invalid or the VAT number is empty; 
    - GLOBAL_MAX_CONCURRENT_REQ: Your Request for VAT validation has not been processed; the maximum number of concurrent requests has been reached. Please re-submit your request later or contact [email protected] for further information": Your request cannot be processed due to high traffic on the web application. Please try again later; 
    - MS_MAX_CONCURRENT_REQ: Your Request for VAT validation has not been processed; the maximum number of concurrent requests for this Member State has been reached. Please re-submit your request later or contact [email protected] for further information": Your request cannot be processed due to high traffic towards the Member State you are trying to reach. Please try again later. 
    - SERVICE_UNAVAILABLE: an error was encountered either at the network level or the Web application level, try again later; 
    - MS_UNAVAILABLE: The application at the Member State is not replying or not available. Please refer to the Technical Information page to check the status of the requested Member State, try again later; 
    - TIMEOUT: The application did not receive a reply within the allocated time period, try again later. 

My feeling would be to only have "INVALID_INPUT" return false, while all other exceptions should potentially be handled differently.

What do you think?

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.