cadrumo.application.modelo.filing_actions module¶
Filing-record actions for modelo calculation revisions.
file_modelo_revision() promotes a verified
CalculationRevision into a current
ModeloRecord after the
WorkflowEngine preflight gate passes. Filing
transitions and audit entries are persisted through the application-owned
bucket-event capability shared by the modelo revision services.
The action records the operator’s local/internal filing state only. It never
submits to AEAT, never marks AEAT acceptance, and never fabricates official
external evidence. A successful transition sets the target revision to
PRESENTADO, creates a VIGENTE
ModeloRecord with aeat_accepted=False, and
delegates cross-period carry projection to
persist_filed_revision(),
which stamps locally-filed observations as non-official app_filing evidence.
See also
import_external_filing_evidence():Separate AEAT-attested import path that creates
ExternalEvidencebaselines; this local filing action deliberately does not.persist_filed_revision():Persists the filing catalogue, revision state, work-unit pointers, bucket events, participation index rows, and optional carry observation.
persist_filed_revision_observation():Projects filed casillas into non-official cross-period observations.
resolve_modelo_result_disposition():Resolves the shared Modelo 303 refund/carry disposition before the file transition persists.
cadrumo.application.modelo.verification_actions._require_cross_period_clean_state:Rechecks cross-period dependencies before local filing state is written.
- exception ModeloFilingEvidenceMissingError(message=None, *, context=None, translated_message=None, precondition_failure=None)[source]¶
Bases:
ModeloPreconditionErrorMixin,ModeloErrorRaised when internal filing would seal deductible IVA without evidence.
- Parameters:
message (str | None)
translated_message (str | None)
precondition_failure (ModeloPreconditionFailure | None)
- Return type:
None
- code¶
- file_modelo_revision(calculation_revision_id, *, certificate_secret_backend_factory, operator_scope_ports, ports, actor, workflow_profile, operation, notes=None, refund_election=RefundElection.COMPENSAR, payment_election=PaymentElection.INGRESO, prior_domiciliation_election=PriorDomiciliationElection.KEEP, cross_period_expected_member_sets=(), workflow_engine=None, workflow_runs_dir=None, settings=None, clock=None, profile=None)[source]¶
Mark a verified-complete revision as the current internal filed answer.
This is the application service behind
aeat app modelo work file. It is a local state transition, not an AEAT presentation: the resultingModeloRecordhasaeat_accepted=Falseand no external evidence.Preconditions and state changes:
Verify the revision is in
VERIFICADO_COMPLETOstate.Recheck profile readiness, persisted Modelo 303 IVA-wallet decision compatibility, and cross-period clean state.
Run the
WorkflowEnginegate for the revision’s modelo and period.Resolve the Modelo 303 result disposition from
RefundElection,PaymentElection, andTaxpayerProfile.If a prior current filing exists, mark its
ModeloRecordasSUPERSEDIDOand its priorCalculationRevisionasPRESENTADO_SUPERSEDIDO.Create the new filing record with status
VIGENTEand transition the target calculation revision fromVERIFICADO_COMPLETOtoPRESENTADO.Advance the work unit’s
filed_calculation_revision_idandcurrent_filing_record_idpointers, emitMODELO_FILED/MODELO_FILED_SUPERSEDEDbucket events, and persist any localapp_filingcarry observation.
- Parameters:
calculation_revision_id (
TypeAliasType) – The id of the verified-complete revision to file.certificate_secret_backend_factory (
CertificateSecretBackendFactory) – Factory for the encrypted certificate-secret capability used by workflow authentication.operator_scope_ports (
OperatorScopePorts) – Operator-scope capabilities used by workflow authentication.actor (
str) – Operator identifier recorded in the filing record and audit trail.workflow_profile (
TaxpayerProfile) – TheTaxpayerProfileused to evaluateWorkflowEnginegate conditions and cross-period clean-state applicability.notes (
str|None) – Optional operator-supplied filing notes.refund_election (
RefundElection) – The operator’s per-filing Modelo 303 negative-result disposition election. Defaults toCOMPENSAR(carry the credit forward).DEVOLVERrequests the credit back as a refund and is honoured only when the period is a lawful refund period (the year’s last filing period for a non-REDEME taxpayer; every period for REDEME). An out-of-windowDEVOLVERis refused.payment_election (
PaymentElection) – The operator’s positive-result settlement election.INGRESOis the default,DOMICILIACIONis available only for Modelo 303, andCUENTA_CORRIENTEremains explicitly refused until its AEAT capability is grounded.prior_domiciliation_election (
object) – Whether to preserve the prior direct debit or request its cancellation/modification. The latter is accepted only for an M303 rectificativa with the official baseline-U proof.ports (
FilingActionPorts) – Complete application-owned filing capability bundle. It supplies the work-unit, calculation, filing, verification, observation, IVA-wallet, bucket-event, and workflow-run authorities for the active profile bucket.operation (
PinnedAuthorityOperation) – Caller-owned generation-pinned indexed authority operation.cross_period_expected_member_sets (
Iterable[CrossPeriodExpectedMemberSet]) – Optional expected grupo member rosters used by the cross-period clean-state proof.workflow_engine (
WorkflowEngine|None) – Optional workflow engine override for the preflight gate.workflow_runs_dir (
Path|None) – Optional workflow runs directory override.profile (
ModeloWorkProfile|None) – The work profile the calling command already loaded for the revision’s bucket. When omitted, this entry loads it once; every profile read below uses that record.
- Return type:
- Returns:
The newly created local
ModeloRecordinVIGENTEstatus.- Raises:
CalculationRevisionNotFoundError – When the revision id is absent.
CalculationRevisionStateError – When the revision is not in
VERIFICADO_COMPLETOstate.WorkUnitNotFoundError – When the revision’s parent work unit cannot be loaded.
See also
persist_filed_revision():Performs the repository writes once all gates pass.
import_external_filing_evidence():Creates official-evidence baselines for imported filings; use that path when a
ExternalEvidencereference must be carried.persist_filed_revision_observation():Saves the non-official
app_filingobservation used by laterprevious_filingcalculations.export_modelo_revision():Sibling local finish line that writes the fichero-BOE artefact without requiring this internal file marker.
- list_filing_records(*, ports, bucket_id=None, modelo=None, include_superseded=False)[source]¶
List
ModeloRecordrows, optionally filtered to a bucket and modelo.Superseded records are excluded unless
include_supersededis true. Results are sorted by(bucket_id, filing_year, modelo, period, filed_at).- Return type:
- Parameters:
ports (FilingActionPorts)
bucket_id (str | None)
modelo (str | ModeloCode | None)
include_superseded (bool)
- get_filing_record(filing_record_id, *, ports)[source]¶
Return the
ModeloRecordfor the given id, or raise.- Return type:
- Parameters:
filing_record_id (str)
ports (FilingActionPorts)
- list_verification_reports(*, ports, calculation_revision_id=None, operation)[source]¶
List
VerificationReportrecords.Optionally filtered to one
CalculationRevision. TheVerificationReportCatalogueRepositoryProtocolsupplies the persisted report catalogue. Results are sorted by(calculation_revision_id, run_at).- Return type:
- Parameters:
ports (FilingActionPorts)
calculation_revision_id (CalculationRevisionId | None)
operation (PinnedAuthorityOperation)
- get_verification_report(verification_report_id, *, ports, operation)[source]¶
Return one
VerificationReportby id, or raise.The optional
VerificationReportCatalogueRepositoryProtocolsupplies the persisted report catalogue for tests or alternate storage boundaries.- Return type:
- Parameters:
verification_report_id (str)
ports (FilingActionPorts)
operation (PinnedAuthorityOperation)