aeat.application.aggregation._evidence_advisory module

Evidence-presence diagnostics for IVA-bearing ledger rows.

The diagnostics pair a transaction’s IVA settlement side with its evidence presence: a positive deductible input-IVA row must carry supplier evidence, while a positive output-IVA row without a linked document remains visible to the operator. This is the ledger-evidence counterpart of the calculate-path unconsumed-declarable-IVA advisory and follows the no-silent-under-declaration discipline: never let a missing-evidence row pass in silence, and let the filing-grade verification layer decide which legally grounded side blocks.

The trigger set is deliberately narrow. An advisory fires only on an ACTIVE business/mixed row with a strictly-positive IVA quota and no linked evidence. Explicit exempt / zero-rated / not-subject IVA categories and non-declarable sentinels are excluded because they do not route an M303 quota. Rows with no explicit iva_category but with a positive iva_amount remain in scope: the IVA aggregation layer derives their domestic category from the stored rate and bank direction before feeding M303.

MISSING_TRANSACTION_EVIDENCE_SOURCE_KIND

Legacy diagnostic source_kind retained for callers that only need the generic reason. New diagnostics use the settlement-side-specific source kinds below.

MISSING_DEDUCTIBLE_VAT_EVIDENCE_SOURCE_KIND

Diagnostic source_kind for missing supplier evidence on positive deductible input IVA. Verification treats this as filing-grade blocking.

MISSING_OUTPUT_VAT_EVIDENCE_SOURCE_KIND

Diagnostic source_kind for missing linked evidence on positive output IVA. The current transaction model cannot yet distinguish all valid issued-invoice evidence paths, so verification keeps this visible but non-blocking.

transaction_missing_deductible_vat_evidence(transaction)[source]

Return whether transaction claims deductible IVA without evidence.

Return type:

bool

Parameters:

transaction (Transaction)

transaction_missing_output_vat_evidence(transaction)[source]

Return whether transaction declares output IVA without linked evidence.

Return type:

bool

Parameters:

transaction (Transaction)

missing_evidence_advisory_observations(transactions)[source]

Return missing-evidence diagnostics for positive IVA rows.

A CalculationSourceDiagnostic (reason missing_transaction_evidence) is emitted for each ACTIVE business/mixed row with a strictly-positive IVA quota and no linked evidence that is either:

  • a deductible input-IVA row (a supplier purchase invoice/evidence is required for filing-grade verification), or

  • an output-IVA row whose IVA category is legally expected to bear a devengada cuota — i.e. not in domain.iva.CUOTA_LESS_M303_IVA_CATEGORIES nor a non-declarable sentinel (the issued-invoice evidence gap remains visible).

Rows that legitimately bear no evidence requirement — non-business / personal, exempt / zero-rated / not-subject / sentinel IVA categories, no positive IVA quota, and non-ACTIVE lifecycle states — are excluded and never fire.

Parameters:

transactions (Iterable[Transaction]) – The revision’s source transactions to inspect.

Return type:

tuple[CalculationSourceDiagnostic, ...]

Returns:

A tuple of non-blocking missing-evidence diagnostics, in input order.