fabiocaccamo / python-codicefiscale

:it: :credit_card: italian fiscal codes encoding, decoding and validation - codifica, decodifica e validazione del Codice Fiscale italiano.
MIT License
74 stars 24 forks source link

Unable to encode and decode fiscal codes when year of birth (excluding century) < 10 (eg. 2004) #79

Closed deltaredentertainment closed 1 year ago

deltaredentertainment commented 1 year ago

Python version 3.9

Current behavior (bug description) When calling both the .encode and .decode function with any birthplace it raises a ValueError: Traceback (most recent call last): File "/Users/davideramondetti/..../handler.py", line 19, in cod1 = codicefiscale.decode( File "/Users/davideramondetti/.../venv/lib/python3.9/site-packages/codicefiscale/codicefiscale.py", line 485, in decode raise ValueError(f"[codicefiscale] wrong birthplace code: {birthplace_code!r}") ValueError: [codicefiscale] wrong birthplace code: 'L219'

Expected behavior It is expected for the .decode to return the extracted data, and for the Encode to output the fiscal code.

fabiocaccamo commented 1 year ago

@deltaredentertainment Could you tell me the input arguments you are using for both, encoding and decoding?

deltaredentertainment commented 1 year ago

certamente, here is a copy of the code used for trial:

` from codicefiscale import codicefiscale

cod = codicefiscale.encode( lastname="Rossi", firstname="Mario", gender="M", birthdate="29/11/2004", birthplace="Torino", )

cod1 = codicefiscale.decode( "RSSMRA00S29L219C" )

print(cod1) print(cod) and here is the error: site-packages/codicefiscale/codicefiscale.py", line 408, in encode decode(code) line 485, in decode raise ValueError(f"[codicefiscale] wrong birthplace code: {birthplace_code!r}") ValueError: [codicefiscale] wrong birthplace code: 'L219'`

Thanks!

deltaredentertainment commented 1 year ago

I have forgot to mention that it gives the error for both encode and decode

fabiocaccamo commented 1 year ago

Thank you! That birthplace code is correct and I'm also sure that it has been used in the test suite.

I will try to replicate the error.

deltaredentertainment commented 1 year ago

i tried even with others, but it keeps resulting in the same error. Let me know, thanks.

deltaredentertainment commented 1 year ago

Dear Fabio, I have downloaded the previous version (0.6.1) and now is working properly. Regards, DR

fabiocaccamo commented 1 year ago

@deltaredentertainment Looking at the cause of the problem I don't understand how the previous version can work well for you.

Anyway... this is fixed now, you can upgrade to 0.7.1 version.

deltaredentertainment commented 1 year ago

thanks, it works.