cadrumo.application.modelo.maritime_preview module

Application service for active-profile maritime exemption previews.

This module backs the aeat app modelo work preview-maritime-exemption CLI surface. It reads the active profile’s maritime_worker.* facts, normalises them into cadrumo.domain.renta.maritime_exemption.MaritimeWorkerFacts, delegates legal pathway selection and typed observation creation to cadrumo.application.calculations.maritime_exemption_service.resolve_maritime_exemption(), and returns a ModeloMaritimeExemptionPreview for transport rendering.

The RETMAR mandatory-filing completeness gate is handled here rather than in the CLI transport. When the legal resolver raises cadrumo.domain.renta.maritime_exemption.ProfileCompletenessError, the service preserves the original profile facts and reruns the calculation with only retmar_registered cleared, allowing the CLI to emit both the warning and the same observation payload shape used by non-warning previews.

See also

cadrumo.entrypoints.cli._modelo_maritime_cli:

Serves the CLI command that serialises this preview into operator payloads.

cadrumo.application.calculations.maritime_exemption_service.resolve_maritime_exemption():

Legal application service that produces the typed observations.

cadrumo.domain.renta.maritime_exemption.MaritimeWorkerFacts:

Closed profile fact carrier consumed by the maritime selectors.

cadrumo.domain.renta.maritime_exemption.ProfileCompletenessError:

Warning-class gate used for RETMAR mandatory-filing disclosure.

class ModeloMaritimeExemptionPreview(facts, result, retmar_warning_error=None)[source]

Bases: object

Resolved active-profile maritime preview returned to the CLI renderer.

Variables:
  • facts – Original MaritimeWorkerFacts read from the active profile. These facts are preserved even when RETMAR warning handling reruns the calculation with a cleared flag.

  • result – MaritimeExemptionResult containing typed observations and the derived casilla-value view.

  • retmar_warning_error – Optional ProfileCompletenessError for the CLI to translate into retmar_warning while still emitting observations.

Parameters:

Read retmar_mandatory_filing from this preview, never from result: on the warning path the result was computed from cleared facts and its copy of that answer is false regardless of the truth.

facts: MaritimeWorkerFacts
result: MaritimeExemptionResult
retmar_warning_error: ProfileCompletenessError | None
property retmar_mandatory_filing: bool

Whether RETMAR registration makes this filing mandatory.

Read from facts rather than from result, and that is the whole point of the property. On the warning path result was computed from facts with the RETMAR flag deliberately cleared, so its own copy of this answer is false whether or not the worker is registered. Asking here, through the service’s one determination, keeps the two paths agreeing and keeps the answer out of the renderer that was previously reconstructing it.

maritime_facts_from_active_profile()[source]

Build MaritimeWorkerFacts from the active workflow profile.

The profile store exposes encrypted fact values as raw strings, so this adapter narrows the closed literal fields accepted by MaritimeWorkerFacts and converts absent or falsy boolean facts to False. It does not evaluate legal eligibility; the returned facts are passed unchanged to the maritime exemption resolver.

See also

cadrumo.application.user_profile.projections.fact_value():

Reads a stored profile fact by dotted path.

cadrumo.application.workflow.persistence.workflow_state_repository():

Supplies the active profile record.

Return type:

MaritimeWorkerFacts

preview_maritime_exemption_for_active_profile(*, annual_salary, qualifying_days, gross_navigation_income, operation=None)[source]

Resolve the active profile maritime exemption preview.

annual_salary and qualifying_days are required only when the active facts trigger Art. 7.p) eligibility. gross_navigation_income is required only when the active facts trigger the REBECA pathway. The resolver owns those eligibility checks and raises the domain validation errors for missing inputs.

RETMAR registration is a non-blocking warning for this preview: the first resolver call records the ProfileCompletenessError, then the calculation is rerun with retmar_registered=False so the operator still receives the observation payload. The returned ModeloMaritimeExemptionPreview keeps the original facts, the rerun result, and the warning error for CLI translation.

Parameters:
  • annual_salary (Decimal | None) – Optional gross annual salary in EUR for Art. 7.p).

  • qualifying_days (int | None) – Optional days worked outside Spanish territory for Art. 7.p).

  • gross_navigation_income (Decimal | None) – Optional gross navigation income in EUR for REBECA.

  • operation (PinnedAuthorityOperation | None) – Optional caller-held generation-pinned registry operation.

Return type:

ModeloMaritimeExemptionPreview

Returns:

ModeloMaritimeExemptionPreview carrying original facts, resolved observations, and an optional RETMAR warning error.

See also

cadrumo.application.calculations.maritime_exemption_service.resolve_maritime_exemption():

Performs DA 41, RETMAR, Art. 7.p), and REBECA resolution.

cadrumo.application.calculations.maritime_exemption_service.MaritimeExemptionResult:

Typed observation carrier stored on the preview.