# stdnum.es.cae

CAE (Código de Actividad y Establecimiento, Spanish activity establishment code).

The Código de Actividad y Establecimiento (CAE) is assigned by the Spanish Tax Agency companies or establishments that carry out activities related to products subject to excise duty. It identifies an activity and the establishment in which it is carried out.

The number consists of 13 characters where the sixth and seventh characters identify the managing office in which the territorial registration is carried out and the eighth and ninth characters identify the activity that takes place.

More information:

- https://www.boe.es/boe/dias/2006/12/28/pdfs/A46098-46100.pdf

- https://www2.agenciatributaria.gob.es/L/inwinvoc/es.aeat.dit.adu.adce.cae.cw.AccW?fAccion=consulta

    >>> validate('ES00008V1488Q')
    'ES00008V1488Q'
    >>> validate('00008V1488')  # invalid check length
    Traceback (most recent call last):
        ...
    InvalidLength: ...
    >>> is_valid('ES00008V1488Q')
    True
    >>> is_valid('00008V1488')
    False
    >>> compact('ES00008V1488Q')
    'ES00008V1488Q'

stdnum.es.cae.compact(number: str) → str

  Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

stdnum.es.cae.is_valid(number: str) → bool

  Check if the number provided is a valid CAE number. This checks the length and formatting.

stdnum.es.cae.validate(number: str) → str

  Check if the number provided is a valid CAE number. This checks the length and formatting.