cadrumo.application.modelo.work_create_policy module¶
Application policies for creating modelo work units.
The work-create command runs these guards before provisioning a work unit. They cover three distinct policy surfaces: modelo codes that are still stub-only in the local work-unit flow, modelos that do not apply to the active profile’s taxpayer model, and active profiles whose CCAA points at a foral tax regime.
Stub-only checks are locale-key lookups over Modelo members and a few
registry-known numeric forms. Applicability checks derive a profile projection
from the active workflow state, then ask the registry-owned applicability rules
whether the requested modelo is excluded. The foral check delegates to the
canonical tax-region parser so the CLI renders the same refusal text as profile
setup. Once these CLI policy guards pass,
cadrumo.application.modelo.work_lifecycle.create_work_unit() performs the application
readiness and registry revision checks before inserting the
WorkUnit.
See also
cadrumo.entrypoints.cli._modelo_work_lifecycle_cli:Calls these guards from
app modelo work create.cadrumo.domain.calculations.registry.applicability.derive_modelo_applicability():Registry-owned modelo applicability classifier used by this guard.
cadrumo.domain.contribuyente.tax_residence.parse_tax_region():Canonical CCAA parser that raises foral-regime refusals.
- CEDED_AUTONOMIC_MODELO_LOCALE_KEYS: dict[str, str]¶
Ceded autonomic-tax modelos that are administered by the Comunidades Autónomas rather than the AEAT, and are therefore absent from the calculation registry entirely: ITP-AJD (
600,620) and ISD (650,660) are tributos cedidos. A registry discovery lookup for one of these codes must redirect the operator to the competent regional Hacienda / CCAA instead of surfacing a generic not-present-in-registry error. The values reuse the work-create refusal copy, which already names the ceded tax, its enabling law, and the regional filing route in every locale.
- ceded_autonomic_modelo_locale_key(modelo)[source]¶
Return the instructive autonomic-redirect locale key for a ceded modelo.
ITP-AJD (
600/620) and ISD (650/660) are ceded autonomic taxes administered by the Comunidades Autónomas, not AEAT modelos present in the calculation registry. Discovery surfaces (describe/casillas/formulas) must redirect an operator who references one of these codes to the competent regional Hacienda / CCAA rather than surface a generic not-present error. Whitespace is normalised;Noneis returned for any other modelo, including registry-backed and genuinely unknown codes.See also
modelo_work_create_refusal_locale_key():The sibling work-create refusal this discovery redirect mirrors.
- class ModeloWorkCreateApplicabilityRefusal(modelo, reason)[source]¶
Bases:
objectApplication refusal for a modelo the active profile should not file.
modelois the stripped requested modelo code.reasonis the registry-derived applicability reason surfaced by the CLI together with its--allow-not-applicableescape hatch.
- modelo_work_create_refusal_locale_key(modelo)[source]¶
Return the jurisdiction redirect for a ceded autonomic tax, if any.
AEAT modelo capability is deliberately absent from this policy. Registry snapshot, readiness, calculation, and filing boundaries each validate the capability they actually require; a hand-maintained “stub” classification cannot represent those distinct surfaces and inevitably lags them.
See also
ceded_autonomic_modelo_locale_key():The domain-owned jurisdiction classifier delegated to here.
cadrumo.entrypoints.cli._modelo_work_lifecycle_cli:Converts the locale key into a typed CLI refusal.
- modelo_work_create_applicability_refusal(modelo, *, allow_not_applicable, record)[source]¶
Return an applicability refusal for the active profile, if one applies.
When
allow_not_applicableis true, the guard deliberately returnsNoneso the CLI can provision the work unit and record that the operator bypassed the applicability guard. Otherwise the caller’s loaded profile record is projected intocadrumo.domain.deadlines.models.TaxpayerProfilefacts and checked against the registry-owned applicability rules. OnlyNOT_APPLICABLEandATTRIBUTION_PASS_THROUGHverdicts block creation.- Return type:
- Returns:
A
ModeloWorkCreateApplicabilityRefusalfor a blocking verdict, orNonewhen the modelo is applicable, unsupported by an explicit rule, or deliberately bypassed.- Parameters:
modelo (str)
allow_not_applicable (bool)
record (UserProfileRecord | None)
See also
cadrumo.domain.calculations.registry.applicability.derive_modelo_applicability():Registry-owned applicability classifier used by this guard.
cadrumo.application.user_profile.projections.projection_for_taxpayer():Builds the taxpayer profile consumed by the classifier.
Core types:
UserProfileRecord.
- guard_active_profile_foral_ccaa(record)[source]¶
Raise the canonical foral-regime refusal for the active profile, if present.
The guard reads
tax_residence.ccaafrom the active profile record the caller already loaded and delegates tocadrumo.domain.contribuyente.tax_residence.parse_tax_region(). Common-regime CCAA values pass through; foral values raise the domain refusal before work-unit creation reaches the generic unsupported-modelo checks.Core types:
UserProfileRecord.- Return type:
- Parameters:
record (UserProfileRecord | None)