aeat.adapters.inbound.declaracion._errors module

Exception hierarchy for the declaración PDF parser.

Defines the parse-error tree raised by adapters.inbound.declaracion. All exceptions descend from PdfModeloImportError so callers can catch the generic PDF-import boundary without needing declaración specifics.

Coverage failures carry structured missing / malformed / ambiguous / coverage attributes mirroring the registry extraction profile contract; callers should inspect those fields rather than parsing localized messages.

exception DeclaracionParseError(message=None, *, context=None, suggestion=None, translated_message=None, missing=(), malformed=(), ambiguous=(), coverage=None)[source]

Bases: PdfExtractionCoverageMixin, PdfModeloImportError

Raised when a PDF cannot be parsed into a declaración filing.

Base class for all parse-time errors emitted by adapters.inbound.declaracion.parse_declaracion(). TemplateNotDetectedError signals a recoverable template detection failure; the bare class is raised for low-level failures (PDF unreadable, header field missing, missing registry coverage, etc.).

The structured missing / malformed / ambiguous / coverage extraction-coverage attributes (casilla IDs here, mirroring JustificanteParseError’s field names) come from the shared PdfExtractionCoverageMixin so callers can assert on them without parsing the message string.

Parameters:
  • message (str | None)

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

  • suggestion (str | None)

  • translated_message (str | None)

  • missing (tuple[str, ...])

  • malformed (tuple[str, ...])

  • ambiguous (tuple[str, ...])

  • coverage (Decimal | None)

Return type:

None

code: ClassVar[ErrorCode]
exception TemplateNotDetectedError(message=None, *, context=None, suggestion=None, translated_message=None, missing=(), malformed=(), ambiguous=(), coverage=None)[source]

Bases: DeclaracionParseError

Raised when the PDF’s template revision cannot be auto-detected.

Emitted by detect_template_revision() when neither the header nor the footer of the PDF carries enough signal to pin a (modelo, año, revision) triple. Callers may recover by passing explicit modelo / año overrides to parse_declaracion().

Parameters:
  • message (str | None)

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

  • suggestion (str | None)

  • translated_message (str | None)

  • missing (tuple[str, ...])

  • malformed (tuple[str, ...])

  • ambiguous (tuple[str, ...])

  • coverage (Decimal | None)

Return type:

None

code: ClassVar[ErrorCode]