Comparing version 2.5.2 to 2.5.3
@@ -22,3 +22,3 @@ define(["require", "exports"], function (require, exports) { | ||
}, | ||
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10], | ||
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8], | ||
regex: [/^(CZ)(\d{8,10})(\d{3})?$/], | ||
@@ -61,7 +61,10 @@ 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}$/] | ||
// Establish check digit. | ||
total = 11 - (total % 11); | ||
if (total === 10) | ||
total = 0; | ||
if (total === 11) | ||
total = 1; | ||
let a; | ||
if (total % 11 === 0) { | ||
a = total + 11; | ||
} | ||
else { | ||
a = Math.ceil(total / 11) * 11; | ||
} | ||
const pointer = a - total - 1; | ||
// Convert calculated check digit according to a lookup table | ||
@@ -71,3 +74,3 @@ const expect = Number(vat.slice(8, 9)); | ||
return false; | ||
return lookup[total - 1] === expect; | ||
return lookup[pointer] === expect; | ||
} | ||
@@ -74,0 +77,0 @@ return false; |
@@ -21,3 +21,3 @@ "use strict"; | ||
}, | ||
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10], | ||
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8], | ||
regex: [/^(CZ)(\d{8,10})(\d{3})?$/], | ||
@@ -60,7 +60,10 @@ 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}$/] | ||
// Establish check digit. | ||
total = 11 - (total % 11); | ||
if (total === 10) | ||
total = 0; | ||
if (total === 11) | ||
total = 1; | ||
var a = void 0; | ||
if (total % 11 === 0) { | ||
a = total + 11; | ||
} | ||
else { | ||
a = Math.ceil(total / 11) * 11; | ||
} | ||
var pointer = a - total - 1; | ||
// Convert calculated check digit according to a lookup table | ||
@@ -70,3 +73,3 @@ var expect = Number(vat.slice(8, 9)); | ||
return false; | ||
return lookup[total - 1] === expect; | ||
return lookup[pointer] === expect; | ||
} | ||
@@ -73,0 +76,0 @@ return false; |
@@ -18,3 +18,3 @@ export const czechRepublic = { | ||
}, | ||
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10], | ||
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8], | ||
regex: [/^(CZ)(\d{8,10})(\d{3})?$/], | ||
@@ -57,7 +57,10 @@ 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}$/] | ||
// Establish check digit. | ||
total = 11 - (total % 11); | ||
if (total === 10) | ||
total = 0; | ||
if (total === 11) | ||
total = 1; | ||
let a; | ||
if (total % 11 === 0) { | ||
a = total + 11; | ||
} | ||
else { | ||
a = Math.ceil(total / 11) * 11; | ||
} | ||
const pointer = a - total - 1; | ||
// Convert calculated check digit according to a lookup table | ||
@@ -67,3 +70,3 @@ const expect = Number(vat.slice(8, 9)); | ||
return false; | ||
return lookup[total - 1] === expect; | ||
return lookup[pointer] === expect; | ||
} | ||
@@ -70,0 +73,0 @@ return false; |
@@ -38,7 +38,10 @@ System.register([], function (exports_1, context_1) { | ||
// Establish check digit. | ||
total = 11 - (total % 11); | ||
if (total === 10) | ||
total = 0; | ||
if (total === 11) | ||
total = 1; | ||
let a; | ||
if (total % 11 === 0) { | ||
a = total + 11; | ||
} | ||
else { | ||
a = Math.ceil(total / 11) * 11; | ||
} | ||
const pointer = a - total - 1; | ||
// Convert calculated check digit according to a lookup table | ||
@@ -48,3 +51,3 @@ const expect = Number(vat.slice(8, 9)); | ||
return false; | ||
return lookup[total - 1] === expect; | ||
return lookup[pointer] === expect; | ||
} | ||
@@ -85,3 +88,3 @@ return false; | ||
}, | ||
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10], | ||
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8], | ||
regex: [/^(CZ)(\d{8,10})(\d{3})?$/], | ||
@@ -88,0 +91,0 @@ 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}$/] |
@@ -30,3 +30,3 @@ (function (factory) { | ||
}, | ||
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10], | ||
lookup: [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8], | ||
regex: [/^(CZ)(\d{8,10})(\d{3})?$/], | ||
@@ -69,7 +69,10 @@ 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}$/] | ||
// Establish check digit. | ||
total = 11 - (total % 11); | ||
if (total === 10) | ||
total = 0; | ||
if (total === 11) | ||
total = 1; | ||
let a; | ||
if (total % 11 === 0) { | ||
a = total + 11; | ||
} | ||
else { | ||
a = Math.ceil(total / 11) * 11; | ||
} | ||
const pointer = a - total - 1; | ||
// Convert calculated check digit according to a lookup table | ||
@@ -79,3 +82,3 @@ const expect = Number(vat.slice(8, 9)); | ||
return false; | ||
return lookup[total - 1] === expect; | ||
return lookup[pointer] === expect; | ||
} | ||
@@ -82,0 +85,0 @@ return false; |
{ | ||
"name": "jsvat", | ||
"version": "2.5.2", | ||
"version": "2.5.3", | ||
"description": "Check the validity of the format of an EU VAT number", | ||
@@ -5,0 +5,0 @@ "main": "./lib/commonjs/index.js", |
@@ -1,2 +0,1 @@ | ||
[![Codacy Badge](https://api.codacy.com/project/badge/grade/874e7dce623149e18807bdc0a02671c2)](https://www.codacy.com/app/se-panfilov/jsvat) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/se-panfilov/jsvat/badge.svg?targetFile=package.json)](https://snyk.io/test/github/se-panfilov/jsvat?targetFile=package.json) | ||
@@ -3,0 +2,0 @@ [![Code Climate](https://codeclimate.com/github/se-panfilov/jsvat/badges/gpa.svg)](https://codeclimate.com/github/se-panfilov/jsvat) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8779
360769
264