Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature Faker::CIF #929

Closed
Elolawyn opened this issue Jun 1, 2017 · 10 comments
Closed

New Feature Faker::CIF #929

Elolawyn opened this issue Jun 1, 2017 · 10 comments

Comments

@Elolawyn
Copy link

Elolawyn commented Jun 1, 2017

I'd like to be able to create valid spanish CIFs like in http://generadordni.es/. I think they are called VAT in other countries.

@PuZZleDucK
Copy link
Contributor

It looks like the possible sequences are ########A and A#######A.
I'm not sure what VAT or CIFs are tho... are they bank account numbers? company identifiers? other?

@lucasqueiroz
Copy link
Member

@PuZZleDucK I'm not sure if that's the only thing. I don't speak Spanish but since Portuguese is really close, I could understand what the website said but not what CIF is. I think it has a validation number somehow... I'll try to find more information

@PuZZleDucK
Copy link
Contributor

lol... I was thinking it could be more appropriate as a localization of "Account number" or something similar rather than a whole new thing.

I'm sure the other two IDs are DNI and NIE as referenced in #872

@Elolawyn
Copy link
Author

Elolawyn commented Feb 6, 2018

CIF is a sequence used to identify a company in our tax system. It seems NIF is like a CIF 2.0.

Wikipedia: https://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal

@PuZZleDucK
Copy link
Contributor

Ok, from trying to comprehend auto-translated info it seems the first letter is one of "ABCDEFGHJNPQRSUVW".

Then two digit combinations for region (a set of sequences listed in the reference from @Elolawyn above)

Then a five digit identifier (I'd propose totally random)

The final character is a checksum sorta thing.

  • sum the even digits
  • double the odd digits and add sum each digit for each number, sum the total
  • sum the first two sums and only take the first digit
  • subtract this digit from 10 and % 10
    -then conditionally map to a letter (J = 0, A = 1, B = 2, C = 3, D = 4, E = 5, F = 6, G = 7, H = 8, I = 9)

Anyone thinks this sounds right-enough to run with?

@PuZZleDucK
Copy link
Contributor

lol... gafaw... and facepalm :p

I was looking for a good place to put this when I stumbled upon spanish_organisation_number in the ``company.rb``` file... however it seems to have never made it to the docs :(

@PuZZleDucK
Copy link
Contributor

Faker::Company.spanish_organisation_number

This was referenced Feb 9, 2018
@stfcodes
Copy link

These "CIF"s are not specific to Spain only, and are more commonly known as VAT numbers (in the EU).

You can find more info here. No validation formula though.

@PuZZleDucK
Copy link
Contributor

It says the number generation is delegated to each nation... so I don't think we could generalize the Spanish formula to other countries... although many might be similar 🤞

VAT also seems to have a country specific prefix which this does not have... so a Spanish CIF would have a prefix when expressed as a VAT... so "1234567X" might be "SP1234567X" when written as a VAT (note, not sure if Spains prefix is SP or not, just a hypothetical value)

@vbrazo
Copy link
Member

vbrazo commented May 21, 2018

@PuZZleDucK PRs merged successfully. Thanks for contributing 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants