stdnum.it.codicefiscale

Codice Fiscale (Italian tax code for individuals).

The Codice Fiscale is an alphanumeric code of 16 characters used to identify individuals residing in Italy. The number consists of three characters derived from the person’s last name, three from the person’s first name, five that hold information on the person’s gender and birth date, four that represent the person’s place of birth and one check digit.

>>> validate('RCCMNL83S18D969H')
'RCCMNL83S18D969H'
>>> validate('RCCMNL83S18D969')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> calc_check_digit('RCCMNL83S18D969')
'H'
Traceback (most recent call last):
    ...
InvalidLength: ...
stdnum.it.codicefiscale.calc_check_digit(number)

Compute the control code for the given number. The passed number should be the first 15 characters of a fiscal code.

stdnum.it.codicefiscale.compact(number)

Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

stdnum.it.codicefiscale.get_birth_date(number, minyear=1920)

Get the birth date from the person’s whose fiscal code.

Only the last two digits of the year are stured in the number. The dates will be returned in the range from minyear to minyear + 100.

>>> get_birth_date('RCCMNL83S18D969H')
datetime.date(1983, 11, 18)
>>> get_birth_date('RCCMNL83S18D969H', minyear=1990)
datetime.date(2083, 11, 18)
stdnum.it.codicefiscale.get_gender(number)

Get the gender of the person’s provided fiscal code.

>>> get_gender('RCCMNL83S18D969H')
'M'
>>> get_gender('CNTCHR83T41D969D')
'F'
stdnum.it.codicefiscale.is_valid(number)

Checks to see if the given fiscal code is valid. This checks the length and whether the check digit is correct.

stdnum.it.codicefiscale.validate(number)

Checks to see if the given fiscal code is valid. This checks the length and whether the check digit is correct.

Previous topic

stdnum.issn

Next topic

stdnum.it.iva