Title: Italian Fiscal Code ('Codice Fiscale') Utilities
Version: 0.3.6
Description: Provides utility functions to deal with Italian fiscal code ('codice fiscale').
URL: https://github.com/lbraglia/ifctools
BugReports: https://github.com/lbraglia/ifctools/issues
Depends: R (≥ 3.1.1)
License: GPL-3
Suggests: testthat
RoxygenNote: 7.2.3
Encoding: UTF-8
NeedsCompilation: yes
Packaged: 2023-08-28 10:35:28 UTC; l
Author: Luca Braglia [aut, cre]
Maintainer: Luca Braglia <lbraglia@gmail.com>
Repository: CRAN
Date/Publication: 2023-08-28 10:50:05 UTC

Miscellaneous utils for Italian fiscal codes

Description

These package provide tools to deal with fiscal codes: a function to check if the fiscal code is valid (wrong_fc) and another to guess the code given personal data (guess_fc).

Details

Fiscal codes are far from perfect but ubiquitous personal id codes in Italy, especially useful for merge purposes from a data analyst standpoint.

WARNING: provided routines aim to be reasonably good. Unfortunately can't be perfect since, as wikipedia puts it, "On the internet, there are several web sites and software packages that allow one to calculate one's tax code. However, the only official tax code is the one provided by the tax office, which handles cases of identical tax codes (which is a pretty frequent case for people not born in Italy, as in this case the 4-characters town code in the codice fiscale is replace by a 3-digit country code), an arbitrary changing of a tax code, as well as cases where a code is incorrect, but still valid (because provided by the tax office)."

For more info see https://en.wikipedia.org/wiki/Italian_fiscal_code_card.

Author(s)

Maintainer: Luca Braglia lbraglia@gmail.com

See Also

Useful links:


Guess Italian Fiscal Code

Description

The function tries to guess regular fiscal code, extracting relevant alphanumeric digits from surname, name, birth date, gender and 'codice catastale' (computing the last character, the control digit).

Usage

guess_fc(
  surname = NULL,
  name = NULL,
  birth_date = NULL,
  female = NULL,
  codice_catastale = NULL
)

Arguments

surname

character, surname

name

character, names

birth_date

Date, date of birth

female

logical, female indicator variable (FALSE = man, TRUE = woman)

codice_catastale

Italian 'codice catastale' (an identifier) of the 'comune' of birth

Value

The function return a character vector of fiscal code.

Examples


## using fictious data
Surnames <- c("Rossi", "Bianchi")
Names <- c("Mario", "Giovanna")
Birthdates <- as.Date(c("1960-01-01", "1970-01-01"))
Female <- c(FALSE, TRUE)
Comune_of_birth <- c("F205", # milan
                     "H501") # rome
guess_fc(Surnames, Names, Birthdates, Female, Comune_of_birth)


Check Italian fiscal codes

Description

The function performs fiscal codes check (both regular and temporary ones), computing the last (control) character basing on the others. The algorithm is intended to be quite "draconian", so you'll better make some pre-cleaning (keep only alphabetic characters and uppercase) if needed. See examples.

Usage

wrong_fc(fc)

Arguments

fc

A character vector of fiscal codes.

Value

The function return TRUE if the fiscal code is wrong, FALSE otherwise.

References

Law source: D.M. (Ministry of Finance) n. 13813 - 23/12/76 - "Sistemi di codificazione dei soggetti da iscrivere all'anagrafe tributaria". Supp. ord. G.U. 345 29/12/1976.

Examples


fc <- c(NA, "qWeASd34D12h 221M   ", " 12312312312 ")
wrong_fc(fc)
fc <- gsub(" ","", toupper(fc))
wrong_fc(fc)