"""Strict pydantic v2 records for the unified review queue.Each per-kind model wraps the source record verbatim alongside theunified queue fields (``item_id``, ``modelo``, ``severity``,``summary``, ``drill_command``, ``since``).The :data:`ReviewItem` discriminated union uses a singlediscriminator field (``kind``) to select the concrete model, andpydantic enforces that discriminator at validation time.Concrete models:* :class:`TransactionReviewItem` — pending bank transactions.* :class:`InvoiceReviewItem` — unmatched, disputed, or payment-pending invoices.* :class:`FindingReviewItem` — pending findings on filing drafts.``InvoiceReviewRecord`` and ``LedgerReviewRecord`` are re-exported here from:mod:`aeat.application._workflow_review_models`, which owns them jointly with:class:`~aeat.application.workflow.WorkflowEvent` because:class:`~aeat.application.workflow.WorkflowState` embeds both review recordsas field types — a genuine mutual runtime dependency between``application.review`` and ``application.workflow`` that the shared leafmodule resolves."""from__future__importannotationsfromdatetimeimportdatetimefromtypingimportAnnotated,LiteralfrompydanticimportBaseModel,Field,field_validatorfrom...coreimportSTRICT_FROZEN_CONFIGas_STRICT_FROZENfrom...core.i18nimportTranslatableastrfrom...core.timeimportvalidate_utc_awarefrom...domain.invoicesimportInvoicefrom...domain.transactionsimportTransactionfrom.._workflow_review_modelsimportInvoiceReviewRecord,LedgerReviewRecordfrom..filingimportModeloValidationFindingfrom._enumsimportReviewItemKind,ReviewSeverityclass_ReviewItemBase(BaseModel):"""Shared pydantic config and unified fields for every review item. Attributes: item_id: Stable per-source identifier of the underlying record. modelo: Modelo code the item belongs to, or ``None`` when the source is not modelo-scoped (transactions, invoices). severity: One of :class:`ReviewSeverity`. summary: Multilingual one-line description. drill_command: Suggested ``aeat`` CLI command the operator can run to inspect or resolve the item. since: Timezone-aware UTC timestamp marking when the item became review-pending. """model_config=_STRICT_FROZENitem_id:str=Field(min_length=1)modelo:str|Noneseverity:ReviewSeveritysummary:trdrill_command:str=Field(min_length=1)since:datetime@field_validator("since")@classmethoddef_require_aware(cls,value:datetime)->datetime:"""Reject naive timestamps so cross-source sorting is deterministic."""returnvalidate_utc_aware(value)
[docs]classTransactionReviewItem(_ReviewItemBase):"""One pending bank transaction wrapped for the review queue. The pending states surfaced here are ``NOT_YET_PROCESSED``, ``PROCESSED_UNCLASSIFIED``, and ``FAILED_VALIDATION``. Severity is derived per state by the transaction-source adapter. Attributes: kind: Literal discriminator pinned to :attr:`ReviewItemKind.TRANSACTION`. source: The verbatim :class:`aeat.domain.transactions.Transaction`. """kind:Literal[ReviewItemKind.TRANSACTION]=ReviewItemKind.TRANSACTIONsource:Transaction
[docs]classInvoiceReviewItem(_ReviewItemBase):"""One pending invoice (unmatched, disputed, or payment-pending). Attributes: kind: Literal discriminator pinned to :attr:`ReviewItemKind.INVOICE`. source: The verbatim :class:`aeat.domain.invoices.Invoice`. """kind:Literal[ReviewItemKind.INVOICE]=ReviewItemKind.INVOICEsource:Invoice
[docs]classFindingReviewItem(_ReviewItemBase):"""One pending finding extracted from a filing draft. ``source`` is ``None`` for the placeholder row emitted when a draft has no findings but is in a DRAFT or VALIDATED status. Otherwise it carries the verbatim :class:`aeat.application.filing.ModeloValidationFinding`. Attributes: kind: Literal discriminator pinned to :attr:`ReviewItemKind.FINDING`. source: The underlying finding, or ``None`` for a status placeholder row. draft_id: Identifier of the originating filing draft. draft_path: On-disk path of the originating filing draft. """kind:Literal[ReviewItemKind.FINDING]=ReviewItemKind.FINDINGsource:ModeloValidationFinding|Nonedraft_id:str=Field(min_length=1)draft_path:str=Field(min_length=1)
ReviewItem=Annotated[TransactionReviewItem|InvoiceReviewItem|FindingReviewItem,Field(discriminator="kind"),]"""Discriminated union of every concrete review-queue item.Pydantic dispatches to the correct concrete model using the ``kind``field as the discriminator. Validate via``TypeAdapter(ReviewItem).validate_python(...)`` or``.validate_json(...)``."""__all__=["FindingReviewItem","InvoiceReviewItem","InvoiceReviewRecord","LedgerReviewRecord","ReviewItem","TransactionReviewItem",]"""``InvoiceReviewRecord`` and ``LedgerReviewRecord`` are defined in and ownedby :mod:`aeat.application._workflow_review_models` (see that module'sdocstring for the mutual-runtime-dependency rationale); this modulere-exports them so ``application.review`` consumers keep importing them fromhere."""