aeat.application.ledger._evidence_advisory module

Printed-vs-derived IVA advisory cross-check.

A non-blocking diagnostic: when an invoice’s on-host-extracted text appears to print an IVA figure that disagrees with the registry-DERIVED IVA, surface an advisory so the operator verifies before filing. The public printed_iva_advisory() helper feeds the evidence_advisory field on aeat.application.ledger._llm_classification.LLMSaturatedSuggestion after the saturation path has resolved evidence through aeat.domain.transactions.PromptSpec.

The printed figure is parsed deterministically on-host from the evidence text (never emitted by the model) and is used ONLY for this advisory – it is never persisted and never overrides the derived value (llm-selects-system-derives-tax-numbers / no-silent-under-declaration). Parsing is best-effort; a miss simply yields no advisory.

printed_iva_advisory(evidence_text, derived_iva_amount, *, tolerance=Decimal('0.01'))[source]

Return an advisory string when the printed IVA disagrees with the derived IVA.

The comparison is a best-effort cross-check between on-host-extracted evidence text and the registry-derived IVA amount carried by aeat.application.ledger._llm_classification.LLMSaturatedSuggestion; it never supplies a tax value for persistence.

Parameters:
  • evidence_text (str | None) – On-host-extracted text of the attached evidence, or None.

  • derived_iva_amount (Decimal | None) – The registry-derived Decimal IVA amount, or None.

  • tolerance (Decimal) – Absolute cent Decimal tolerance for the comparison.

Return type:

str | None

Returns:

A non-blocking advisory message when a printed IVA figure is found and differs from derived_iva_amount beyond tolerance; otherwise None (no evidence, no derived value, no parseable printed figure, or a match).