Fixed issue #46

This commit is contained in:
Luca Vandro 2020-09-25 17:32:52 +02:00
parent 8ff9bccad1
commit 2052b10e5c
8 changed files with 28 additions and 17 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

27
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "codice-fiscale-js",
"version": "2.3.2",
"version": "2.3.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -9165,10 +9165,13 @@
"dev": true
},
"serialize-javascript": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz",
"integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==",
"dev": true
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
"integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
"dev": true,
"requires": {
"randombytes": "^2.1.0"
}
},
"set-blocking": {
"version": "2.0.0",
@ -10025,9 +10028,9 @@
"dev": true
},
"terser": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-4.7.0.tgz",
"integrity": "sha512-Lfb0RiZcjRDXCC3OSHJpEkxJ9Qeqs6mp2v4jf2MHfy8vGERmVDuvjXdd/EnP5Deme5F2yBRBymKmKHCBg2echw==",
"version": "4.8.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-4.8.0.tgz",
"integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==",
"dev": true,
"requires": {
"commander": "^2.20.0",
@ -10050,16 +10053,16 @@
}
},
"terser-webpack-plugin": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz",
"integrity": "sha512-QMxecFz/gHQwteWwSo5nTc6UaICqN1bMedC5sMtUc7y3Ha3Q8y6ZO0iCR8pq4RJC8Hjf0FEPEHZqcMB/+DFCrA==",
"version": "1.4.5",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.5.tgz",
"integrity": "sha512-04Rfe496lN8EYruwi6oPQkG0vo8C+HT49X687FZnpPF0qMAIHONI6HEXYPKDOE8e5HjXTyKfqRd/agHtH0kOtw==",
"dev": true,
"requires": {
"cacache": "^12.0.2",
"find-cache-dir": "^2.1.0",
"is-wsl": "^1.1.0",
"schema-utils": "^1.0.0",
"serialize-javascript": "^2.1.2",
"serialize-javascript": "^4.0.0",
"source-map": "^0.6.1",
"terser": "^4.1.2",
"webpack-sources": "^1.4.0",

View File

@ -1,6 +1,6 @@
{
"name": "codice-fiscale-js",
"version": "2.3.4",
"version": "2.3.5",
"description": "The Italian Tax Code Library for Javascript and Typescript",
"main": "dist/codice.fiscale.commonjs2.js",
"types": "types/codice-fiscale.d.ts",

View File

@ -77,6 +77,8 @@ export class Comune {
return results[0]
else if(prov)
throw new Error(`Comune with name of ${nome} and prov ${prov} doesn't exists`)
else if(nome.length===4 && nome.toUpperCase() === nome)
return Comune.GetByCC(nome)
else
throw new Error(`Comune with name of ${nome} is found in more than one province. Please specify the province code`)

View File

@ -91,6 +91,8 @@ describe('CodiceFiscale.compute', () => {
})
test("calcola il codice fiscale di persone nate all'estero", () => {
expect(CodiceFiscale.compute({
name: 'Luca',
@ -120,6 +122,10 @@ describe('CodiceFiscale.compute', () => {
}
expect(comuneInventato).toThrowError('Comune with name of Foo and prov EE doesn\'t exists')
})
test('calcola il codice fiscale anche quando viene passato come birthplace il CC di un comune', ()=>{
expect(CodiceFiscale.compute({ name: "mario", surname: "rossi", gender: "M", birthday: "2000-01-01", birthplace: "H501" })).toBeDefined()
})
})
describe('CodiceFiscale.findLocationCode', () => {