Socket
Socket
Sign inDemoInstall

angular-jsvat

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.7-2 to 0.6.1-1

2

bower.json
{
"name": "angular-jsvat",
"version": "0.4.7-2",
"version": "0.6.1-1",
"description": "Check the validity of the format of an EU VAT number",

@@ -5,0 +5,0 @@ "main": "./dist/angular-jsvat.js",

@@ -6,63 +6,180 @@ angular.module('jsvat', [])

var _REGEXP_LIST = {
austria: /^(AT)U(\d{8})$/,
belgium: /^(BE)(0?\d{9})$/,
bulgaria: /^(BG)(\d{9,10})$/,
switzerland: /^(CHE)(\d{9})(MWST)?$/,
cyprus: /^(CY)([0-59]\d{7}[A-Z])$/,
czech_republic: /^(CZ)(\d{8,10})(\d{3})?$/,
germany: /^(DE)([1-9]\d{8})$/,
denmark: /^(DK)(\d{8})$/,
estonia: /^(EE)(10\d{7})$/,
greece: /^(EL)(\d{9})$/,
spain: [
/^(ES)([A-Z]\d{8})$/,
/^(ES)([A-HN-SW]\d{7}[A-J])$/,
/^(ES)([0-9YZ]\d{7}[A-Z])$/,
/^(ES)([KLMX]\d{7}[A-Z])$/
],
europe: /^(EU)(\d{9})$/,
finland: /^(FI)(\d{8})$/,
france: [
/^(FR)(\d{11})$/,
/^(FR)([A-HJ-NP-Z]\d{10})$/,
/^(FR)(\d[A-HJ-NP-Z]\d{9})$/,
/^(FR)([A-HJ-NP-Z]{2}\d{9})$/
],
united_kingdom: [
/^(GB)?(\d{9})$/,
/^(GB)?(\d{12})$/,
/^(GB)?(GD\d{3})$/,
/^(GB)?(HA\d{3})$/
],
croatia: /^(HR)(\d{11})$/,
hungary: /^(HU)(\d{8})$/,
ireland: [
/^(IE)(\d{7}[A-W])$/,
/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/,
/^(IE)(\d{7}[A-W][AH])$/
],
italy: /^(IT)(\d{11})$/,
latvia: /^(LV)(\d{11})$/,
lithunia: /^(LT)(\d{9}|\d{12})$/,
luxembourg: /^(LU)(\d{8})$/,
malta: /^(MT)([1-9]\d{7})$/,
netherlands: /^(NL)(\d{9})B\d{2}$/,
norway: /^(NO)(\d{9})$/,
poland: /^(PL)(\d{10})$/,
portugal: /^(PT)(\d{9})$/,
romania: /^(RO)([1-9]\d{1,9})$/,
russia: /^(RU)(\d{10}|\d{12})$/,
serbia: /^(RS)(\d{9})$/,
slovenia: /^(SI)([1-9]\d{7})$/,
slovakia_republic: /^(SK)([1-9]\d[2346-9]\d{7})$/,
sweden: /^(SE)(\d{10}01)$/
var CONDITIONS = {
austria: {
multipliers: [1, 2, 1, 2, 1, 2, 1],
regex: /^(AT)U(\d{8})$/
},
belgium: {
regex: /^(BE)(0?\d{9})$/
},
bulgaria: {
multipliers: {
physical: [2, 4, 8, 5, 10, 9, 7, 3, 6],
foreigner: [21, 19, 17, 13, 11, 9, 7, 3, 1],
miscellaneous: [4, 3, 2, 7, 6, 5, 4, 3, 2]
},
regex: /^(BG)(\d{9,10})$/
},
switzerland: {
multipliers: [5, 4, 3, 2, 7, 6, 5, 4],
regex: /^(CHE)(\d{9})(MWST)?$/
},
cyprus: {
regex: /^(CY)([0-59]\d{7}[A-Z])$/
},
czech_republic: {
multipliers: [8, 7, 6, 5, 4, 3, 2],
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10],
regex: /^(CZ)(\d{8,10})(\d{3})?$/,
additional: [
/^\d{8}$/,
/^[0-5][0-9][0|1|5|6]\d[0-3]\d\d{3}$/,
/^6\d{8}$/,
/^\d{2}[0-3|5-8]\d[0-3]\d\d{4}$/
]
},
germany: {
regex: /^(DE)([1-9]\d{8})$/
},
denmark: {
multipliers: [2, 7, 6, 5, 4, 3, 2, 1],
regex: /^(DK)(\d{8})$/
},
estonia: {
multipliers: [3, 7, 1, 3, 7, 1, 3, 7],
regex: /^(EE)(10\d{7})$/
},
greece: {
multipliers: [256, 128, 64, 32, 16, 8, 4, 2],
regex: /^(EL)(\d{9})$/
},
spain: {
multipliers: [2, 1, 2, 1, 2, 1, 2],
regex: [
/^(ES)([A-Z]\d{8})$/,
/^(ES)([A-HN-SW]\d{7}[A-J])$/,
/^(ES)([0-9YZ]\d{7}[A-Z])$/,
/^(ES)([KLMX]\d{7}[A-Z])$/
],
additional: [
/^[A-H|J|U|V]\d{8}$/,
/^[A-H|N-S|W]\d{7}[A-J]$/,
/^[0-9|Y|Z]\d{7}[A-Z]$/,
/^[K|L|M|X]\d{7}[A-Z]$/
]
},
europe: {
regex: /^(EU)(\d{9})$/
},
finland: {
multipliers: [7, 9, 10, 5, 8, 4, 2],
regex: /^(FI)(\d{8})$/
},
france: {
regex: [
/^(FR)(\d{11})$/,
/^(FR)([A-HJ-NP-Z]\d{10})$/,
/^(FR)(\d[A-HJ-NP-Z]\d{9})$/,
/^(FR)([A-HJ-NP-Z]{2}\d{9})$/
]
},
united_kingdom: {
multipliers: [8, 7, 6, 5, 4, 3, 2],
regex: [
/^(GB)?(\d{9})$/,
/^(GB)?(\d{12})$/,
/^(GB)?(GD\d{3})$/,
/^(GB)?(HA\d{3})$/
]
},
croatia: {
regex: /^(HR)(\d{11})$/
},
hungary: {
multipliers: [9, 7, 3, 1, 9, 7, 3],
regex: /^(HU)(\d{8})$/
},
ireland: {
multipliers: [8, 7, 6, 5, 4, 3, 2],
regex: [
/^(IE)(\d{7}[A-W])$/,
/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/,
/^(IE)(\d{7}[A-W][AH])$/
]
},
italy: {
multipliers: [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],
regex: /^(IT)(\d{11})$/
},
latvia: {
multipliers: [9, 1, 4, 8, 3, 10, 2, 5, 7, 6],
regex: /^(LV)(\d{11})$/
},
lithunia: {
multipliers: {
short: [3, 4, 5, 6, 7, 8, 9, 1],
med: [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2],
alt: [3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4]
},
regex: /^(LT)(\d{9}|\d{12})$/
},
luxembourg: {
regex: /^(LU)(\d{8})$/
},
malta: {
multipliers: [3, 4, 6, 7, 8, 9],
regex: /^(MT)([1-9]\d{7})$/
},
netherlands: {
multipliers: [9, 8, 7, 6, 5, 4, 3, 2],
regex: /^(NL)(\d{9})B\d{2}$/
},
norway: {
multipliers: [3, 2, 7, 6, 5, 4, 3, 2],
regex: /^(NO)(\d{9})$/
},
poland: {
multipliers: [6, 5, 7, 2, 3, 4, 5, 6, 7],
regex: /^(PL)(\d{10})$/
},
portugal: {
multipliers: [9, 8, 7, 6, 5, 4, 3, 2],
regex: /^(PT)(\d{9})$/
},
romania: {
multipliers: [7, 5, 3, 2, 1, 7, 5, 3, 2],
regex: /^(RO)([1-9]\d{1,9})$/
},
russia: {
multipliers: {
m_1: [2, 4, 10, 3, 5, 9, 4, 6, 8, 0],
m_2: [7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0],
m_3: [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0]
},
regex: /^(RU)(\d{10}|\d{12})$/
},
serbia: {
regex: /^(RS)(\d{9})$/
},
slovenia: {
multipliers: [8, 7, 6, 5, 4, 3, 2],
regex: /^(SI)([1-9]\d{7})$/
},
slovakia_republic: {
regex: /^(SK)([1-9]\d[2346-9]\d{7})$/
},
sweden: {
regex: /^(SE)(\d{10}01)$/
}
};
function _validateRegexp(vat, regexp) {
return regexp.test(vat);
function _validateRegex(vat, regex) {
return regex.test(vat);
}
function _validateRules(vat, regexp, countryName) {
var parsedNum = regexp.exec(vat);
function _validateRules(vat, regex, countryName) {
var parsedNum = regex.exec(vat);

@@ -73,9 +190,9 @@ //var code = parsedNum[1];

return _checks[countryName](number);
return _checks[countryName](number, countryName);
}
function _validate(vat, regexp, countryName) {
function _validate(vat, regex, countryName) {
var result = false;
if (_validateRegexp(vat, regexp)) {
result = _validateRules(vat, regexp, countryName);
if (_validateRegex(vat, regex)) {
result = _validateRules(vat, regex, countryName);
}

@@ -90,13 +207,13 @@ return result;

for (var countryName in _REGEXP_LIST) {
if (_REGEXP_LIST.hasOwnProperty(countryName)) {
var regexp = _REGEXP_LIST[countryName];
for (var countryName in CONDITIONS) {
if (CONDITIONS.hasOwnProperty(countryName)) {
var regex = CONDITIONS[countryName].regex;
//TODO (S.Panfilov) this is not cross-browser check
if (Array.isArray(regexp)) {
for (var i = 0; i < regexp.length; i++) {
if (_validate(vat, regexp[i], countryName)) return true;
if (Array.isArray(regex)) {
for (var i = 0; i < regex.length; i++) {
if (_validate(vat, regex[i], countryName)) return true;
}
} else {
if (_validate(vat, regexp, countryName)) return true;
if (_validate(vat, regex, countryName)) return true;
}

@@ -110,11 +227,10 @@ }

var expect;
var temp;
var _checks = {
austria: function (vat) {
austria: function (vat, countryName) {
var total = 0;
var multipliers = [1, 2, 1, 2, 1, 2, 1];
var temp;
var expect;
for (var i = 0; i < 7; i++) {
temp = vat.charAt(i) * multipliers[i];
temp = vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
if (temp > 9)

@@ -134,19 +250,15 @@ total += Math.floor(temp / 10) + temp % 10;

belgium: function (vat) {
var expect;
var check;
if (vat.length === 9) vat = "0" + vat;
if (vat.length === 9) {
vat = '0' + vat;
}
if (+vat.slice(1, 2) === 0) return false;
check = (97 - +vat.slice(0, 8) % 97);
var check = (97 - +vat.slice(0, 8) % 97);
expect = +vat.slice(8, 10);
return check === expect;
},
bulgaria: function (vat) {
var expect;
var multipliers;
var temp;
var total;
bulgaria: function (vat, countryName) {
var checkNineLengthVat = function () {
var total =0;
temp = 0;

@@ -176,2 +288,3 @@ for (var i = 0; i < 8; i++) {

var isPhysicalPerson = function () {
var total = 0;
// 10 digit VAT code - see if it relates to a standard physical person

@@ -183,7 +296,5 @@ if ((/^\d\d[0-5]\d[0-3]\d\d{4}$/).test(vat)) {

// Extract the next digit and multiply by the counter.
multipliers = [2, 4, 8, 5, 10, 9, 7, 3, 6];
total = 0;
for (var k = 0; k < 9; k++) {
total += +vat.charAt(k) * multipliers[k];
total += +vat.charAt(k) * CONDITIONS[countryName].multipliers.physical[k];
}

@@ -205,7 +316,6 @@ // Establish check digit.

var isForeigner = function () {
var total = 0;
// Extract the next digit and multiply by the counter.
multipliers = [21, 19, 17, 13, 11, 9, 7, 3, 1];
total = 0;
for (var l = 0; l < 9; l++) {
total += +vat.charAt(l) * multipliers[l];
total += +vat.charAt(l) * CONDITIONS[countryName].multipliers.foreigner[l];
}

@@ -220,9 +330,7 @@

var miscellaneousVAT = function () {
var total = 0;
// Finally, if not yet identified, see if it conforms to a miscellaneous VAT number
// Extract the next digit and multiply by the counter.
multipliers = [4, 3, 2, 7, 6, 5, 4, 3, 2];
total = 0;
for (var m = 0; m < 9; m++) {
total += +vat.charAt(m) * multipliers[m];
total += +vat.charAt(m) * CONDITIONS[countryName].multipliers.miscellaneous[m];
}

@@ -247,11 +355,7 @@

},
switzerland: function (vat) {
var expect;
// Checks the check digits of a Swiss VAT number.
// Extract the next digit and multiply by the counter.
var multipliers = [5, 4, 3, 2, 7, 6, 5, 4];
switzerland: function (vat, countryName) {
var total = 0;
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -268,6 +372,3 @@ // Establish check digit.

cyprus: function (vat) {
var expect;
// Checks the check digits of a Cypriot VAT number.
var total = 0;
// Not allowed to start with '12'

@@ -277,3 +378,3 @@ if (+vat.slice(0, 2) === 12) return false;

// Extract the next digit and multiply by the counter.
var total = 0;
for (var i = 0; i < 8; i++) {

@@ -313,22 +414,11 @@ var temp = +vat.charAt(i);

},
czech_republic: function (vat) {
var expect;
// Checks the check digits of a Czech Republic VAT number.
czech_republic: function (vat, countryName) {
var total = 0;
var multipliers = [8, 7, 6, 5, 4, 3, 2];
var czExp = [];
czExp[0] = (/^\d{8}$/);
czExp[1] = (/^[0-5][0-9][0|1|5|6]\d[0-3]\d\d{3}$/);
czExp[2] = (/^6\d{8}$/);
czExp[3] = (/^\d{2}[0-3|5-8]\d[0-3]\d\d{4}$/);
// Legal entities
if (czExp[0].test(vat)) {
if (CONDITIONS[countryName].additional[0].test(vat)) {
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 7; i++) {
total += +vat.charAt(i) * multipliers[i];
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -346,15 +436,8 @@

// Individuals type 1
//else if (czExp[1].test(vat)) {
//TODO (S.Panfilov) It's seems to be an error
// return !(temp = +vat.slice(0, 2) > 53);
//
//}
// Individuals type 2
else if (czExp[2].test(vat)) {
else if (CONDITIONS[countryName].additional[2].test(vat)) {
// Extract the next digit and multiply by the counter.
for (var j = 0; j < 7; j++) {
total += +vat.charAt(j + 1) * multipliers[j];
total += +vat.charAt(j + 1) * CONDITIONS[countryName].multipliers[j];
}

@@ -368,9 +451,8 @@

// Convert calculated check digit according to a lookup table;
var lookup = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10];
expect = +vat.slice(8, 9);
return lookup[total - 1] === expect;
return CONDITIONS[countryName].lookup[total - 1] === expect;
}
// Individuals type 3
else if (czExp[3].test(vat)) {
else if (CONDITIONS[countryName].additional[3].test(vat)) {
var temp = +vat.slice(0, 2) + vat.slice(2, 4) + vat.slice(4, 6) + vat.slice(6, 8) + vat.slice(8);

@@ -385,4 +467,4 @@ expect = +vat % 11 === 0;

germany: function (vat) {
var expect;
// Checks the check digits of a German VAT number.

@@ -415,20 +497,16 @@

},
denmark: function (vat) {
denmark: function (vat, countryName) {
var total = 0;
var multipliers = [2, 7, 6, 5, 4, 3, 2, 1];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
return total % 11 === 0;
},
estonia: function (vat) {
var expect;
// Checks the check digits of an Estonian VAT number.
estonia: function (vat, countryName) {
var total = 0;
var multipliers = [3, 7, 1, 3, 7, 1, 3, 7];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -443,17 +521,13 @@ // Establish check digits using modulus 10.

},
greece: function (vat) {
var expect;
// Checks the check digits of a Greek VAT number.
greece: function (vat, countryName) {
var total = 0;
var multipliers = [256, 128, 64, 32, 16, 8, 4, 2];
//eight character numbers should be prefixed with an 0.
if (vat.length === 8) {
vat = "0" + vat;
vat = '0' + vat;
}
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -470,23 +544,12 @@ // Establish check digit.

},
spain: function (vat) {
var expect;
// Checks the check digits of a Spanish VAT number.
spain: function (vat, countryName) {
var i = 0;
var total = 0;
var temp = 0;
var multipliers = [2, 1, 2, 1, 2, 1, 2];
var esExp = [];
esExp[0] = (/^[A-H|J|U|V]\d{8}$/);
esExp[1] = (/^[A-H|N-S|W]\d{7}[A-J]$/);
esExp[2] = (/^[0-9|Y|Z]\d{7}[A-Z]$/);
esExp[3] = (/^[K|L|M|X]\d{7}[A-Z]$/);
var i = 0;
// National juridical entities
if (esExp[0].test(vat)) {
if (CONDITIONS[countryName].additional[0].test(vat)) {
// Extract the next digit and multiply by the counter.
for (i = 0; i < 7; i++) {
temp = vat.charAt(i + 1) * multipliers[i];
temp = vat.charAt(i + 1) * CONDITIONS[countryName].multipliers[i];
if (temp > 9)

@@ -509,7 +572,7 @@ total += Math.floor(temp / 10) + temp % 10;

// Juridical entities other than national ones
else if (esExp[1].test(vat)) {
else if (CONDITIONS[countryName].additional[1].test(vat)) {
// Extract the next digit and multiply by the counter.
for (i = 0; i < 7; i++) {
temp = vat.charAt(i + 1) * multipliers[i];
temp = vat.charAt(i + 1) * CONDITIONS[countryName].multipliers[i];
if (temp > 9)

@@ -531,6 +594,6 @@ total += Math.floor(temp / 10) + temp % 10;

// Personal number (NIF) (starting with numeric of Y or Z)
else if (esExp[2].test(vat)) {
else if (CONDITIONS[countryName].additional[2].test(vat)) {
var tempnumber = vat;
if (tempnumber.substring(0, 1) === 'Y') tempnumber = tempnumber.replace(/Y/, "1");
if (tempnumber.substring(0, 1) === 'Z') tempnumber = tempnumber.replace(/Z/, "2");
if (tempnumber.substring(0, 1) === 'Y') tempnumber = tempnumber.replace(/Y/, '1');
if (tempnumber.substring(0, 1) === 'Z') tempnumber = tempnumber.replace(/Z/, '2');
expect = 'TRWAGMYFPDXBNJZSQVHLCKE'.charAt(+tempnumber.substring(0, 8) % 23);

@@ -541,3 +604,3 @@ return tempnumber.charAt(8) === expect;

// Personal number (NIF) (starting with K, L, M, or X)
else if (esExp[3].test(vat)) {
else if (CONDITIONS[countryName].additional[3].test(vat)) {
expect = 'TRWAGMYFPDXBNJZSQVHLCKE'.charAt(+vat.substring(1, 8) % 23);

@@ -550,3 +613,3 @@ return vat.charAt(8) === expect;

europe: function () {
//TODO (S.Panfilov) wtf?
// We know little about EU numbers apart from the fact that the first 3 digits represent the

@@ -556,12 +619,6 @@ // country, and that there are nine digits in total.

},
finland: function (vat) {
var expect;
// Checks the check digits of a Finnish VAT number.
finland: function (vat, countryName) {
var total = 0;
var multipliers = [7, 9, 10, 5, 8, 4, 2];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 7; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 7; i++) total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];

@@ -579,6 +636,4 @@ // Establish check digit.

france: function (vat) {
var expect;
var total;
// Checks the check digits of a French VAT number.
if (!(/^\d{11}$/).test(vat)) {

@@ -589,3 +644,3 @@ return true;

// Extract the last nine digits as an integer.
var total = +vat.substring(2);
total = +vat.substring(2);

@@ -599,9 +654,4 @@ // Establish check digit.

},
united_kingdom: function (vat) {
var expect;
// Checks the check digits of a UK VAT number.
var multipliers = [8, 7, 6, 5, 4, 3, 2];
united_kingdom: function (vat, countryName) {
var total = 0;
// Government departments

@@ -620,4 +670,4 @@ if (vat.substr(0, 2) === 'GD') {

// Standard and commercial numbers
var total = 0;
// 0 VAT numbers disallowed!

@@ -630,3 +680,5 @@ if (+vat.slice(0) === 0) return false;

// Extract the next digit and multiply by the counter.
for (var i = 0; i < 7; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 7; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -657,4 +709,4 @@ // Old numbers use a simple 97 modulus, but new numbers use an adaptation of that (less 55). Our

croatia: function (vat) {
var expect;
// Checks the check digits of a Croatian VAT number using ISO 7064, MOD 11-10 for check digit.

@@ -680,12 +732,8 @@

},
hungary: function (vat) {
var expect;
// Checks the check digits of a Hungarian VAT number.
hungary: function (vat, countryName) {
var total = 0;
var multipliers = [9, 7, 3, 1, 9, 7, 3];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 7; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 7; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -700,13 +748,7 @@ // Establish check digit.

},
ireland: function (vat) {
var expect;
// Checks the check digits of an Irish VAT number.
ireland: function (vat, countryName) {
var total = 0;
var multipliers = [8, 7, 6, 5, 4, 3, 2];
// If the code is type 1 format, we need to convert it to the new before performing the validation.
if (/^\d[A-Z\*\+]/.test(vat)) {
vat = "0" + vat.substring(2, 7) + vat.substring(0, 1) + vat.substring(7, 8);
vat = '0' + vat.substring(2, 7) + vat.substring(0, 1) + vat.substring(7, 8);
}

@@ -716,3 +758,3 @@

for (var i = 0; i < 7; i++) {
total += +vat.charAt(i) * multipliers[i];
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -733,3 +775,3 @@

if (total === 0) {
total = "W";
total = 'W';
} else {

@@ -743,11 +785,4 @@ total = String.fromCharCode(total + 64);

},
italy: function (vat) {
var expect;
// Checks the check digits of an Italian VAT number.
italy: function (vat, countryName) {
var total = 0;
var multipliers = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2];
var temp;
// The last three digits are the issuing office, and cannot exceed more 201, unless 999 or 888

@@ -765,3 +800,3 @@ if (+vat.slice(0, 7) === 0) {

for (var i = 0; i < 10; i++) {
temp = +vat.charAt(i) * multipliers[i];
temp = +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
if (temp > 9)

@@ -783,9 +818,4 @@ total += Math.floor(temp / 10) + temp % 10;

},
lithunia: function (vat) {
var total;
var multipliers;
var expect;
// Checks the check digits of a Lithuanian VAT number.
lithunia: function (vat, countryName) {
var total = 0;
// 9 character VAT numbers are for legal persons

@@ -805,6 +835,5 @@ if (vat.length === 9) {

if (total % 11 === 10) {
multipliers = [3, 4, 5, 6, 7, 8, 9, 1];
total = 0;
for (var j = 0; j < 8; j++) {
total += +vat.charAt(j) * multipliers[j];
total += +vat.charAt(j) * CONDITIONS[countryName].multipliers.short[j];
}

@@ -832,5 +861,4 @@ }

total = 0;
multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2];
for (var k = 0; k < 11; k++) {
total += +vat.charAt(k) * multipliers[k];
total += +vat.charAt(k) * CONDITIONS[countryName].multipliers.med[k];
}

@@ -840,6 +868,5 @@

if (total % 11 === 10) {
multipliers = [3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4];
total = 0;
for (var l = 0; l < 11; l++) {
total += +vat.charAt(l) * multipliers[l];
total += +vat.charAt(l) * CONDITIONS[countryName].multipliers.alt[l];
}

@@ -866,7 +893,5 @@ }

},
latvia: function (vat) {
var expect;
latvia: function (vat, countryName) {
var total = 0;
// Checks the check digits of a Latvian VAT number.
// Differentiate between legal entities and natural bodies. For the latter we simply check that

@@ -878,7 +903,6 @@ // the first six digits correspond to valid DDMMYY dates.

var total = 0;
var multipliers = [9, 1, 4, 8, 3, 10, 2, 5, 7, 6];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 10; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 10; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -899,12 +923,8 @@ // Establish check digits by getting modulus 11.

},
malta: function (vat) {
var expect;
// Checks the check digits of a Maltese VAT number.
malta: function (vat, countryName) {
var total = 0;
var multipliers = [3, 4, 6, 7, 8, 9];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 6; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 6; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -918,12 +938,8 @@ // Establish check digits by getting modulus 37.

},
netherlands: function (vat) {
var expect;
// Checks the check digits of a Dutch VAT number.
netherlands: function (vat, countryName) {
var total = 0;
var multipliers = [9, 8, 7, 6, 5, 4, 3, 2];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -940,13 +956,10 @@ // Establish check digits by getting modulus 11.

},
norway: function (vat) {
var expect;
// Checks the check digits of a Norwegian VAT number.
norway: function (vat, countryName) {
var total = 0;
// See http://www.brreg.no/english/coordination/number.html
var total = 0;
var multipliers = [3, 2, 7, 6, 5, 4, 3, 2];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -965,12 +978,8 @@ // Establish check digits by getting modulus 11. Check digits > 9 are invalid

},
poland: function (vat) {
var expect;
// Checks the check digits of a Polish VAT number.
poland: function (vat, countryName) {
var total = 0;
var multipliers = [6, 5, 7, 2, 3, 4, 5, 6, 7];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 9; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 9; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -987,12 +996,8 @@ // Establish check digits subtracting modulus 11 from 11.

},
portugal: function (vat) {
var expect;
// Checks the check digits of a Portugese VAT number.
portugal: function (vat, countryName) {
var total = 0;
var multipliers = [9, 8, 7, 6, 5, 4, 3, 2];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -1009,13 +1014,8 @@ // Establish check digits subtracting modulus 11 from 11.

},
romania: function (vat) {
var expect;
// Checks the check digits of a Romanian VAT number.
var multipliers = [7, 5, 3, 2, 1, 7, 5, 3, 2];
romania: function (vat, countryName) {
var total = 0;
// Extract the next digit and multiply by the counter.
var vatLength = vat.length;
multipliers = multipliers.slice(10 - vatLength);
var total = 0;
var multipliers = CONDITIONS[countryName].multipliers.slice(10 - vatLength);
for (var i = 0; i < vat.length - 1; i++) {

@@ -1034,4 +1034,2 @@ total += +vat.charAt(i) * multipliers[i];

serbia: function (vat) {
var expect;
// Checks the check digits of a Serbian VAT number using ISO 7064, MOD 11-10 for check digit.

@@ -1058,4 +1056,4 @@

},
russia: function (vat) {
var expect;
russia: function (vat, countryName) {
var total = 0;
var expect2;

@@ -1068,6 +1066,5 @@

if (vat.length === 10) {
var total = 0;
var multipliers = [2, 4, 10, 3, 5, 9, 4, 6, 8, 0];
for (var i = 0; i < 10; i++) {
total += +vat.charAt(i) * multipliers[i];
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers.m_1[i];
}

@@ -1087,8 +1084,6 @@

var total1 = 0;
var multipliers1 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0];
var total2 = 0;
var multipliers2 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0];
for (var j = 0; j < 11; j++) {
total1 += +vat.charAt(j) * multipliers1[j];
total1 += +vat.charAt(j) * CONDITIONS[countryName].multipliers.m_2[j];
}

@@ -1102,3 +1097,3 @@

for (var k = 0; k < 11; k++) {
total2 += +vat.charAt(k) * multipliers2[k];
total2 += +vat.charAt(k) * CONDITIONS[countryName].multipliers.m_3[k];
}

@@ -1113,4 +1108,6 @@

// character of the VAT number. If they're both the same, then it's valid
expect = +vat.slice(10, 11);
expect2 = +vat.slice(11, 12);
//expect = +vat.slice(10, 11);
expect = (total1 === +vat.slice(10, 11));
//expect2 = +vat.slice(11, 12);
expect2 = (total2 === +vat.slice(11, 12));
return (expect) && (expect2);

@@ -1120,4 +1117,2 @@ }

sweden: function (vat) {
var expect;
// Calculate R where R = R1 + R3 + R5 + R7 + R9, and Ri = INT(Ci/5) + (Ci*2) modulo 10

@@ -1144,12 +1139,8 @@ var R = 0;

},
slovenia: function (vat) {
var expect;
// Checks the check digits of a Slovenian VAT number.
slovenia: function (vat, countryName) {
var total = 0;
var multipliers = [8, 7, 6, 5, 4, 3, 2];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 7; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 7; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -1156,0 +1147,0 @@ // Establish check digits using modulus 11

@@ -1,2 +0,2 @@

angular.module("jsvat",[]).factory("JsVatFactory",function(){var r=function(){"use strict";function r(r,t){return t.test(r)}function t(r,t,e){var n=t.exec(r),a=n[2];return i[e](a)}function e(e,n,a){var i=!1;return r(e,n)&&(i=t(e,n,a)),i}var n={austria:/^(AT)U(\d{8})$/,belgium:/^(BE)(0?\d{9})$/,bulgaria:/^(BG)(\d{9,10})$/,switzerland:/^(CHE)(\d{9})(MWST)?$/,cyprus:/^(CY)([0-59]\d{7}[A-Z])$/,czech_republic:/^(CZ)(\d{8,10})(\d{3})?$/,germany:/^(DE)([1-9]\d{8})$/,denmark:/^(DK)(\d{8})$/,estonia:/^(EE)(10\d{7})$/,greece:/^(EL)(\d{9})$/,spain:[/^(ES)([A-Z]\d{8})$/,/^(ES)([A-HN-SW]\d{7}[A-J])$/,/^(ES)([0-9YZ]\d{7}[A-Z])$/,/^(ES)([KLMX]\d{7}[A-Z])$/],europe:/^(EU)(\d{9})$/,finland:/^(FI)(\d{8})$/,france:[/^(FR)(\d{11})$/,/^(FR)([A-HJ-NP-Z]\d{10})$/,/^(FR)(\d[A-HJ-NP-Z]\d{9})$/,/^(FR)([A-HJ-NP-Z]{2}\d{9})$/],united_kingdom:[/^(GB)?(\d{9})$/,/^(GB)?(\d{12})$/,/^(GB)?(GD\d{3})$/,/^(GB)?(HA\d{3})$/],croatia:/^(HR)(\d{11})$/,hungary:/^(HU)(\d{8})$/,ireland:[/^(IE)(\d{7}[A-W])$/,/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/,/^(IE)(\d{7}[A-W][AH])$/],italy:/^(IT)(\d{11})$/,latvia:/^(LV)(\d{11})$/,lithunia:/^(LT)(\d{9}|\d{12})$/,luxembourg:/^(LU)(\d{8})$/,malta:/^(MT)([1-9]\d{7})$/,netherlands:/^(NL)(\d{9})B\d{2}$/,norway:/^(NO)(\d{9})$/,poland:/^(PL)(\d{10})$/,portugal:/^(PT)(\d{9})$/,romania:/^(RO)([1-9]\d{1,9})$/,russia:/^(RU)(\d{10}|\d{12})$/,serbia:/^(RS)(\d{9})$/,slovenia:/^(SI)([1-9]\d{7})$/,slovakia_republic:/^(SK)([1-9]\d[2346-9]\d{7})$/,sweden:/^(SE)(\d{10}01)$/},a={checkVAT:function(r){if(!r)return!1;r=r.toString().toUpperCase().replace(/(\s|-|\.)+/g,"");for(var t in n)if(n.hasOwnProperty(t)){var a=n[t];if(Array.isArray(a)){for(var i=0;i<a.length;i++)if(e(r,a[i],t))return!0}else if(e(r,a,t))return!0}return!1}},i={austria:function(r){for(var t,e,n=0,a=[1,2,1,2,1,2,1],i=0;7>i;i++)t=r.charAt(i)*a[i],n+=t>9?Math.floor(t/10)+t%10:t;return n=10-(n+4)%10,10===n&&(n=0),e=+r.slice(7,8),n===e},belgium:function(r){var t,e;return 9===r.length&&(r="0"+r),0===+r.slice(1,2)?!1:(e=97-+r.slice(0,8)%97,t=+r.slice(8,10),e===t)},bulgaria:function(r){var t,e,n,a,i=function(){n=0;for(var e=0;8>e;e++)n+=+r.charAt(e)*(e+1);if(a=n%11,10!==a)return t=+r.slice(8),a===t;n=0;for(var i=0;8>i;i++)n+=+r.charAt(i)*(i+3);return a=n%11,10===a&&(a=0),t=+r.slice(8),a===t},c=function(){if(/^\d\d[0-5]\d[0-3]\d\d{4}$/.test(r)){var t=+r.slice(2,4);if(t>0&&13>t||t>20&&33>t||t>40&&53>t){e=[2,4,8,5,10,9,7,3,6],a=0;for(var n=0;9>n;n++)a+=+r.charAt(n)*e[n];if(a%=11,10===a&&(a=0),a===+r.substr(9,1))return!0}}return!1},u=function(){e=[21,19,17,13,11,9,7,3,1],a=0;for(var t=0;9>t;t++)a+=+r.charAt(t)*e[t];return a%10===+r.substr(9,1)?!0:void 0},s=function(){e=[4,3,2,7,6,5,4,3,2],a=0;for(var n=0;9>n;n++)a+=+r.charAt(n)*e[n];return a=11-a%11,10===a?!1:(11===a&&(a=0),t=+r.substr(9,1),a===t)};return 9===r.length?i():c()||u()||s()},switzerland:function(r){for(var t,e=[5,4,3,2,7,6,5,4],n=0,a=0;8>a;a++)n+=+r.charAt(a)*e[a];return n=11-n%11,10===n?!1:(11===n&&(n=0),t=+r.substr(8,1),n===t)},cyprus:function(r){var t;if(12===+r.slice(0,2))return!1;for(var e=0,n=0;8>n;n++){var a=+r.charAt(n);if(n%2===0)switch(a){case 0:a=1;break;case 1:a=0;break;case 2:a=5;break;case 3:a=7;break;case 4:a=9;break;default:a=2*a+3}e+=a}return e%=26,e=String.fromCharCode(e+65),t=r.substr(8,1),e===t},czech_republic:function(r){var t,e=0,n=[8,7,6,5,4,3,2],a=[];if(a[0]=/^\d{8}$/,a[1]=/^[0-5][0-9][0|1|5|6]\d[0-3]\d\d{3}$/,a[2]=/^6\d{8}$/,a[3]=/^\d{2}[0-3|5-8]\d[0-3]\d\d{4}$/,a[0].test(r)){for(var i=0;7>i;i++)e+=+r.charAt(i)*n[i];return e=11-e%11,10===e&&(e=0),11===e&&(e=1),t=+r.slice(7,8),e===t}if(a[2].test(r)){for(var c=0;7>c;c++)e+=+r.charAt(c+1)*n[c];e=11-e%11,10===e&&(e=0),11===e&&(e=1);var u=[8,7,6,5,4,3,2,1,0,9,10];return t=+r.slice(8,9),u[e-1]===t}if(a[3].test(r)){var s=+r.slice(0,2)+r.slice(2,4)+r.slice(4,6)+r.slice(6,8)+r.slice(8);return t=+r%11===0,!(s%11!==0||!t)}return!1},germany:function(r){for(var t,e=10,n=0,a=0,i=0;8>i;i++)n=(+r.charAt(i)+e)%10,0===n&&(n=10),e=2*n%11;return a=11-e===10?0:11-e,t=+r.slice(8,9),a===t},denmark:function(r){for(var t=0,e=[2,7,6,5,4,3,2,1],n=0;8>n;n++)t+=+r.charAt(n)*e[n];return t%11===0},estonia:function(r){for(var t,e=0,n=[3,7,1,3,7,1,3,7],a=0;8>a;a++)e+=+r.charAt(a)*n[a];return e=10-e%10,10===e&&(e=0),t=+r.slice(8,9),e===t},greece:function(r){var t,e=0,n=[256,128,64,32,16,8,4,2];8===r.length&&(r="0"+r);for(var a=0;8>a;a++)e+=+r.charAt(a)*n[a];return e%=11,e>9&&(e=0),t=+r.slice(8,9),e===t},spain:function(r){var t,e=0,n=0,a=[2,1,2,1,2,1,2],i=[];i[0]=/^[A-H|J|U|V]\d{8}$/,i[1]=/^[A-H|N-S|W]\d{7}[A-J]$/,i[2]=/^[0-9|Y|Z]\d{7}[A-Z]$/,i[3]=/^[K|L|M|X]\d{7}[A-Z]$/;var c=0;if(i[0].test(r)){for(c=0;7>c;c++)n=r.charAt(c+1)*a[c],e+=n>9?Math.floor(n/10)+n%10:n;return e=10-e%10,10===e&&(e=0),t=+r.slice(8,9),e===t}if(i[1].test(r)){for(c=0;7>c;c++)n=r.charAt(c+1)*a[c],e+=n>9?Math.floor(n/10)+n%10:n;return e=10-e%10,e=String.fromCharCode(e+64),t=r.slice(8,9),e===t}if(i[2].test(r)){var u=r;return"Y"===u.substring(0,1)&&(u=u.replace(/Y/,"1")),"Z"===u.substring(0,1)&&(u=u.replace(/Z/,"2")),t="TRWAGMYFPDXBNJZSQVHLCKE".charAt(+u.substring(0,8)%23),u.charAt(8)===t}return i[3].test(r)?(t="TRWAGMYFPDXBNJZSQVHLCKE".charAt(+r.substring(1,8)%23),r.charAt(8)===t):!1},europe:function(){return!0},finland:function(r){for(var t,e=0,n=[7,9,10,5,8,4,2],a=0;7>a;a++)e+=+r.charAt(a)*n[a];return e=11-e%11,e>9&&(e=0),t=+r.slice(7,8),e===t},france:function(r){var t;if(!/^\d{11}$/.test(r))return!0;var e=+r.substring(2);return e=(100*e+12)%97,t=+r.slice(0,2),e===t},united_kingdom:function(r){var t,e=[8,7,6,5,4,3,2];if("GD"===r.substr(0,2))return t=500,r.substr(2,3)<t;if("HA"===r.substr(0,2))return t=499,r.substr(2,3)>t;var n=0;if(0===+r.slice(0))return!1;for(var a=+r.slice(0,7),i=0;7>i;i++)n+=+r.charAt(i)*e[i];for(var c=n;c>0;)c-=97;return c=Math.abs(c),c===+r.slice(7,9)&&9990001>a&&(1e5>a||a>999999)&&(9490001>a||a>97e5)?!0:(c>=55?c-=55:c+=42,t=+r.slice(7,9),!!(c===t&&a>1e6))},croatia:function(r){for(var t,e=10,n=0,a=0;10>a;a++)n=(+r.charAt(a)+e)%10,0===n&&(n=10),e=2*n%11;return t=+r.slice(10,11),(e+t)%10===1},hungary:function(r){for(var t,e=0,n=[9,7,3,1,9,7,3],a=0;7>a;a++)e+=+r.charAt(a)*n[a];return e=10-e%10,10===e&&(e=0),t=+r.slice(7,8),e===t},ireland:function(r){var t,e=0,n=[8,7,6,5,4,3,2];/^\d[A-Z\*\+]/.test(r)&&(r="0"+r.substring(2,7)+r.substring(0,1)+r.substring(7,8));for(var a=0;7>a;a++)e+=+r.charAt(a)*n[a];return/^\d{7}[A-Z][AH]$/.test(r)&&(e+="H"===r.charAt(8)?72:9),e%=23,e=0===e?"W":String.fromCharCode(e+64),t=r.slice(7,8),e===t},italy:function(r){var t,e,n=0,a=[1,2,1,2,1,2,1,2,1,2];if(0===+r.slice(0,7))return!1;if(e=+r.slice(7,10),1>e||e>201&&999!==e&&888!==e)return!1;for(var i=0;10>i;i++)e=+r.charAt(i)*a[i],n+=e>9?Math.floor(e/10)+e%10:e;return n=10-n%10,n>9&&(n=0),t=+r.slice(10,11),n===t},lithunia:function(r){var t,e,n;if(9===r.length){if(!/^\d{7}1/.test(r))return!1;t=0;for(var a=0;8>a;a++)t+=+r.charAt(a)*(a+1);if(t%11===10){e=[3,4,5,6,7,8,9,1],t=0;for(var i=0;8>i;i++)t+=+r.charAt(i)*e[i]}return t%=11,10===t&&(t=0),n=+r.slice(8,9),t===n}if(!/^\d{10}1/.test(r))return!1;t=0,e=[1,2,3,4,5,6,7,8,9,1,2];for(var c=0;11>c;c++)t+=+r.charAt(c)*e[c];if(t%11===10){e=[3,4,5,6,7,8,9,1,2,3,4],t=0;for(var u=0;11>u;u++)t+=+r.charAt(u)*e[u]}return t%=11,10===t&&(t=0),n=+r.slice(11,12),t===n},luxembourg:function(r){var t=+r.slice(6,8),e=+r.slice(0,6)%89;return e===t},latvia:function(r){var t;if(/^[0-3]/.test(r))return!!/^[0-3][0-9][0-1][0-9]/.test(r);for(var e=0,n=[9,1,4,8,3,10,2,5,7,6],a=0;10>a;a++)e+=+r.charAt(a)*n[a];return e%11===4&&9===r[0]&&(e-=45),e%11===4?e=4-e%11:e%11>4?e=14-e%11:4>e%11&&(e=3-e%11),t=+r.slice(10,11),e===t},malta:function(r){for(var t,e=0,n=[3,4,6,7,8,9],a=0;6>a;a++)e+=+r.charAt(a)*n[a];return e=37-e%37,t=+r.slice(6,8),e===t},netherlands:function(r){for(var t,e=0,n=[9,8,7,6,5,4,3,2],a=0;8>a;a++)e+=+r.charAt(a)*n[a];return e%=11,e>9&&(e=0),t=+r.slice(8,9),e===t},norway:function(r){for(var t,e=0,n=[3,2,7,6,5,4,3,2],a=0;8>a;a++)e+=+r.charAt(a)*n[a];return e=11-e%11,11===e&&(e=0),10>e?(t=+r.slice(8,9),e===t):void 0},poland:function(r){for(var t,e=0,n=[6,5,7,2,3,4,5,6,7],a=0;9>a;a++)e+=+r.charAt(a)*n[a];return e%=11,e>9&&(e=0),t=+r.slice(9,10),e===t},portugal:function(r){for(var t,e=0,n=[9,8,7,6,5,4,3,2],a=0;8>a;a++)e+=+r.charAt(a)*n[a];return e=11-e%11,e>9&&(e=0),t=+r.slice(8,9),e===t},romania:function(r){var t,e=[7,5,3,2,1,7,5,3,2],n=r.length;e=e.slice(10-n);for(var a=0,i=0;i<r.length-1;i++)a+=+r.charAt(i)*e[i];return a=10*a%11,10===a&&(a=0),t=+r.slice(r.length-1,r.length),a===t},serbia:function(r){for(var t,e,n=10,a=0,i=0;8>i;i++)a=(+r.charAt(i)+n)%10,0===a&&(a=10),n=2*a%11;return t=1,e=(n+ +r.slice(8,9))%10,e===t},russia:function(r){var t,e;if(10===r.length){for(var n=0,a=[2,4,10,3,5,9,4,6,8,0],i=0;10>i;i++)n+=+r.charAt(i)*a[i];return n%=11,n>9&&(n%=10),t=+r.slice(9,10),n===t}if(12===r.length){for(var c=0,u=[7,2,4,10,3,5,9,4,6,8,0],s=0,o=[3,7,2,4,10,3,5,9,4,6,8,0],f=0;11>f;f++)c+=+r.charAt(f)*u[f];c%=11,c>9&&(c%=10);for(var l=0;11>l;l++)s+=+r.charAt(l)*o[l];return s%=11,s>9&&(s%=10),t=+r.slice(10,11),e=+r.slice(11,12),t&&e}},sweden:function(r){for(var t,e,n=0,a=0;9>a;a+=2)e=+r.charAt(a),n+=Math.floor(e/5)+2*e%10;for(var i=0,c=1;9>c;c+=2)i+=+r.charAt(c);var u=(10-(n+i)%10)%10;return t=+r.slice(9,10),u===t},slovenia:function(r){for(var t,e=0,n=[8,7,6,5,4,3,2],a=0;7>a;a++)e+=+r.charAt(a)*n[a];return e=11-e%11,10===e&&(e=0),t=+r.slice(7,8),!(11===e||e!==t)},slovakia_republic:function(r){var t=0,e=r%11;return e===t}};return"object"==typeof module&&module.exports&&(module.exports=a),a}();return r});
angular.module("jsvat",[]).factory("JsVatFactory",function(){var r=function(){"use strict";function r(r,e){return e.test(r)}function e(r,e,t){var i=e.exec(r),l=i[2];return u[t](l,t)}function t(t,i,l){var a=!1;return r(t,i)&&(a=e(t,i,l)),a}var i,l,a={austria:{multipliers:[1,2,1,2,1,2,1],regex:/^(AT)U(\d{8})$/},belgium:{regex:/^(BE)(0?\d{9})$/},bulgaria:{multipliers:{physical:[2,4,8,5,10,9,7,3,6],foreigner:[21,19,17,13,11,9,7,3,1],miscellaneous:[4,3,2,7,6,5,4,3,2]},regex:/^(BG)(\d{9,10})$/},switzerland:{multipliers:[5,4,3,2,7,6,5,4],regex:/^(CHE)(\d{9})(MWST)?$/},cyprus:{regex:/^(CY)([0-59]\d{7}[A-Z])$/},czech_republic:{multipliers:[8,7,6,5,4,3,2],lookup:[8,7,6,5,4,3,2,1,0,9,10],regex:/^(CZ)(\d{8,10})(\d{3})?$/,additional:[/^\d{8}$/,/^[0-5][0-9][0|1|5|6]\d[0-3]\d\d{3}$/,/^6\d{8}$/,/^\d{2}[0-3|5-8]\d[0-3]\d\d{4}$/]},germany:{regex:/^(DE)([1-9]\d{8})$/},denmark:{multipliers:[2,7,6,5,4,3,2,1],regex:/^(DK)(\d{8})$/},estonia:{multipliers:[3,7,1,3,7,1,3,7],regex:/^(EE)(10\d{7})$/},greece:{multipliers:[256,128,64,32,16,8,4,2],regex:/^(EL)(\d{9})$/},spain:{multipliers:[2,1,2,1,2,1,2],regex:[/^(ES)([A-Z]\d{8})$/,/^(ES)([A-HN-SW]\d{7}[A-J])$/,/^(ES)([0-9YZ]\d{7}[A-Z])$/,/^(ES)([KLMX]\d{7}[A-Z])$/],additional:[/^[A-H|J|U|V]\d{8}$/,/^[A-H|N-S|W]\d{7}[A-J]$/,/^[0-9|Y|Z]\d{7}[A-Z]$/,/^[K|L|M|X]\d{7}[A-Z]$/]},europe:{regex:/^(EU)(\d{9})$/},finland:{multipliers:[7,9,10,5,8,4,2],regex:/^(FI)(\d{8})$/},france:{regex:[/^(FR)(\d{11})$/,/^(FR)([A-HJ-NP-Z]\d{10})$/,/^(FR)(\d[A-HJ-NP-Z]\d{9})$/,/^(FR)([A-HJ-NP-Z]{2}\d{9})$/]},united_kingdom:{multipliers:[8,7,6,5,4,3,2],regex:[/^(GB)?(\d{9})$/,/^(GB)?(\d{12})$/,/^(GB)?(GD\d{3})$/,/^(GB)?(HA\d{3})$/]},croatia:{regex:/^(HR)(\d{11})$/},hungary:{multipliers:[9,7,3,1,9,7,3],regex:/^(HU)(\d{8})$/},ireland:{multipliers:[8,7,6,5,4,3,2],regex:[/^(IE)(\d{7}[A-W])$/,/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/,/^(IE)(\d{7}[A-W][AH])$/]},italy:{multipliers:[1,2,1,2,1,2,1,2,1,2],regex:/^(IT)(\d{11})$/},latvia:{multipliers:[9,1,4,8,3,10,2,5,7,6],regex:/^(LV)(\d{11})$/},lithunia:{multipliers:{"short":[3,4,5,6,7,8,9,1],med:[1,2,3,4,5,6,7,8,9,1,2],alt:[3,4,5,6,7,8,9,1,2,3,4]},regex:/^(LT)(\d{9}|\d{12})$/},luxembourg:{regex:/^(LU)(\d{8})$/},malta:{multipliers:[3,4,6,7,8,9],regex:/^(MT)([1-9]\d{7})$/},netherlands:{multipliers:[9,8,7,6,5,4,3,2],regex:/^(NL)(\d{9})B\d{2}$/},norway:{multipliers:[3,2,7,6,5,4,3,2],regex:/^(NO)(\d{9})$/},poland:{multipliers:[6,5,7,2,3,4,5,6,7],regex:/^(PL)(\d{10})$/},portugal:{multipliers:[9,8,7,6,5,4,3,2],regex:/^(PT)(\d{9})$/},romania:{multipliers:[7,5,3,2,1,7,5,3,2],regex:/^(RO)([1-9]\d{1,9})$/},russia:{multipliers:{m_1:[2,4,10,3,5,9,4,6,8,0],m_2:[7,2,4,10,3,5,9,4,6,8,0],m_3:[3,7,2,4,10,3,5,9,4,6,8,0]},regex:/^(RU)(\d{10}|\d{12})$/},serbia:{regex:/^(RS)(\d{9})$/},slovenia:{multipliers:[8,7,6,5,4,3,2],regex:/^(SI)([1-9]\d{7})$/},slovakia_republic:{regex:/^(SK)([1-9]\d[2346-9]\d{7})$/},sweden:{regex:/^(SE)(\d{10}01)$/}},n={checkVAT:function(r){if(!r)return!1;r=r.toString().toUpperCase().replace(/(\s|-|\.)+/g,"");for(var e in a)if(a.hasOwnProperty(e)){var i=a[e].regex;if(Array.isArray(i)){for(var l=0;l<i.length;l++)if(t(r,i[l],e))return!0}else if(t(r,i,e))return!0}return!1}},u={austria:function(r,e){for(var t=0,n=0;7>n;n++)l=r.charAt(n)*a[e].multipliers[n],t+=l>9?Math.floor(l/10)+l%10:l;return t=10-(t+4)%10,10===t&&(t=0),i=+r.slice(7,8),t===i},belgium:function(r){if(9===r.length&&(r="0"+r),0===+r.slice(1,2))return!1;var e=97-+r.slice(0,8)%97;return i=+r.slice(8,10),e===i},bulgaria:function(r,e){var t=function(){var e=0;l=0;for(var t=0;8>t;t++)l+=+r.charAt(t)*(t+1);if(e=l%11,10!==e)return i=+r.slice(8),e===i;l=0;for(var a=0;8>a;a++)l+=+r.charAt(a)*(a+3);return e=l%11,10===e&&(e=0),i=+r.slice(8),e===i},n=function(){var t=0;if(/^\d\d[0-5]\d[0-3]\d\d{4}$/.test(r)){var i=+r.slice(2,4);if(i>0&&13>i||i>20&&33>i||i>40&&53>i){t=0;for(var l=0;9>l;l++)t+=+r.charAt(l)*a[e].multipliers.physical[l];if(t%=11,10===t&&(t=0),t===+r.substr(9,1))return!0}}return!1},u=function(){for(var t=0,i=0;9>i;i++)t+=+r.charAt(i)*a[e].multipliers.foreigner[i];return t%10===+r.substr(9,1)?!0:void 0},s=function(){for(var t=0,l=0;9>l;l++)t+=+r.charAt(l)*a[e].multipliers.miscellaneous[l];return t=11-t%11,10===t?!1:(11===t&&(t=0),i=+r.substr(9,1),t===i)};return 9===r.length?t():n()||u()||s()},switzerland:function(r,e){for(var t=0,l=0;8>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t=11-t%11,10===t?!1:(11===t&&(t=0),i=+r.substr(8,1),t===i)},cyprus:function(r){var e=0;if(12===+r.slice(0,2))return!1;for(var t=0;8>t;t++){var l=+r.charAt(t);if(t%2===0)switch(l){case 0:l=1;break;case 1:l=0;break;case 2:l=5;break;case 3:l=7;break;case 4:l=9;break;default:l=2*l+3}e+=l}return e%=26,e=String.fromCharCode(e+65),i=r.substr(8,1),e===i},czech_republic:function(r,e){var t=0;if(a[e].additional[0].test(r)){for(var l=0;7>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t=11-t%11,10===t&&(t=0),11===t&&(t=1),i=+r.slice(7,8),t===i}if(a[e].additional[2].test(r)){for(var n=0;7>n;n++)t+=+r.charAt(n+1)*a[e].multipliers[n];return t=11-t%11,10===t&&(t=0),11===t&&(t=1),i=+r.slice(8,9),a[e].lookup[t-1]===i}if(a[e].additional[3].test(r)){var u=+r.slice(0,2)+r.slice(2,4)+r.slice(4,6)+r.slice(6,8)+r.slice(8);return i=+r%11===0,!(u%11!==0||!i)}return!1},germany:function(r){for(var e=10,t=0,l=0,a=0;8>a;a++)t=(+r.charAt(a)+e)%10,0===t&&(t=10),e=2*t%11;return l=11-e===10?0:11-e,i=+r.slice(8,9),l===i},denmark:function(r,e){for(var t=0,i=0;8>i;i++)t+=+r.charAt(i)*a[e].multipliers[i];return t%11===0},estonia:function(r,e){for(var t=0,l=0;8>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t=10-t%10,10===t&&(t=0),i=+r.slice(8,9),t===i},greece:function(r,e){var t=0;8===r.length&&(r="0"+r);for(var l=0;8>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t%=11,t>9&&(t=0),i=+r.slice(8,9),t===i},spain:function(r,e){var t=0,n=0;if(a[e].additional[0].test(r)){for(t=0;7>t;t++)l=r.charAt(t+1)*a[e].multipliers[t],n+=l>9?Math.floor(l/10)+l%10:l;return n=10-n%10,10===n&&(n=0),i=+r.slice(8,9),n===i}if(a[e].additional[1].test(r)){for(t=0;7>t;t++)l=r.charAt(t+1)*a[e].multipliers[t],n+=l>9?Math.floor(l/10)+l%10:l;return n=10-n%10,n=String.fromCharCode(n+64),i=r.slice(8,9),n===i}if(a[e].additional[2].test(r)){var u=r;return"Y"===u.substring(0,1)&&(u=u.replace(/Y/,"1")),"Z"===u.substring(0,1)&&(u=u.replace(/Z/,"2")),i="TRWAGMYFPDXBNJZSQVHLCKE".charAt(+u.substring(0,8)%23),u.charAt(8)===i}return a[e].additional[3].test(r)?(i="TRWAGMYFPDXBNJZSQVHLCKE".charAt(+r.substring(1,8)%23),r.charAt(8)===i):!1},europe:function(){return!0},finland:function(r,e){for(var t=0,l=0;7>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t=11-t%11,t>9&&(t=0),i=+r.slice(7,8),t===i},france:function(r){var e;return/^\d{11}$/.test(r)?(e=+r.substring(2),e=(100*e+12)%97,i=+r.slice(0,2),e===i):!0},united_kingdom:function(r,e){var t=0;if("GD"===r.substr(0,2))return i=500,r.substr(2,3)<i;if("HA"===r.substr(0,2))return i=499,r.substr(2,3)>i;if(0===+r.slice(0))return!1;for(var l=+r.slice(0,7),n=0;7>n;n++)t+=+r.charAt(n)*a[e].multipliers[n];for(var u=t;u>0;)u-=97;return u=Math.abs(u),u===+r.slice(7,9)&&9990001>l&&(1e5>l||l>999999)&&(9490001>l||l>97e5)?!0:(u>=55?u-=55:u+=42,i=+r.slice(7,9),!!(u===i&&l>1e6))},croatia:function(r){for(var e=10,t=0,l=0;10>l;l++)t=(+r.charAt(l)+e)%10,0===t&&(t=10),e=2*t%11;return i=+r.slice(10,11),(e+i)%10===1},hungary:function(r,e){for(var t=0,l=0;7>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t=10-t%10,10===t&&(t=0),i=+r.slice(7,8),t===i},ireland:function(r,e){var t=0;/^\d[A-Z\*\+]/.test(r)&&(r="0"+r.substring(2,7)+r.substring(0,1)+r.substring(7,8));for(var l=0;7>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return/^\d{7}[A-Z][AH]$/.test(r)&&(t+="H"===r.charAt(8)?72:9),t%=23,t=0===t?"W":String.fromCharCode(t+64),i=r.slice(7,8),t===i},italy:function(r,e){var t=0;if(0===+r.slice(0,7))return!1;if(l=+r.slice(7,10),1>l||l>201&&999!==l&&888!==l)return!1;for(var n=0;10>n;n++)l=+r.charAt(n)*a[e].multipliers[n],t+=l>9?Math.floor(l/10)+l%10:l;return t=10-t%10,t>9&&(t=0),i=+r.slice(10,11),t===i},lithunia:function(r,e){var t=0;if(9===r.length){if(!/^\d{7}1/.test(r))return!1;t=0;for(var l=0;8>l;l++)t+=+r.charAt(l)*(l+1);if(t%11===10){t=0;for(var n=0;8>n;n++)t+=+r.charAt(n)*a[e].multipliers["short"][n]}return t%=11,10===t&&(t=0),i=+r.slice(8,9),t===i}if(!/^\d{10}1/.test(r))return!1;t=0;for(var u=0;11>u;u++)t+=+r.charAt(u)*a[e].multipliers.med[u];if(t%11===10){t=0;for(var s=0;11>s;s++)t+=+r.charAt(s)*a[e].multipliers.alt[s]}return t%=11,10===t&&(t=0),i=+r.slice(11,12),t===i},luxembourg:function(r){var e=+r.slice(6,8),t=+r.slice(0,6)%89;return t===e},latvia:function(r,e){var t=0;if(/^[0-3]/.test(r))return!!/^[0-3][0-9][0-1][0-9]/.test(r);for(var l=0;10>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t%11===4&&9===r[0]&&(t-=45),t%11===4?t=4-t%11:t%11>4?t=14-t%11:4>t%11&&(t=3-t%11),i=+r.slice(10,11),t===i},malta:function(r,e){for(var t=0,l=0;6>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t=37-t%37,i=+r.slice(6,8),t===i},netherlands:function(r,e){for(var t=0,l=0;8>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t%=11,t>9&&(t=0),i=+r.slice(8,9),t===i},norway:function(r,e){for(var t=0,l=0;8>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t=11-t%11,11===t&&(t=0),10>t?(i=+r.slice(8,9),t===i):void 0},poland:function(r,e){for(var t=0,l=0;9>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t%=11,t>9&&(t=0),i=+r.slice(9,10),t===i},portugal:function(r,e){for(var t=0,l=0;8>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t=11-t%11,t>9&&(t=0),i=+r.slice(8,9),t===i},romania:function(r,e){for(var t=0,l=r.length,n=a[e].multipliers.slice(10-l),u=0;u<r.length-1;u++)t+=+r.charAt(u)*n[u];return t=10*t%11,10===t&&(t=0),i=+r.slice(r.length-1,r.length),t===i},serbia:function(r){for(var e,t=10,l=0,a=0;8>a;a++)l=(+r.charAt(a)+t)%10,0===l&&(l=10),t=2*l%11;return i=1,e=(t+ +r.slice(8,9))%10,e===i},russia:function(r,e){var t,l=0;if(10===r.length){for(var n=0;10>n;n++)l+=+r.charAt(n)*a[e].multipliers.m_1[n];return l%=11,l>9&&(l%=10),i=+r.slice(9,10),l===i}if(12===r.length){for(var u=0,s=0,c=0;11>c;c++)u+=+r.charAt(c)*a[e].multipliers.m_2[c];u%=11,u>9&&(u%=10);for(var o=0;11>o;o++)s+=+r.charAt(o)*a[e].multipliers.m_3[o];return s%=11,s>9&&(s%=10),i=u===+r.slice(10,11),t=s===+r.slice(11,12),i&&t}},sweden:function(r){for(var e,t=0,l=0;9>l;l+=2)e=+r.charAt(l),t+=Math.floor(e/5)+2*e%10;for(var a=0,n=1;9>n;n+=2)a+=+r.charAt(n);var u=(10-(t+a)%10)%10;return i=+r.slice(9,10),u===i},slovenia:function(r,e){for(var t=0,l=0;7>l;l++)t+=+r.charAt(l)*a[e].multipliers[l];return t=11-t%11,10===t&&(t=0),i=+r.slice(7,8),!(11===t||t!==i)},slovakia_republic:function(r){var e=0,t=r%11;return t===e}};return"object"==typeof module&&module.exports&&(module.exports=n),n}();return r});
//# sourceMappingURL=angular-jsvat.min.js.map
{
"name": "angular-jsvat",
"version": "0.4.7-2",
"version": "0.6.1-1",
"description": "Check the validity of the format of an EU VAT number specified",

@@ -39,16 +39,16 @@ "main": "./dist/angular-jsvat.js",

"devDependencies": {
"chai": "^3.4.1",
"chai": "^3.5.0",
"gulp-filesize": "0.0.6",
"gulp-jshint": "^2.0.0",
"gulp-ng-annotate": "^1.1.0",
"gulp-ng-annotate": "^2.0.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^1.6.0",
"gulp-todo": "^4.0.0",
"gulp-uglify": "^1.4.2",
"gulp-todo": "^4.1.0",
"gulp-uglify": "^1.5.3",
"gulp-watch": "^4.3.5",
"gulp-wrap": "^0.11.0",
"jshint": "^2.8.0",
"jshint-stylish": "^2.0.1",
"mocha": "^2.3.4"
"jshint": "^2.9.1",
"jshint-stylish": "^2.1.0",
"mocha": "^2.4.5"
}
}
var jsvat = (function () {
'use strict';
var _REGEXP_LIST = {
austria: /^(AT)U(\d{8})$/,
belgium: /^(BE)(0?\d{9})$/,
bulgaria: /^(BG)(\d{9,10})$/,
switzerland: /^(CHE)(\d{9})(MWST)?$/,
cyprus: /^(CY)([0-59]\d{7}[A-Z])$/,
czech_republic: /^(CZ)(\d{8,10})(\d{3})?$/,
germany: /^(DE)([1-9]\d{8})$/,
denmark: /^(DK)(\d{8})$/,
estonia: /^(EE)(10\d{7})$/,
greece: /^(EL)(\d{9})$/,
spain: [
/^(ES)([A-Z]\d{8})$/,
/^(ES)([A-HN-SW]\d{7}[A-J])$/,
/^(ES)([0-9YZ]\d{7}[A-Z])$/,
/^(ES)([KLMX]\d{7}[A-Z])$/
],
europe: /^(EU)(\d{9})$/,
finland: /^(FI)(\d{8})$/,
france: [
/^(FR)(\d{11})$/,
/^(FR)([A-HJ-NP-Z]\d{10})$/,
/^(FR)(\d[A-HJ-NP-Z]\d{9})$/,
/^(FR)([A-HJ-NP-Z]{2}\d{9})$/
],
united_kingdom: [
/^(GB)?(\d{9})$/,
/^(GB)?(\d{12})$/,
/^(GB)?(GD\d{3})$/,
/^(GB)?(HA\d{3})$/
],
croatia: /^(HR)(\d{11})$/,
hungary: /^(HU)(\d{8})$/,
ireland: [
/^(IE)(\d{7}[A-W])$/,
/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/,
/^(IE)(\d{7}[A-W][AH])$/
],
italy: /^(IT)(\d{11})$/,
latvia: /^(LV)(\d{11})$/,
lithunia: /^(LT)(\d{9}|\d{12})$/,
luxembourg: /^(LU)(\d{8})$/,
malta: /^(MT)([1-9]\d{7})$/,
netherlands: /^(NL)(\d{9})B\d{2}$/,
norway: /^(NO)(\d{9})$/,
poland: /^(PL)(\d{10})$/,
portugal: /^(PT)(\d{9})$/,
romania: /^(RO)([1-9]\d{1,9})$/,
russia: /^(RU)(\d{10}|\d{12})$/,
serbia: /^(RS)(\d{9})$/,
slovenia: /^(SI)([1-9]\d{7})$/,
slovakia_republic: /^(SK)([1-9]\d[2346-9]\d{7})$/,
sweden: /^(SE)(\d{10}01)$/
var CONDITIONS = {
austria: {
multipliers: [1, 2, 1, 2, 1, 2, 1],
regex: /^(AT)U(\d{8})$/
},
belgium: {
regex: /^(BE)(0?\d{9})$/
},
bulgaria: {
multipliers: {
physical: [2, 4, 8, 5, 10, 9, 7, 3, 6],
foreigner: [21, 19, 17, 13, 11, 9, 7, 3, 1],
miscellaneous: [4, 3, 2, 7, 6, 5, 4, 3, 2]
},
regex: /^(BG)(\d{9,10})$/
},
switzerland: {
multipliers: [5, 4, 3, 2, 7, 6, 5, 4],
regex: /^(CHE)(\d{9})(MWST)?$/
},
cyprus: {
regex: /^(CY)([0-59]\d{7}[A-Z])$/
},
czech_republic: {
multipliers: [8, 7, 6, 5, 4, 3, 2],
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10],
regex: /^(CZ)(\d{8,10})(\d{3})?$/,
additional: [
/^\d{8}$/,
/^[0-5][0-9][0|1|5|6]\d[0-3]\d\d{3}$/,
/^6\d{8}$/,
/^\d{2}[0-3|5-8]\d[0-3]\d\d{4}$/
]
},
germany: {
regex: /^(DE)([1-9]\d{8})$/
},
denmark: {
multipliers: [2, 7, 6, 5, 4, 3, 2, 1],
regex: /^(DK)(\d{8})$/
},
estonia: {
multipliers: [3, 7, 1, 3, 7, 1, 3, 7],
regex: /^(EE)(10\d{7})$/
},
greece: {
multipliers: [256, 128, 64, 32, 16, 8, 4, 2],
regex: /^(EL)(\d{9})$/
},
spain: {
multipliers: [2, 1, 2, 1, 2, 1, 2],
regex: [
/^(ES)([A-Z]\d{8})$/,
/^(ES)([A-HN-SW]\d{7}[A-J])$/,
/^(ES)([0-9YZ]\d{7}[A-Z])$/,
/^(ES)([KLMX]\d{7}[A-Z])$/
],
additional: [
/^[A-H|J|U|V]\d{8}$/,
/^[A-H|N-S|W]\d{7}[A-J]$/,
/^[0-9|Y|Z]\d{7}[A-Z]$/,
/^[K|L|M|X]\d{7}[A-Z]$/
]
},
europe: {
regex: /^(EU)(\d{9})$/
},
finland: {
multipliers: [7, 9, 10, 5, 8, 4, 2],
regex: /^(FI)(\d{8})$/
},
france: {
regex: [
/^(FR)(\d{11})$/,
/^(FR)([A-HJ-NP-Z]\d{10})$/,
/^(FR)(\d[A-HJ-NP-Z]\d{9})$/,
/^(FR)([A-HJ-NP-Z]{2}\d{9})$/
]
},
united_kingdom: {
multipliers: [8, 7, 6, 5, 4, 3, 2],
regex: [
/^(GB)?(\d{9})$/,
/^(GB)?(\d{12})$/,
/^(GB)?(GD\d{3})$/,
/^(GB)?(HA\d{3})$/
]
},
croatia: {
regex: /^(HR)(\d{11})$/
},
hungary: {
multipliers: [9, 7, 3, 1, 9, 7, 3],
regex: /^(HU)(\d{8})$/
},
ireland: {
multipliers: [8, 7, 6, 5, 4, 3, 2],
regex: [
/^(IE)(\d{7}[A-W])$/,
/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/,
/^(IE)(\d{7}[A-W][AH])$/
]
},
italy: {
multipliers: [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],
regex: /^(IT)(\d{11})$/
},
latvia: {
multipliers: [9, 1, 4, 8, 3, 10, 2, 5, 7, 6],
regex: /^(LV)(\d{11})$/
},
lithunia: {
multipliers: {
short: [3, 4, 5, 6, 7, 8, 9, 1],
med: [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2],
alt: [3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4]
},
regex: /^(LT)(\d{9}|\d{12})$/
},
luxembourg: {
regex: /^(LU)(\d{8})$/
},
malta: {
multipliers: [3, 4, 6, 7, 8, 9],
regex: /^(MT)([1-9]\d{7})$/
},
netherlands: {
multipliers: [9, 8, 7, 6, 5, 4, 3, 2],
regex: /^(NL)(\d{9})B\d{2}$/
},
norway: {
multipliers: [3, 2, 7, 6, 5, 4, 3, 2],
regex: /^(NO)(\d{9})$/
},
poland: {
multipliers: [6, 5, 7, 2, 3, 4, 5, 6, 7],
regex: /^(PL)(\d{10})$/
},
portugal: {
multipliers: [9, 8, 7, 6, 5, 4, 3, 2],
regex: /^(PT)(\d{9})$/
},
romania: {
multipliers: [7, 5, 3, 2, 1, 7, 5, 3, 2],
regex: /^(RO)([1-9]\d{1,9})$/
},
russia: {
multipliers: {
m_1: [2, 4, 10, 3, 5, 9, 4, 6, 8, 0],
m_2: [7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0],
m_3: [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0]
},
regex: /^(RU)(\d{10}|\d{12})$/
},
serbia: {
regex: /^(RS)(\d{9})$/
},
slovenia: {
multipliers: [8, 7, 6, 5, 4, 3, 2],
regex: /^(SI)([1-9]\d{7})$/
},
slovakia_republic: {
regex: /^(SK)([1-9]\d[2346-9]\d{7})$/
},
sweden: {
regex: /^(SE)(\d{10}01)$/
}
};
function _validateRegexp(vat, regexp) {
return regexp.test(vat);
function _validateRegex(vat, regex) {
return regex.test(vat);
}
function _validateRules(vat, regexp, countryName) {
var parsedNum = regexp.exec(vat);
function _validateRules(vat, regex, countryName) {
var parsedNum = regex.exec(vat);

@@ -70,9 +187,9 @@ //var code = parsedNum[1];

return _checks[countryName](number);
return _checks[countryName](number, countryName);
}
function _validate(vat, regexp, countryName) {
function _validate(vat, regex, countryName) {
var result = false;
if (_validateRegexp(vat, regexp)) {
result = _validateRules(vat, regexp, countryName);
if (_validateRegex(vat, regex)) {
result = _validateRules(vat, regex, countryName);
}

@@ -87,13 +204,13 @@ return result;

for (var countryName in _REGEXP_LIST) {
if (_REGEXP_LIST.hasOwnProperty(countryName)) {
var regexp = _REGEXP_LIST[countryName];
for (var countryName in CONDITIONS) {
if (CONDITIONS.hasOwnProperty(countryName)) {
var regex = CONDITIONS[countryName].regex;
//TODO (S.Panfilov) this is not cross-browser check
if (Array.isArray(regexp)) {
for (var i = 0; i < regexp.length; i++) {
if (_validate(vat, regexp[i], countryName)) return true;
if (Array.isArray(regex)) {
for (var i = 0; i < regex.length; i++) {
if (_validate(vat, regex[i], countryName)) return true;
}
} else {
if (_validate(vat, regexp, countryName)) return true;
if (_validate(vat, regex, countryName)) return true;
}

@@ -107,11 +224,10 @@ }

var expect;
var temp;
var _checks = {
austria: function (vat) {
austria: function (vat, countryName) {
var total = 0;
var multipliers = [1, 2, 1, 2, 1, 2, 1];
var temp;
var expect;
for (var i = 0; i < 7; i++) {
temp = vat.charAt(i) * multipliers[i];
temp = vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
if (temp > 9)

@@ -131,19 +247,15 @@ total += Math.floor(temp / 10) + temp % 10;

belgium: function (vat) {
var expect;
var check;
if (vat.length === 9) vat = "0" + vat;
if (vat.length === 9) {
vat = '0' + vat;
}
if (+vat.slice(1, 2) === 0) return false;
check = (97 - +vat.slice(0, 8) % 97);
var check = (97 - +vat.slice(0, 8) % 97);
expect = +vat.slice(8, 10);
return check === expect;
},
bulgaria: function (vat) {
var expect;
var multipliers;
var temp;
var total;
bulgaria: function (vat, countryName) {
var checkNineLengthVat = function () {
var total =0;
temp = 0;

@@ -173,2 +285,3 @@ for (var i = 0; i < 8; i++) {

var isPhysicalPerson = function () {
var total = 0;
// 10 digit VAT code - see if it relates to a standard physical person

@@ -180,7 +293,5 @@ if ((/^\d\d[0-5]\d[0-3]\d\d{4}$/).test(vat)) {

// Extract the next digit and multiply by the counter.
multipliers = [2, 4, 8, 5, 10, 9, 7, 3, 6];
total = 0;
for (var k = 0; k < 9; k++) {
total += +vat.charAt(k) * multipliers[k];
total += +vat.charAt(k) * CONDITIONS[countryName].multipliers.physical[k];
}

@@ -202,7 +313,6 @@ // Establish check digit.

var isForeigner = function () {
var total = 0;
// Extract the next digit and multiply by the counter.
multipliers = [21, 19, 17, 13, 11, 9, 7, 3, 1];
total = 0;
for (var l = 0; l < 9; l++) {
total += +vat.charAt(l) * multipliers[l];
total += +vat.charAt(l) * CONDITIONS[countryName].multipliers.foreigner[l];
}

@@ -217,9 +327,7 @@

var miscellaneousVAT = function () {
var total = 0;
// Finally, if not yet identified, see if it conforms to a miscellaneous VAT number
// Extract the next digit and multiply by the counter.
multipliers = [4, 3, 2, 7, 6, 5, 4, 3, 2];
total = 0;
for (var m = 0; m < 9; m++) {
total += +vat.charAt(m) * multipliers[m];
total += +vat.charAt(m) * CONDITIONS[countryName].multipliers.miscellaneous[m];
}

@@ -244,11 +352,7 @@

},
switzerland: function (vat) {
var expect;
// Checks the check digits of a Swiss VAT number.
// Extract the next digit and multiply by the counter.
var multipliers = [5, 4, 3, 2, 7, 6, 5, 4];
switzerland: function (vat, countryName) {
var total = 0;
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -265,6 +369,3 @@ // Establish check digit.

cyprus: function (vat) {
var expect;
// Checks the check digits of a Cypriot VAT number.
var total = 0;
// Not allowed to start with '12'

@@ -274,3 +375,3 @@ if (+vat.slice(0, 2) === 12) return false;

// Extract the next digit and multiply by the counter.
var total = 0;
for (var i = 0; i < 8; i++) {

@@ -310,22 +411,11 @@ var temp = +vat.charAt(i);

},
czech_republic: function (vat) {
var expect;
// Checks the check digits of a Czech Republic VAT number.
czech_republic: function (vat, countryName) {
var total = 0;
var multipliers = [8, 7, 6, 5, 4, 3, 2];
var czExp = [];
czExp[0] = (/^\d{8}$/);
czExp[1] = (/^[0-5][0-9][0|1|5|6]\d[0-3]\d\d{3}$/);
czExp[2] = (/^6\d{8}$/);
czExp[3] = (/^\d{2}[0-3|5-8]\d[0-3]\d\d{4}$/);
// Legal entities
if (czExp[0].test(vat)) {
if (CONDITIONS[countryName].additional[0].test(vat)) {
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 7; i++) {
total += +vat.charAt(i) * multipliers[i];
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -343,15 +433,8 @@

// Individuals type 1
//else if (czExp[1].test(vat)) {
//TODO (S.Panfilov) It's seems to be an error
// return !(temp = +vat.slice(0, 2) > 53);
//
//}
// Individuals type 2
else if (czExp[2].test(vat)) {
else if (CONDITIONS[countryName].additional[2].test(vat)) {
// Extract the next digit and multiply by the counter.
for (var j = 0; j < 7; j++) {
total += +vat.charAt(j + 1) * multipliers[j];
total += +vat.charAt(j + 1) * CONDITIONS[countryName].multipliers[j];
}

@@ -365,9 +448,8 @@

// Convert calculated check digit according to a lookup table;
var lookup = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10];
expect = +vat.slice(8, 9);
return lookup[total - 1] === expect;
return CONDITIONS[countryName].lookup[total - 1] === expect;
}
// Individuals type 3
else if (czExp[3].test(vat)) {
else if (CONDITIONS[countryName].additional[3].test(vat)) {
var temp = +vat.slice(0, 2) + vat.slice(2, 4) + vat.slice(4, 6) + vat.slice(6, 8) + vat.slice(8);

@@ -382,4 +464,4 @@ expect = +vat % 11 === 0;

germany: function (vat) {
var expect;
// Checks the check digits of a German VAT number.

@@ -412,20 +494,16 @@

},
denmark: function (vat) {
denmark: function (vat, countryName) {
var total = 0;
var multipliers = [2, 7, 6, 5, 4, 3, 2, 1];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
return total % 11 === 0;
},
estonia: function (vat) {
var expect;
// Checks the check digits of an Estonian VAT number.
estonia: function (vat, countryName) {
var total = 0;
var multipliers = [3, 7, 1, 3, 7, 1, 3, 7];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -440,17 +518,13 @@ // Establish check digits using modulus 10.

},
greece: function (vat) {
var expect;
// Checks the check digits of a Greek VAT number.
greece: function (vat, countryName) {
var total = 0;
var multipliers = [256, 128, 64, 32, 16, 8, 4, 2];
//eight character numbers should be prefixed with an 0.
if (vat.length === 8) {
vat = "0" + vat;
vat = '0' + vat;
}
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -467,23 +541,12 @@ // Establish check digit.

},
spain: function (vat) {
var expect;
// Checks the check digits of a Spanish VAT number.
spain: function (vat, countryName) {
var i = 0;
var total = 0;
var temp = 0;
var multipliers = [2, 1, 2, 1, 2, 1, 2];
var esExp = [];
esExp[0] = (/^[A-H|J|U|V]\d{8}$/);
esExp[1] = (/^[A-H|N-S|W]\d{7}[A-J]$/);
esExp[2] = (/^[0-9|Y|Z]\d{7}[A-Z]$/);
esExp[3] = (/^[K|L|M|X]\d{7}[A-Z]$/);
var i = 0;
// National juridical entities
if (esExp[0].test(vat)) {
if (CONDITIONS[countryName].additional[0].test(vat)) {
// Extract the next digit and multiply by the counter.
for (i = 0; i < 7; i++) {
temp = vat.charAt(i + 1) * multipliers[i];
temp = vat.charAt(i + 1) * CONDITIONS[countryName].multipliers[i];
if (temp > 9)

@@ -506,7 +569,7 @@ total += Math.floor(temp / 10) + temp % 10;

// Juridical entities other than national ones
else if (esExp[1].test(vat)) {
else if (CONDITIONS[countryName].additional[1].test(vat)) {
// Extract the next digit and multiply by the counter.
for (i = 0; i < 7; i++) {
temp = vat.charAt(i + 1) * multipliers[i];
temp = vat.charAt(i + 1) * CONDITIONS[countryName].multipliers[i];
if (temp > 9)

@@ -528,6 +591,6 @@ total += Math.floor(temp / 10) + temp % 10;

// Personal number (NIF) (starting with numeric of Y or Z)
else if (esExp[2].test(vat)) {
else if (CONDITIONS[countryName].additional[2].test(vat)) {
var tempnumber = vat;
if (tempnumber.substring(0, 1) === 'Y') tempnumber = tempnumber.replace(/Y/, "1");
if (tempnumber.substring(0, 1) === 'Z') tempnumber = tempnumber.replace(/Z/, "2");
if (tempnumber.substring(0, 1) === 'Y') tempnumber = tempnumber.replace(/Y/, '1');
if (tempnumber.substring(0, 1) === 'Z') tempnumber = tempnumber.replace(/Z/, '2');
expect = 'TRWAGMYFPDXBNJZSQVHLCKE'.charAt(+tempnumber.substring(0, 8) % 23);

@@ -538,3 +601,3 @@ return tempnumber.charAt(8) === expect;

// Personal number (NIF) (starting with K, L, M, or X)
else if (esExp[3].test(vat)) {
else if (CONDITIONS[countryName].additional[3].test(vat)) {
expect = 'TRWAGMYFPDXBNJZSQVHLCKE'.charAt(+vat.substring(1, 8) % 23);

@@ -547,3 +610,3 @@ return vat.charAt(8) === expect;

europe: function () {
//TODO (S.Panfilov) wtf?
// We know little about EU numbers apart from the fact that the first 3 digits represent the

@@ -553,12 +616,6 @@ // country, and that there are nine digits in total.

},
finland: function (vat) {
var expect;
// Checks the check digits of a Finnish VAT number.
finland: function (vat, countryName) {
var total = 0;
var multipliers = [7, 9, 10, 5, 8, 4, 2];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 7; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 7; i++) total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];

@@ -576,6 +633,4 @@ // Establish check digit.

france: function (vat) {
var expect;
var total;
// Checks the check digits of a French VAT number.
if (!(/^\d{11}$/).test(vat)) {

@@ -586,3 +641,3 @@ return true;

// Extract the last nine digits as an integer.
var total = +vat.substring(2);
total = +vat.substring(2);

@@ -596,9 +651,4 @@ // Establish check digit.

},
united_kingdom: function (vat) {
var expect;
// Checks the check digits of a UK VAT number.
var multipliers = [8, 7, 6, 5, 4, 3, 2];
united_kingdom: function (vat, countryName) {
var total = 0;
// Government departments

@@ -617,4 +667,4 @@ if (vat.substr(0, 2) === 'GD') {

// Standard and commercial numbers
var total = 0;
// 0 VAT numbers disallowed!

@@ -627,3 +677,5 @@ if (+vat.slice(0) === 0) return false;

// Extract the next digit and multiply by the counter.
for (var i = 0; i < 7; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 7; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -654,4 +706,4 @@ // Old numbers use a simple 97 modulus, but new numbers use an adaptation of that (less 55). Our

croatia: function (vat) {
var expect;
// Checks the check digits of a Croatian VAT number using ISO 7064, MOD 11-10 for check digit.

@@ -677,12 +729,8 @@

},
hungary: function (vat) {
var expect;
// Checks the check digits of a Hungarian VAT number.
hungary: function (vat, countryName) {
var total = 0;
var multipliers = [9, 7, 3, 1, 9, 7, 3];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 7; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 7; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -697,13 +745,7 @@ // Establish check digit.

},
ireland: function (vat) {
var expect;
// Checks the check digits of an Irish VAT number.
ireland: function (vat, countryName) {
var total = 0;
var multipliers = [8, 7, 6, 5, 4, 3, 2];
// If the code is type 1 format, we need to convert it to the new before performing the validation.
if (/^\d[A-Z\*\+]/.test(vat)) {
vat = "0" + vat.substring(2, 7) + vat.substring(0, 1) + vat.substring(7, 8);
vat = '0' + vat.substring(2, 7) + vat.substring(0, 1) + vat.substring(7, 8);
}

@@ -713,3 +755,3 @@

for (var i = 0; i < 7; i++) {
total += +vat.charAt(i) * multipliers[i];
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -730,3 +772,3 @@

if (total === 0) {
total = "W";
total = 'W';
} else {

@@ -740,11 +782,4 @@ total = String.fromCharCode(total + 64);

},
italy: function (vat) {
var expect;
// Checks the check digits of an Italian VAT number.
italy: function (vat, countryName) {
var total = 0;
var multipliers = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2];
var temp;
// The last three digits are the issuing office, and cannot exceed more 201, unless 999 or 888

@@ -762,3 +797,3 @@ if (+vat.slice(0, 7) === 0) {

for (var i = 0; i < 10; i++) {
temp = +vat.charAt(i) * multipliers[i];
temp = +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
if (temp > 9)

@@ -780,9 +815,4 @@ total += Math.floor(temp / 10) + temp % 10;

},
lithunia: function (vat) {
var total;
var multipliers;
var expect;
// Checks the check digits of a Lithuanian VAT number.
lithunia: function (vat, countryName) {
var total = 0;
// 9 character VAT numbers are for legal persons

@@ -802,6 +832,5 @@ if (vat.length === 9) {

if (total % 11 === 10) {
multipliers = [3, 4, 5, 6, 7, 8, 9, 1];
total = 0;
for (var j = 0; j < 8; j++) {
total += +vat.charAt(j) * multipliers[j];
total += +vat.charAt(j) * CONDITIONS[countryName].multipliers.short[j];
}

@@ -829,5 +858,4 @@ }

total = 0;
multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2];
for (var k = 0; k < 11; k++) {
total += +vat.charAt(k) * multipliers[k];
total += +vat.charAt(k) * CONDITIONS[countryName].multipliers.med[k];
}

@@ -837,6 +865,5 @@

if (total % 11 === 10) {
multipliers = [3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4];
total = 0;
for (var l = 0; l < 11; l++) {
total += +vat.charAt(l) * multipliers[l];
total += +vat.charAt(l) * CONDITIONS[countryName].multipliers.alt[l];
}

@@ -863,7 +890,5 @@ }

},
latvia: function (vat) {
var expect;
latvia: function (vat, countryName) {
var total = 0;
// Checks the check digits of a Latvian VAT number.
// Differentiate between legal entities and natural bodies. For the latter we simply check that

@@ -875,7 +900,6 @@ // the first six digits correspond to valid DDMMYY dates.

var total = 0;
var multipliers = [9, 1, 4, 8, 3, 10, 2, 5, 7, 6];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 10; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 10; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -896,12 +920,8 @@ // Establish check digits by getting modulus 11.

},
malta: function (vat) {
var expect;
// Checks the check digits of a Maltese VAT number.
malta: function (vat, countryName) {
var total = 0;
var multipliers = [3, 4, 6, 7, 8, 9];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 6; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 6; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -915,12 +935,8 @@ // Establish check digits by getting modulus 37.

},
netherlands: function (vat) {
var expect;
// Checks the check digits of a Dutch VAT number.
netherlands: function (vat, countryName) {
var total = 0;
var multipliers = [9, 8, 7, 6, 5, 4, 3, 2];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -937,13 +953,10 @@ // Establish check digits by getting modulus 11.

},
norway: function (vat) {
var expect;
// Checks the check digits of a Norwegian VAT number.
norway: function (vat, countryName) {
var total = 0;
// See http://www.brreg.no/english/coordination/number.html
var total = 0;
var multipliers = [3, 2, 7, 6, 5, 4, 3, 2];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -962,12 +975,8 @@ // Establish check digits by getting modulus 11. Check digits > 9 are invalid

},
poland: function (vat) {
var expect;
// Checks the check digits of a Polish VAT number.
poland: function (vat, countryName) {
var total = 0;
var multipliers = [6, 5, 7, 2, 3, 4, 5, 6, 7];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 9; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 9; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -984,12 +993,8 @@ // Establish check digits subtracting modulus 11 from 11.

},
portugal: function (vat) {
var expect;
// Checks the check digits of a Portugese VAT number.
portugal: function (vat, countryName) {
var total = 0;
var multipliers = [9, 8, 7, 6, 5, 4, 3, 2];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 8; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 8; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -1006,13 +1011,8 @@ // Establish check digits subtracting modulus 11 from 11.

},
romania: function (vat) {
var expect;
// Checks the check digits of a Romanian VAT number.
var multipliers = [7, 5, 3, 2, 1, 7, 5, 3, 2];
romania: function (vat, countryName) {
var total = 0;
// Extract the next digit and multiply by the counter.
var vatLength = vat.length;
multipliers = multipliers.slice(10 - vatLength);
var total = 0;
var multipliers = CONDITIONS[countryName].multipliers.slice(10 - vatLength);
for (var i = 0; i < vat.length - 1; i++) {

@@ -1031,4 +1031,2 @@ total += +vat.charAt(i) * multipliers[i];

serbia: function (vat) {
var expect;
// Checks the check digits of a Serbian VAT number using ISO 7064, MOD 11-10 for check digit.

@@ -1055,4 +1053,4 @@

},
russia: function (vat) {
var expect;
russia: function (vat, countryName) {
var total = 0;
var expect2;

@@ -1065,6 +1063,5 @@

if (vat.length === 10) {
var total = 0;
var multipliers = [2, 4, 10, 3, 5, 9, 4, 6, 8, 0];
for (var i = 0; i < 10; i++) {
total += +vat.charAt(i) * multipliers[i];
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers.m_1[i];
}

@@ -1084,8 +1081,6 @@

var total1 = 0;
var multipliers1 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0];
var total2 = 0;
var multipliers2 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0];
for (var j = 0; j < 11; j++) {
total1 += +vat.charAt(j) * multipliers1[j];
total1 += +vat.charAt(j) * CONDITIONS[countryName].multipliers.m_2[j];
}

@@ -1099,3 +1094,3 @@

for (var k = 0; k < 11; k++) {
total2 += +vat.charAt(k) * multipliers2[k];
total2 += +vat.charAt(k) * CONDITIONS[countryName].multipliers.m_3[k];
}

@@ -1110,4 +1105,6 @@

// character of the VAT number. If they're both the same, then it's valid
expect = +vat.slice(10, 11);
expect2 = +vat.slice(11, 12);
//expect = +vat.slice(10, 11);
expect = (total1 === +vat.slice(10, 11));
//expect2 = +vat.slice(11, 12);
expect2 = (total2 === +vat.slice(11, 12));
return (expect) && (expect2);

@@ -1117,4 +1114,2 @@ }

sweden: function (vat) {
var expect;
// Calculate R where R = R1 + R3 + R5 + R7 + R9, and Ri = INT(Ci/5) + (Ci*2) modulo 10

@@ -1141,12 +1136,8 @@ var R = 0;

},
slovenia: function (vat) {
var expect;
// Checks the check digits of a Slovenian VAT number.
slovenia: function (vat, countryName) {
var total = 0;
var multipliers = [8, 7, 6, 5, 4, 3, 2];
// Extract the next digit and multiply by the counter.
for (var i = 0; i < 7; i++) total += +vat.charAt(i) * multipliers[i];
for (var i = 0; i < 7; i++) {
total += +vat.charAt(i) * CONDITIONS[countryName].multipliers[i];
}

@@ -1153,0 +1144,0 @@ // Establish check digits using modulus 11

### TODOs
| Filename | line # | TODO
|:------|:------:|:------
| jsvat.js | 90 | (S.Panfilov) this is not cross-browser check
| jsvat.js | 333 | (S.Panfilov) It's seems to be an error
| jsvat.js | 207 | (S.Panfilov) this is not cross-browser check
| jsvat.js | 589 | (S.Panfilov) wtf?

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc