All Projects → topac → codice_fiscale

topac / codice_fiscale

Licence: MIT License
A Ruby gem that calculates the Italian Tax ID (Codice Fiscale)

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to codice fiscale

python-codicefiscale
🇮🇹 💳 encode / decode italian fiscal codes - codifica / decodifica del Codice Fiscale italiano.
Stars: ✭ 53 (+211.76%)
Mutual labels:  italian, codicefiscale, italy
TrenitaliaAPI
Reverse engineering dell'API dell'app di Trenitalia
Stars: ✭ 32 (+88.24%)
Mutual labels:  italian, italy
username-generation-guide
A definitive guide to generating usernames for OSINT purposes
Stars: ✭ 38 (+123.53%)
Mutual labels:  generator
wolmo-bootstrap-react-native
Bootstrap generator for React Native projects
Stars: ✭ 20 (+17.65%)
Mutual labels:  generator
desktop
Extendable calculator for the 21st Century ⚡
Stars: ✭ 85 (+400%)
Mutual labels:  calculator
yang-schematics
Yet Another Angular Generator - based on @schematics/angular
Stars: ✭ 16 (-5.88%)
Mutual labels:  generator
micro-svelte-compiler
Micro Svelte compiler (naive clone)
Stars: ✭ 56 (+229.41%)
Mutual labels:  generator
roadifier
Open Source road mesh generator script for Unity
Stars: ✭ 30 (+76.47%)
Mutual labels:  generator
autumn
采用Spring、Spring Boot、Redis、MyBatis、Shiro、Druid框架开发,搭载mysql数据。 如果你厌烦了MyBatis中需要手动创建表的事情,这个项目非常适合你,自动为你生成表。 从此你不在需要导入sql文件了,项目初始化变得异常简单,结构清晰,易于开发,真正拿来可用。 全注解MyBatis开发,没有任何mapper文件,一切sql 映射都用代码实现,全程无xml配置,对xml编写mapper有恐惧症的人的福音。 提供双向生成功能: 实体类自动生成数据库表,全过程不需要任何SQL语句,所有表自动生成 通过表生成基础结构代码,生成代码中已包含CRUD功能,表级别的API接口全部都有 基本实例数据全自动通过代码初始化,无需干预 仅仅只需要修改数据库连接地址,…
Stars: ✭ 28 (+64.71%)
Mutual labels:  generator
spid-express
Express middleware implementing SPID & Entra con CIE (Carta d'Identità Elettronica)
Stars: ✭ 27 (+58.82%)
Mutual labels:  italy
justgo
Skeleton for jump-starting a Go-powered microservice project with Docker and Go best-practices + easy code hot-reloading (for dev environments)!
Stars: ✭ 29 (+70.59%)
Mutual labels:  generator
combustor
MVC code generator for the Codeigniter framework.
Stars: ✭ 31 (+82.35%)
Mutual labels:  generator
mosaic-node-generator
Generate mosaic images in Node.
Stars: ✭ 25 (+47.06%)
Mutual labels:  generator
unity-plumber
A component to procedurally generate pipe-like meshes in Unity
Stars: ✭ 55 (+223.53%)
Mutual labels:  generator
yii2-rest-doc
Yii2 REST doc generator
Stars: ✭ 35 (+105.88%)
Mutual labels:  generator
crafting
Website for generating Minecraft crafting recipe JSON files
Stars: ✭ 31 (+82.35%)
Mutual labels:  generator
nuzlocke-generator
📃 A nuzlocke template generator.
Stars: ✭ 21 (+23.53%)
Mutual labels:  generator
Comuni-Italiani-2018-Sql-Json-excel
DATABASE dei COMUNI ITALIANI 2018 PROVINCE, REGIONI, COMUNI CON CAP e COORDINATE GEOGRAFICHE
Stars: ✭ 87 (+411.76%)
Mutual labels:  italy
numara-calculator
Simple notepad calculator built on Electron, powered by Math.js
Stars: ✭ 16 (-5.88%)
Mutual labels:  calculator
simpleflakes
Fast and test-driven distributed 64-bit ID generation, using pure JavaScript, for Node.js.
Stars: ✭ 32 (+88.24%)
Mutual labels:  generator

Gem Version Build Status

Codice Fiscale (Italian Tax ID)

A Ruby gem that calculates the Codice Fiscale (Italian Tax ID).

The Codice Fiscale is an identifier unique to each person that is used when dealing with Italian government offices or for private concerns and is formulated using a combination of the person’s name, place and date of birth. Usually it is attributed by the Office of Income Revenue (Agenzia delle Entrate) through local tax offices.

The code is 16 characters long and includes both letters and numbers, for e.g: RSSMRA90A01H501W (taken from this sample card). Read more on wikipedia or here.

Installation

WARNING: The gem name on rubygems.org is "codice-fiscale" not "codice_fiscale"

Add this line to your application's Gemfile:

    source 'https://rubygems.org'
    gem 'codice-fiscale'

And then execute the bundle install command.

Usage

  require 'codice_fiscale'

  CodiceFiscale.calculate(
    :name          => 'Mario',
    :surname       => 'Rossi',
    :gender        => :male,
    :birthdate     => Date.new(1987, 1, 1),
    :province_code => 'MI',
    :city_name     => 'Milano'
  )
  # => RSSMRA87A01F205E

City codes (Codici Catastali)

As explained above, one of the information required to calculate the tax ID is the birthplace.
If a person was born outside Italy, only the italian name of the country is required.
For example, an italian citizen born in France:

  CodiceFiscale.calculate(
    :name         => 'Mario', 
    :surname      => 'Rossi', 
    :gender       => :male, 
    :birthdate    => Date.new(1987, 1, 1), 
    :country_name => 'Francia'
  )
  # => RSSMRA87A01Z110I

If a person was born in Italy you have to specify the code of the province and the name of the city. These informations are actually contained in a CSV document downloaded from istat.it, converted and shipped with this gem.

But what if you have your own table with all those codes?

In this case, you can add a custom block that fetches the codes from your database:

config/initializers/codice_fiscale_initializer.rb:

  CodiceFiscale.config.country_code do |country_name|
    # Place your code here, for e.g.:
    YourCountryActiveRecordModel.find_by_name(country_name).code
    # So that given for e.g. country_name="Denmark" the returned code must be "Z107"
    # Checkout the file ./lib/codice_fiscale/codes/country_codes.csv
  end

  CodiceFiscale.config.city_code do |city_name, province_code|
    # Place your code here, for e.g.:
    YourCityActiveRecordModel.find_by_province_and_city(province_code, city_name).code
    # So that given for e.g. city_name="Fiumicino", province_code="RM" the returned code must be "M297"
    # Checkout the file ./lib/codice_fiscale/codes/city_codes.csv
  end

Testing

$ bundle exec rspec

This gem is tested with all ruby versions starting from 1.9.3.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].