ronanguilloux / IsoCodes

PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Manufacturing Industry, Phone numbers & Zipcodes for many countries
GNU General Public License v3.0
792 stars 77 forks source link

Nif validation only for Spain? #10

Closed soullivaneuh closed 8 years ago

soullivaneuh commented 9 years ago

I see on your README file that your NIF validator if for Spain codes (Número de Identificación Fiscal) but, stop me if I'm wrong, NIF codes are Europeans.

See here: http://ec.europa.eu/taxation_customs/taxation/tax_cooperation/mutual_assistance/tin/index_fr.htm

Are we speaking about the same NIF?

Is your NIF validator compliant with EU conventions?

Regards

TCB13 commented 9 years ago

@Soullivaneuh yes they are European, however they differ from country to country. There's a base format like a max lengths and accepted characters but the number itself can be different in each country.

For example, Portuguese and Spanish VAT numbers have different lengths.

soullivaneuh commented 9 years ago

@TCB13 Sorry not an expert about this.

To be sure: VAT = NIF? On all country?

So actually, this NIF validator works only for spanish VAT/NIF isn't it?

Could be awesome to manager another country like you did for zipcodes.

TCB13 commented 9 years ago

@Soullivaneuh Yes VAT = NIF. NIF it's kinda of a translation for VAT in Spanish and Portuguese... I guess the person who implemented the code didn't notice there was a VAT file already...

The file Vat.php has validation rules for multiple countries. Including Spain. I'm not sure if the implementation is correct because I'm not into the Spanish tax code.

soullivaneuh commented 9 years ago

Indeed! Didn't notice the Vat.php file.

So I think Nif.php should be removed, isn't it?

My proposition:

Maybe this need a new major version.

Are you agree with this?

Could make a PR of that if you want.

cc @ronanguilloux

TCB13 commented 9 years ago

I think it needs further analysis from someone Spanish.

They are the only one who can determine if the Nif.php should be removed and if there's any need to update the implementation on Vat.php.

I can try to review the two files and look for differences by I'm not sure If I'm the right person.

soullivaneuh commented 9 years ago

@TCB13 Nif already have unit test: https://github.com/ronanguilloux/IsoCodes/blob/master/tests/IsoCodes/Tests/NifTest.php

This is not enough?

soullivaneuh commented 9 years ago

According to Wikipedia:

Spain Número de Identificación Fiscal (for freelancers) or Código de Identificación Fiscal (for companies) NIF / CIF ES 'ES'+9 digits, the first or the last value can also be a character – e.g. ESX9999999X

So Spain Nif and Cif seems to be the same. So Nif and Cif classes should be removed.

Btw, Spain VAT is already managed here: https://github.com/ronanguilloux/IsoCodes/blob/master/src/IsoCodes/Vat.php#L34-L35

ronanguilloux commented 9 years ago

AFAIK, NIF are not VAT:

"¿Es lo mismo NIF que NIF-IVA? No. El NIF lo necesitan las personas físicas o jurídicas para cualquier relación de naturaleza o con trascendencia tributaria, mientras que el NIF-IVA es necesario para realizar determinadas operaciones intracomunitarias." (source)

In fact, NIF unit tests would probably not match the VAT algorithm.

soullivaneuh commented 9 years ago

What is NIF-IVA?

Can we have an English source please?

So is NIF only for Spain?

NIF unit tests would probably not match the VAT algorithm.

I'm curious. Have you check it?

ronanguilloux commented 9 years ago

What is NIF-IVA? Can we have an English source please?

http://www.agenciatributaria.es/AEAT.internet/en_gb/Inicio_en_GB/_Segmentos_/Empresas_y_profesionales/Empresarios_individuales_y_profesionales/IVA/El_NIF_en_el_IVA.shtml

So is NIF only for Spain?

I suppose, as it stands for Número de Identificación Fiscal. Please, make your own researches if you want to know more.

I'm curious. Have you check it?

Yes.

soullivaneuh commented 9 years ago

I suppose, as it stands for Número de Identificación Fiscal. Please, make your own researches if you want to know more.

I made it and this is why I'm confused.

NIF could also be Numéros d'identification fiscale in France and is use in all European coutries. See FR reference: http://ec.europa.eu/taxation_customs/taxation/tax_cooperation/mutual_assistance/tin/index_fr.htm

So, NIF is used by all European countries and some of them named it VAT.

So I really don't understand why NIF for Spain should be different from another countries.

Maybe a name mistake/confusion?

happyDemon commented 9 years ago

@ronanguilloux is there any chance you'll be implementing the Portuguese NIF at any point?

ronanguilloux commented 9 years ago

Hi @happyDemon,

Short answer: Portuguese NIF validation rule = Portuguese VAT rule, so you may simply use the exising VAT validator for Portugal. Check UE VAT/NIF rules specs links below.

Long answer & consequences:

AFAIK,

So I re-open this issue:

TCB13 commented 9 years ago

@ronanguilloux you said it all.

Don't rename NIF to TIN because nobody will know what that actually means. At least on the Portuguese case you easy drop the NIF validator because it does match the VAT one completely. Same rules, same number.