cadrumo.domain.censo.certificado module

Typed record for the Certificado de Situación Censal (procedure G313).

The certificate is the operator-downloadable censal artefact the setup flow’s cotejo phase reconciles against. Its target shape is the SIX officially certified fields (AEAT “¿Qué certifica?”): domicilio fiscal, condición de residencia, NIF de los representantes, situación tributaria, actividades y locales, and obligaciones periódicas. The shape is primary-source grounded; the PDF layout extraction is deliberately unpinned until a real issued-certificate specimen exists, so the inbound adapter refuses loudly rather than guessing a layout.

censo_facts_from_certificado projects the certificate onto candidate UserProfileFact rows for the cotejo’s compare-select pages. Only axes with an unambiguous profile counterpart produce a candidate fact; the rest are display-only certificate evidence:

  • condicion_residencia — free-form certificate prose; mapping it onto the typed fiscal-residency enum needs the specimen’s exact vocabulary.

  • representantes_nif — the certificate certifies legal representatives, a DIFFERENT axis from the profile’s IRNR representante_fiscal_nif; auto-mapping would conflate the two.

  • situacion_tributaria / obligaciones_periodicas — obligation surface, an input to the derived deadline schedule, not a static profile fact.

Every candidate fact carries the non-official artefact provenance token — never an AEAT-verified stamp, so the calendar’s censo.enrolment_unverified posture is unaffected.

exception CertificadoCensalError(message=None, *, context=None, translated_message=None)[source]

Bases: CadrumoError

Base for every Certificado de Situación Censal failure.

Parameters:
  • message (str | None)

  • context (Mapping[str, object] | None)

  • translated_message (str | None)

Return type:

None

code
exception CertificadoCensalParseError(message=None, *, context=None, translated_message=None)[source]

Bases: CertificadoCensalError

Raised when bytes cannot be parsed into a CertificadoSituacionCensal.

Parameters:
  • message (str | None)

  • context (Mapping[str, object] | None)

  • translated_message (str | None)

Return type:

None

code
class ActividadLocalCertificada(**data)[source]

Bases: BaseModel

One certified actividad/local row on the certificate.

Parameters:

data (Any)

descripcion: str
epigrafe_iae: str
local: str
class CertificadoSituacionCensal(**data)[source]

Bases: BaseModel

The six axes AEAT states a G313 censal certificate certifies.

This is the model’s scope, not an inventory of the document. AEAT’s “¿Qué certifica?” enumerates what the certificate ATTESTS; whether the issued artefact also carries an issue date, a CSV or header furniture is unestablished, because no issued-certificate specimen exists in this tree. Read the absence of a temporal field as unmeasured, never as evidence the document has none – and in particular do not derive an obligation start year from that absence.

Parameters:

data (Any)

domicilio_fiscal: str
condicion_residencia: str
representantes_nif: tuple[str, ...]
situacion_tributaria: tuple[str, ...]
actividades: tuple[ActividadLocalCertificada, ...]
obligaciones_periodicas: tuple[str, ...]
censo_facts_from_certificado(certificado)[source]

Project the certificate onto candidate profile facts for the cotejo.

Returns UserProfileFact rows stamped with the artefact provenance token. Axes without an unambiguous profile counterpart are deliberately absent (display-only evidence on the cotejo page); see the module docstring for the per-axis rationale.

Every certified actividad is projected, not only the first. The activities section is schema-declared repeatable, and profile_section_rows() already treats a repeatable fact written WITHOUT an index as the implicit first row – the shape every other single-activity producer in this codebase writes – so the primary activity keeps that unindexed address for compatibility, and every activity after it is projected at its own numeric index (activities.1.description, activities.2.description, …), which is the addressing scheme the manager and status surfaces already read repeatable rows through. A taxpayer with a second local or a second IAE epígrafe on the certificate used to lose it here silently: actividades[0] with no loop, no warning, and a cotejo that still reported success.

Return type:

tuple[UserProfileFact, ...]

Parameters:

certificado (CertificadoSituacionCensal)