python-stdnum
python-stdnum copied to clipboard
Add Spanish CAE Number
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


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 Ok, I will chek it and make the appropriate changes if needed Thanks
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.
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?
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.
@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.
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 Thanks a lot