cadrumo.application.modelo._ledger_drift_gate module¶
Verify-time ledger-drift gate for BORRADOR calculation drafts.
Verify targets the work unit’s current calculation revision. The deductible-evidence gate beside it reads the LIVE transaction catalogue, while the casilla values under audit come from the STORED draft. Those are the same view only while nothing changes in between, and nothing required that.
The reachable sequence this closes: an operator meets the blocking deductible-evidence finding, reclassifies the row to drop the deduction rather than attaching an invoice, and re-runs verify without recalculating. No recalculate means the work unit still points at the same draft. The evidence gate reads the live ledger, sees a row that is no longer deductible, and raises nothing; the casilla values still assert the deduction. Granting there freezes an evidence bundle over an over-declaration.
The gate lives here rather than beside the finding collectors it runs with, because it is a distinct responsibility: those collectors project registry and profile state onto findings, while this one compares two views of the ledger across time. Keeping it separate also lets the comparison be exercised without standing up the whole verify path.
See also
_ledger_evidence_gate:The sibling filing-grade gate over the frozen evidence bundle.
evaluate_ledger_filing_staleness():The shared comparison, which also guards finalized revisions.
- LEDGER_DRIFT_LEGAL_REFS: tuple[str, ...]¶
Grounding for the drift refusal. A declaración must reflect the operator’s real accounting records (LIVA art. 164.1.4 the IVA declaration duty, RD 1619/2012 art. 2 the invoicing duty that fixes what those records say), so filing values the ledger no longer supports is not a filing the operator may complete.
- ledger_drift_findings(*, target, work_unit, transaction_repository, source_refs=(), blocking_finding_observer=None)[source]¶
Refuse a draft whose contributing ledger rows moved since it was calculated.
The comparison is the draft’s own ledger anchor against the live rows, through the same staleness evaluator that guards finalized revisions. The two views it holds apart are exactly the two arguments:
targetis the storedCalculationRevisionthe casilla values came from, andtransaction_repositoryis the liveTransactionCatalogueRepositoryProtocolthe evidence gate reads. The caller supplies the repository bound to the work unit’s bucket, so the live side is never silently absent. The anchor’s fingerprint covers tax facts only, so a reclassify moves it and an evidence attach does not — which is what lets this refuse the stale-draft path without refusing the attach-and-re-verify recovery the deductible-evidence promotion depends on.A ledger-derived draft with NO anchor is refused on the same terms rather than passed. It was calculated before the anchor existed, so whether its values still match the ledger is unknown, and an unknown is not a pass (
no-silent-under-declaration). Both branches resolve to the same operator move, which is why they carry the same instruction.This never recomputes. A verify that quietly recalculated would mint values the operator never saw and file them under a report they never read.
- Return type:
- Parameters:
target (CalculationRevision)
work_unit (WorkUnit)
transaction_repository (TransactionCatalogueRepositoryProtocol)
blocking_finding_observer (Callable[[ModeloVerificationFinding, bool, tuple[str, ...], tuple[str, ...]], None] | None)