aeat.adapters.inbound.borrador._schema module

Strict pydantic v2 records for the Renta / Modelo 100 parser.

Defines the inbound data shapes that the borrador pipeline produces. These records are observed-data contracts; registry authority stays with callers that project a profile into BorradorExtractionProfile.

  • ArtefactKind — three Modelo 100 PDF flavours.

  • BorradorParseMode — observed rows versus caller-supplied registry-profile validation.

  • BorradorExtractionProfile — lightweight protocol projected by the caller from registry metadata when completeness checks are required.

  • InboundBorradorObservation — parsed observed record with printed casillas, source provenance and per-casilla advisory warnings.

class ArtefactKind(*values)[source]

Bases: StrEnum

The three Modelo 100 PDF artefact types the operator encounters.

Variables:
  • BORRADOR – Pre-filing draft from Portal Renta; carries casillas but no CSV.

  • PREDECLARACION – Simulación (Renta Web Open) watermarked VISTA PREVIA; carries no CSV.

  • DECLARACION – Post-filing copy with an AEAT CSV stamp.

BORRADOR
PREDECLARACION
DECLARACION
class BorradorParseMode(*values)[source]

Bases: StrEnum

Parser authority mode requested by the caller.

Variables:
  • OBSERVED – Return the casilla rows printed in the PDF without minimum coverage enforcement.

  • REGISTRY_PROFILE – Require a caller-supplied BorradorExtractionProfile, filter to its target casillas, and enforce its minimum coverage without consulting a registry snapshot inside the adapter.

OBSERVED
REGISTRY_PROFILE
class BorradorExtractionTarget(*args, **kwargs)[source]

Bases: Protocol

Per-target descriptor surface the parser reads from a profile.

This protocol is intentionally narrow so callers can project registry targets without making the inbound adapter depend on registry internals. Only the stable casilla identifier is needed by the observed-value filter.

property casilla_id: CasillaId
class BorradorExtractionProfile(*args, **kwargs)[source]

Bases: Protocol

Registry extraction-profile surface consumed by the parser.

The parser consumes this structural protocol only when BorradorParseMode.REGISTRY_PROFILE is requested. It is supplied by the caller; the inbound adapter does not look up RegistrySnapshot data itself.

property id: str
property target_casillas: tuple[BorradorExtractionTarget, ...]
property min_coverage: Decimal
class InboundBorradorObservation(**data)[source]

Bases: BaseModel

Observed Modelo 100 PDF data.

Strict, frozen pydantic record produced by adapters.inbound.borrador.parse_borrador().

Variables:
  • modelo – Always "100" for this record.

  • ejercicio – Four-digit tax year.

  • tax_id – NIF / NIE of the filer.

  • artefact_kind – Which of the three PDF types was detected.

  • values – Tuple of ExtractedCasilla records observed in the PDF.

  • registry_extraction_profile_id – Registry extraction profile applied to this parse, when the caller requested coverage validation.

  • extraction_coverage – Observed target-casilla coverage when a registry extraction profile was supplied.

  • source_pdf_path – Privacy-preserving .secure-source/<sha256>.pdf reference derived from the parsed PDF digest.

  • source_pdf_sha256 – Lowercase hex SHA-256 of source bytes.

  • parsed_at – UTC timestamp at parse completion.

  • csv – AEAT CSV if the artefact is a DECLARACION; None for borrador / predeclaración.

  • warnings – Per-casilla advisory messages emitted by the extractor (for example "casilla 0622: value 'unparseable' is not a number").

Parameters:
modelo: Literal[Modelo.M100]
ejercicio: str
tax_id: str
artefact_kind: ArtefactKind
values: tuple[ExtractedCasilla, ...]
registry_extraction_profile_id: str | None
extraction_coverage: Decimal | None
source_pdf_path: Path
source_pdf_sha256: str
parsed_at: datetime
csv: str | None
warnings: tuple[str, ...]