cadrumo.application.modelo._ledger_evidence_gate module¶
Filing-grade ledger evidence gates for modelo lifecycle finish lines.
These helpers inspect the CalculationRevision evidence bundle before
verification, export, or local filing lets deductible input IVA proceed.
- ledger_evidence_row_missing_deductible_iva_evidence(row)[source]¶
Return whether an evidence row claims deductible IVA without linked proof.
lifecycle_state,business_classification,directionandiva_categoryare persisted onLedgerEvidenceRowas bare strings so a frozen bundle round-trips through the strict persistence boundary. Parsing them back can fail, and this gate refuses rather than absolves when it does: a row it cannot read is a row whose contribution to a filing it cannot vouch for, and answering “no gap” there would let a Modelo 303 input-IVA deduction reach a filing with no documento justificativo behind it (LIVA art. 97 enumerates what may support one; LGT art. 105.1 puts the burden on the taxpayer).The order of the checks is load-bearing, because failing closed on a field that could not decide anything would refuse rows that raise no question. Each required field is consulted only while the row is still a candidate: a parseably-inactive row is excluded before its direction is read, and a row already carrying evidence is cleared before its cuota is. So the unreadable-value refusals fire only where the unreadable value would actually have decided the answer.
An absent
iva_amounton a row that reaches the last line is a gap, not a zero. By then the row is active, business-bearing, on the deducible side and carrying no evidence of any kind; a deduction-side claim whose cuota was never captured is exactly the missing-input stateno-silent-under-declarationkeeps distinct from a proven zero.iva_categoryalone is still read through_enum_or_none(), because its absence is a real state — an unclassified domestic row — and both absence and drift route to the same direction-derived flow rather than to an exemption, so neither can slip past on that axis.Tightening this was gated on a recovery path existing, not on the argument being sound: the note above
_row_has_linked_evidence()explains that a refusal here used to strand a finalized revision forever. It no longer does.recapture_ledger_filing_evidencere-bundles a sealed revision’s evidence over unchanged facts without moving its content address, so a row refused here can be answered by attaching the document and recapturing.- Return type:
- Parameters:
row (LedgerEvidenceRow)
- deductible_iva_evidence_gap_transaction_ids(revision)[source]¶
Return ledger transaction ids whose bundled evidence cannot support deduction.
- Parameters:
revision (
CalculationRevision) –CalculationRevisioncarrying the ledger filing evidence rows to inspect.- Return type:
- raise_if_deductible_iva_evidence_missing(revision, *, error_type)[source]¶
Raise a typed file refusal when a finalized revision has unsupported input IVA.
- Parameters:
revision (
CalculationRevision) –CalculationRevisionwhose bundled ledger evidence is checked before the lifecycle finish line.error_type (
type[ModeloError]) – Modelo error class raised when deductible IVA lacks evidence.
- Return type: