heavybeard / codice-fiscale

Javascript object for managing the italian tax code
http://heavybeard.github.io/codice-fiscale/
MIT License
9 stars 4 forks source link
bower-package calculations codice-fiscale codicefiscale tax

CodiceFiscale

Javascript object for managing the italian tax code.

bower install codice-fiscale --save

or

npm install codice-fiscale-js --save

How To Use

Add the Object file

<script src="https://github.com/heavybeard/codice-fiscale/raw/master/CodiceFiscale.min.js" type="text/javascript"></script>

Use the function to calculate the tax code

var person = new CodiceFiscale({
    name: "Mario",
    lastname: "Rossi",
    day: "25",
    month: "04",
    year: "1945",
    isMale: true,
    communeName: "Milano",
});

Use the public function for getting specific taxcode part

person.taxCode(); // RSSMRA45D25F205N
person.lastnameCode(); // RSS
person.nameCode(); //    MRA

person.dateCode(); //       45D25
person.yearCode(); //       45
person.monthCode(); //         D
person.dayCode(); //          25

person.communeCode(); //            F205

person.controlChar(); //                N

Known issues

Omocodia

This is an issue in italian system. In this case government offices change chars without a real algorithm because we don't know how many omocodias there're in this moment. Here there's a good explanation for calculating it.

It consists in replacing one or more of the seven numbers of the code, starting from the rightmost one, with the corresponding letters below:

0 = L | 1 = M | 2 = N | 3 = P | 4 = Q

5 = R | 6 = S | 7 = T | 8 = U | 9 = V

Calculation of control char

The control char calculation don't work properly, so the last tax code's char is not always right.

Versions

Version 1.1.4

Version 1.1.3

Version 1.1.2

Version 1.1.1

Version 1.1.0

Version 1.0.3

Version 1.0.2

Version 1.0.1

Version 1.0.0

Version 0.0.1

Credits

The code is freely taken from zingus.altervista.org. This is a refactoring code finally here, on Github.