se-panfilov / jsvat Goto Github PK
View Code? Open in Web Editor NEWCheck the validity of the format of an EU VAT number
Home Page: http://se-panfilov.github.io/jsvat
License: MIT License
Check the validity of the format of an EU VAT number
Home Page: http://se-panfilov.github.io/jsvat
License: MIT License
How do I check if a specific VAT number is valid on the country "NL"?
My company is launching in Brazil next month and I wouldn't like to have to add another library to only validate the VAT in Brazil.
Do you mind if I open a PR to add this validation?
It will require some small changes to getCountry logic because Brazil VAT doesn't start with the country code and also add the /
to removeExtraChars method.
This Vat numbers are valid, but your validator and many others, report as invalid.
Ex: MRTMTT25D09F205Z or PCTCHR77S66I470H
Check this: https://validarnif.pt/pt/validar-nif-italia/ (works fine)
Given a valid vat number, I'd like to format it as usual in its country
eg, for Switzerland, CHE272990183
would be formatted as CHE-272.990.183
Hello there,
I just installed this module, and I can't get it work for some countries.
Here is an example of returns I get:
import { checkVAT, countries } from 'jsvat';
console.log(checkVat('FRXX999999999', countries).isValid) // => true
console.log(checkVat('DE999999999', countries).isValid) // => false
console.log(checkVat('BE1234567890', countries).isValid) // => false
Did I miss something ?
I've tried this:export const andorra = { name: 'Andorra', codes: ['AD', 'AND', '20'], // This codes should follow ISO standards (short, long and numeric), but it's your own business calcFn: (vat) => { return vat.length === 10; }, rules: { regex: [/^(AD)(\d{8})$/] } };
and in main file
import { andorra } from "../lib/jsvatCustom/checkNIFAndorra"; //and then: checkVAT(, [andorra])
What i am doing wrong?? I think it doesnt pass the right country to de checker
const { checkVAT, countries } = require('jsvat');
const result = checkVAT('LT100009745612', countries);
result.country.name
is Brazil and isValid = false even though both of these things aren't actually true about this VAT code
Thanks for a great library!
Two thoughts:
import { lookup } from 'jsvat';
let response = lookup('BE0411905847');
// where response would be the current response object
blocs: ['eu']
, so one could quickly check if a VAT number is within the EU VAT scheme. Could add more relevant blocks in the future if needed.Happy to hear your thoughts!
It seems there is an issue with VAT validation for Poland.
According to this wikipedia page (https://pl.wikipedia.org/wiki/Numer_identyfikacji_podatkowej) and the spec here (https://romek.info/ut/nip-rego.html#nip) the following numbers are invalid VAT numbers:
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
.nvmrc
with the new oneIf you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Hi,
Great library! I just updated and trying to make it work again. Before we didn't need to hand in a country. Now it looks like it's required? How can I hand in all countries without importing all of them specifically? I tried
import {checkVAT, europe} from 'jsvat';
checkVAT(vatNumber, [europe]);
When logging this, it says that country is undefined. How come? What am I doing wrong?
country: undefined
isValid: false
value: "RO19"
I ran into a 'bug' where the system said the VAT number is valid, when it was actually not.
checkVAT('BE0740-509975', countries) return true, because the library automatically clears the special characters (https://github.com/se-panfilov/jsvat/blob/master/src/lib/jsvat.ts#L107)
Would it be possible to add an attribute that specifies if the client actually wants to remove those characters?
I don't mind submitting a PR, if you don't have the time to implement this.
Thanks for your library!
Any plans to make the latest version compatible with Internet Explorer 11 ?
Hello,
I just made npm i jsvat but i am unable to use it in node. How can it be done? With require givens error with your example using import also gives an error. Am using node 12.3.1. With the import command ives error in the first {. With the require complains about the main reference. Thank you
https://caniuse.com/#feat=bigint
Workaround: This library works as a polyfill. Or JSBI, which is a pure-JavaScript implementation of the official ECMAScript BigInt proposal (BTW, why not simple user Number
?)
^(BE)(0?\d{9})$
to ^(BE)([0-1]?\d{9})$
if (Number(newVat.slice(1, 2)) === 0) return false;
this const newVat = vat.length === 9 ? '0' + vat : vat;
Error if jsvat is used with Jest during test.
(Works fine elsewhere)
Details:
C:\Projets\bp-client\node_modules\jsvat\dist\index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export { austria } from './lib/countries/austria';
^^^^^^
SyntaxError: Unexpected token export
jsvat : 2.0.1
There seems to be no support for south korea and australia.
Currently library is using the following condition to check office code part of VAT number:
// italy.js
temp = +vat.slice(7, 10)
if ((temp < 1) || (temp > 201) && temp !== 999 && temp !== 888) {
return false
}
According to Wikipedia (https://it.wikipedia.org/wiki/Partita_IVA) the range should be 1-121. BTW I am not Italian so I am not 100% sure, just the other backend VAT validation library that I use accepts only vats with office number in range 1-121 and 888 and 999. Is this a mistake or is my other validation library not up to date?
FR allows for 2 letters instead of digits, /^(FR)([A-HJ-NP-Z]{2}\d{9})$/
What value do the letters have?
It doesn't seem like this library does anything in this case.
New VAT Codes were introduced in the Netherlands at the start of the year (https://www.belastingdienst.nl/wps/wcm/connect/bldcontenten/belastingdienst/business/vat/new-vat-id/)
It appears that although in the same format as before NLXXXXXXXXXBXX (where X is a digit) the checksum calculation no longer works.
Codes that validate on VIES return false on https://se-panfilov.github.io/jsvat/
Would you consider functionality / accept a PR to implement a VIES lookup? The EU offers a GUI (http://ec.europa.eu/taxation_customs/vies) and an API endpoint.
Using the <script>
tag inside a webpage loading index.js
from umd
package, it will not generate any functions, and checkVAT
and other methods are undefined
.
How can I use this library on a simple webpage?
I found that by default country code for GB is optional. So for example both GB000472631 and 000472631 are valid VAT numbers. We would like to accept only VAT numbers with country code.
Would it be possible to make it configurable what country is default if any?
Because of Brexit, it seems businesses in Northern Ireland must use the 'XI' prefix rather than 'GB' in some circumstances.
https://ec.europa.eu/taxation_customs/sites/taxation/files/use_of_gb_and_xi_codes_guidance.pdf
VAT number: NL002198178B09
result: invalid
expected: valid
Hi all,
We're trying to use the library at my company and we're having trouble having the es6 version work with our system.
As a workaround we are currently using the commonjs version but we're trying to figure out why the es6 version didn't work and were looking for some help.
Our react app is not ejected but we're using this babel config file to do the parsing of code:
module.exports = {
presets: [
'@babel/preset-flow',
'@babel/preset-react',
[
'@babel/preset-env',
{
targets: '>0.25%',
},
],
'module:metro-react-native-babel-preset',
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
'dynamic-import-node',
'react-native-web',
],
overrides: [
{
test: ['./src/**/*.ts'],
presets: [
'@babel/preset-typescript',
'@babel/preset-react',
[
'@babel/preset-env',
{
targets: '>0.25%',
},
],
],
},
],
};
Weirdly enough, we are using other libraries in node_modules that make use of es6 language constructs without any issues.
This is our dependency tree:
"@babel/cli": "^7.0.0",
"@babel/core": "7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/preset-env": "^7.7.1",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.8.3",
"@babel/preset-typescript": "^7.7.2",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^9.0.0",
"babel-jest": "^23.4.2",
"babel-plugin-react-native-web": "^0.11.2",
"cross-env": "^5.1.4",
Any ideas?
Wouldn't it be good idea to provide a kind of import mechanism for countries.
So you would be able to be more dynamic and to get only the necessarily code downloaded to the client (browser).
Currently unit tests are ran against one of the generated JavaScript bundles.
I think we want to run our tests against the TypeScript files, this will also give us insight into the code coverage.
I realize that the regex expression just uses the validation for Collective Persons (14 digits), but the Individual Persons have 11 digits NNN.NNN.NNN-NN (11 digits)
Can you please fix this problem for Brazilian vat numbers?
There is an issue with the vat validation for Belgium.
Actually, vat format is BE0 + 9 numbers.
Using your validator with the example :
checkVAT('BE0411905847', [belgium]); // true: accept only Belgium VATs
is working but the issue is with this format (without the zero)
checkVAT('BE411905847', [belgium]); // return true but should be false
There should be one or more regexp to find out if a string is the beginning of a vat number for a country
eg: if it starts with FI, it could return that this is an invalid vat number that looks like it's from Finland
I think compiled code should not be included in the git repository.
Instead, it should be generated during the build and published in the release.
See also: https://kentcdodds.com/blog/why-i-dont-commit-generated-files-to-master
Hi,
When I use this library to validate the Czech VAT number "CZ699000899", is returns false, yet when I use the site of VIES (http://ec.europa.eu/taxation_customs/vies/) it says that the VAT number is valid.
Maybe the validation rules changed of perhaps there is an error in the validation? According to the code this should be a Czech Individuals type 2 number.
Kind regards
Hello! Are there any plans to update the library for GB and XI vat codes?
https://ec.europa.eu/taxation_customs/sites/taxation/files/use_of_gb_and_xi_codes_guidance.pdf
Hi, i was wondering if this library was still under active development?
Hi, thanks for the validator.
I see in germany there are vat number and tax number: https://allaboutberlin.com/guides/german-tax-id-steuernummer#:~:text=The%20Steueridentifikationsnummer%2C%20Steuerliche%20Identifikationsnummer%2C%20Pers%C3%B6nliche,%2212%20345%20678%20901%22
I's possible to add this validation to german validation? Thx
Is there a possibility to know if VAT validation for specific country is supported?
We have a use case where customer submits WEB form with his name, address and VAT number etc and we should be able to validate at minimum EU VAT numbers.
Now this library works great as long as the customer is from supported countries.
If the customer is for example from Canada or India and enters their local VAT Id, response is similar as it would be for invalid VAT.
Yes I could build hard-coded list of country ISO codes and then validate VAT only for the supported ones but it would be more future proof if I could get the list of supported country ISO codes from lib or if validation response could somehow differentiate between unsupported country / invalid VAT?
For input placeholders I'd like to be able to generate a fake vat number from a country, the number should probably only look like a vat number for this country but not be a valid one
one example of each is enough, they don't have to be randomly generated (in fact event better if there's only one by country because it would be distracting if the number changed on page refresh)
When validating Swedish VAT numbers, the result is always false with real-world VAT numbers, such as:
556012-5790
969728-1989
716453-0326
I have tried both SE and SV as country code and both return false.
Hi,
I just updated to 2.1.2. It all works great and I can check now against all countries. Unfortunately a problem with the production build happened. We use webpack and babel to build. We run our code through babel but not the vendor files so everything es6 related breaks browsers that can't handle es6.
Would it be possible to avoid using es6 features? This error happened when UglifyJs tried to do it's thing. Here the error:
ERROR in 22-chunk.js from UglifyJs Unexpected token: keyword «const» [./node_modules/jsvat/lib/es6/lib/countries/austria.js:1,7]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.