FakerPHP / Faker

Faker is a PHP library that generates fake data for you
https://fakerphp.github.io
Other
3.49k stars 331 forks source link

Person -> taxId() in it_IT not working #643

Closed michael-kreatif closed 1 year ago

michael-kreatif commented 1 year ago

Hi guys,

the taxId() (Codice Fiscale) in Italian is not valid. The problem occurs, because the last character has to be computed and therefore is not a randomised character.

https://en.wikipedia.org/wiki/Italian_fiscal_code ->Check character (one letter)

Example ( generated over faker api):

UVPTVR50J53C641F 
odd chars = UPV5J361 = 16+10+10+13+21+7+15+0 = 92
even chars = VTR05C4  = 21+19+17+0+5+2+4 = 68
160 % 26 = 4
last character should be E
DvDty commented 1 year ago

I started working on a fix. Looks like the last digit isn't the only issue - we're generating invalid months (like J in your example). The value of the month should be coming from this mapping:

Month Code
January A
February B
March C
April D
May E
June H
July L
August M
September P
October R
November S
December T

Another thing:

odd chars = UPV5J361 = 16+10+10+13+21+7+15+0 = 92

Why is P = 10 here? Mistake or some special rule?

michael-kreatif commented 1 year ago

I started working on a fix. Looks like the last digit isn't the only issue - we're generating invalid months (like J in your example). The value of the month should be coming from this mapping:

Month Code January A February B March C April D May E June H July L August M September P October R November S December T Another thing:

odd chars = UPV5J361 = 16+10+10+13+21+7+15+0 = 92

Why is P = 10 here? Mistake or some special rule?

Sounds great. You're right, months are also invalid, thx for checking carefully. :) Sorry, P = 10 is a mistake, should be 3.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.