python-stdnum icon indicating copy to clipboard operation
python-stdnum copied to clipboard

Add Spanish CAE Number

Open quiqueporta opened this issue 1 year ago • 2 comments

The CAE (Código de Actividad y Establecimiento) number is a 13-digit number and that allows you to identify an activity and the establishment in which it is carried out.

This is the official BOE (Boletín Oficial del Estado) about the CAE number: https://www.boe.es/boe/dias/2006/12/28/pdfs/A46098-46100.pdf

This is the offical web site about the CAE number: https://sede.agenciatributaria.gob.es/Sede/impuestos-especiales-medioambientales/censo-impuestos-especiales-medioambientales/registro-impuestos-especiales-fabricacion.html?faqId=3cc75c714b11c710VgnVCM100000dc381e0aRCRD

quiqueporta avatar Jul 04 '24 11:07 quiqueporta

Antonio-Vela avatar Jul 16 '24 11:07 Antonio-Vela

Antonio-Vela avatar Aug 08 '24 07:08 Antonio-Vela

Hi @quiqueporta,

Thanks for providing this and sorry it took a while for me to get around to this. The link in the code appear to be broken:

https://www2.agenciatributaria.gob.es/wlpl/inwinvoc/es.aeat.dit.adu.adce.cae.cw.AccW

I get "Error en la recuperación de la acción seleccionada. (Se esperaba fAccion)".

This page suggests additional checks that can be performed:

  • that all digits after "ES" are digits (e.g. other modules use the isdigits() function to check that)
  • the "ES" part is followed by "000"
  • the last digit appears to be a check digit

Do you have any idea of what the check digit function would be? Searching for hints on the check digit algorithm is generally easier in the applicable language (and I read Spanish through Google Translate). Without an actual reference to what the algorithm is it is sometimes possible to reverse-engineer the check digit algorithm from a large number of valid numbers (also see https://github.com/arthurdejong/python-stdnum/blob/master/CONTRIBUTING.md)

Thanks,

arthurdejong avatar Sep 21 '24 17:09 arthurdejong

@arthurdejong Ok, I will chek it and make the appropriate changes if needed Thanks

quiqueporta avatar Sep 24 '24 14:09 quiqueporta

Regardless of the check digit, you cannot check it through the official web page because it only checks if the CAE is registered in its database, not the format itself.

quiqueporta avatar Sep 30 '24 07:09 quiqueporta

Do you have a link to the site where I can check a hand full of numbers or do you some other way to get a large-ish set of numbers to try to reverse-engineer the check digit algorithm?

arthurdejong avatar Oct 11 '24 14:10 arthurdejong

No :disappointed: , the only official webpage to check the codes is this: https://www2.agenciatributaria.gob.es/L/inwinvoc/es.aeat.dit.adu.adce.cae.cw.AccW?fAccion=consulta

However, this page doesn't tell you if the code is correct; it only checks whether the code is registered in the official database.

quiqueporta avatar Oct 14 '24 06:10 quiqueporta

@arthurdejong seems that the Python 2.7 test suite failed due to GitHub Actions timeout, not about code.

The job running on runner GitHub Actions 1 has exceeded the maximum execution time of 360 minutes.

quiqueporta avatar Jan 22 '25 07:01 quiqueporta

Hi @quiqueporta,

I've merged it as 8519221. I've cleaned up the tests a bit, made the documentation similar to that of the other modules and other than that only made a few formatting changes.

arthurdejong avatar Feb 15 '25 17:02 arthurdejong

@arthurdejong Thanks a lot

quiqueporta avatar Feb 20 '25 09:02 quiqueporta