"""Domain errors for the :mod:`aeat.domain.iva` subpackage.Every failure mode raised by the IVA substrate inherits from:class:`IvaError`, which in turn inherits from:class:`aeat.core.errors.AeatError`. Downstream callers catch the base classwhen they want to treat the substrate as an opaque unit, or the specificsubclass when they need to distinguish missing-rate from missing-category orcorpus load failures."""from__future__importannotationsfrom...core.errorsimportAeatError
[docs]classIvaError(AeatError):"""Base error for every :mod:`aeat.domain.iva` failure mode."""
[docs]classIvaRateNotFoundError(IvaError):"""Raised when :func:`aeat.domain.iva.lookup_rate` cannot resolve a rate. The lookup fails either because the requested member state is absent from :data:`aeat.domain.iva.IVA_RATE_TABLE`, because no rate of the requested :class:`aeat.domain.iva.IvaRateKind` is registered for that member state, or because every registered rate's effective window excludes the requested date. """
[docs]classIvaCategoryNotFoundError(IvaError):"""Raised when a lookup against a resolved IVA catalogue misses."""
[docs]classIvaCatalogueError(IvaError):"""Raised when a IVA catalogue cannot be loaded, resolved, or validated."""
[docs]classIvaRateOverlapError(IvaError):"""Raised when two :class:`aeat.domain.iva.IvaRateRecord` records share a window. The substrate enforces that for every ``(member_state, kind)`` partition of :data:`aeat.domain.iva.IVA_RATE_TABLE` no two records have overlapping ``effective_from`` / ``effective_until`` ranges. Adding a new record that violates this invariant raises this error at module import time so the regression surfaces in CI rather than silently affecting :func:`aeat.domain.iva.lookup_rate` results. """
[docs]classIvaClassificationError(IvaError):"""Raised when :func:`aeat.domain.iva.classify_iva` cannot return a deterministic match. The classifier exposes a closed first-match-wins table; the only structural failure is when the input criteria cannot be represented under the closed enum set, which is caught at construction time by pydantic. This error is reserved for future extensions such as ambiguous rule rankings. """
[docs]classIvaValidationError(IvaError,ValueError):"""Raised on invalid IVA field values. Inherits from ValueError for Pydantic."""
[docs]classProrrataError(IvaError):"""Base error for IVA prorrata calculation failures (LIVA arts. 101-103)."""
[docs]classProrrataInputError(ProrrataError,ValueError):"""Raised when prorrata inputs violate domain invariants. Inherits from ``ValueError`` so pydantic surfaces it as a ``ValidationError`` when raised from a model validator. """
[docs]classProrrataSectorError(ProrrataError):"""Raised when sectoral-separation inputs are inconsistent. Examples: a sector references an unknown id, two sectors share an activity code, or the sector list is empty when sectoral separation is required (LIVA art. 9.1.c). """