aeat.domain.justificante._errors module

Error hierarchy for the justificante parser.

Defines the typed exceptions raised by domain.justificante when a PDF filing receipt cannot be parsed, when no Código Seguro de Verificación is present, or when the live AEAT verification round-trip fails. Every class derives from PdfModeloImportError so PDF filing import callers can catch the whole domain at once.

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

Bases: AeatError

Domain-level root for PDF filing import failures.

Parameters:
  • message (str | None)

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

  • suggestion (str | None)

  • translated_message (str | None)

Return type:

None

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

Bases: object

Shared structured-attribute __init__ for PDF extraction coverage failures.

Both the justificante and declaración PDF parsers raise a coverage error that carries the same four structured attributes describing which target fields (field names for justificante, casilla IDs for declaración) could not be extracted cleanly. Mixing this in once keeps the attribute shape and constructor signature identical across both parser error hierarchies instead of each declaring its own copy.

Variables:
  • missing – Tuple of target identifiers that produced no match in the PDF text.

  • malformed – Tuple of target identifiers whose captured value could not be coerced to the target type (e.g. an invalid decimal literal).

  • ambiguous – Tuple of target identifiers that matched more than one region.

  • coverage – Fraction of required targets successfully extracted (Decimal). None when the error is not a coverage failure.

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)

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

Bases: PdfModeloImportError

Base class for every justificante-related failure.

Parameters:
  • message (str | None)

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

  • suggestion (str | None)

  • translated_message (str | None)

Return type:

None

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

Bases: PdfExtractionCoverageMixin, JustificanteError

Raised when a PDF cannot be parsed into a Justificante.

Mirrors adapters.inbound.declaracion.DeclaracionParseError’s structured-attribute shape (via the shared PdfExtractionCoverageMixin) so callers can assert on typed attributes rather than 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 JustificanteCsvNotFoundError(message=None, *, context=None, suggestion=None, translated_message=None, missing=(), malformed=(), ambiguous=(), coverage=None)[source]

Bases: JustificanteParseError

Raised when a PDF does not contain a Código Seguro de Verificación.

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 JustificanteVerificationError(message=None, *, context=None, suggestion=None, translated_message=None)[source]

Bases: JustificanteError

Raised when the live CSV verification round-trip fails.

Parameters:
  • message (str | None)

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

  • suggestion (str | None)

  • translated_message (str | None)

Return type:

None

code: ClassVar[ErrorCode]