aeat.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 aeat.domain.renta.MaritimeWorkerFacts, delegates legal pathway selection and typed observation creation to aeat.application.calculations.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 aeat.domain.renta.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

aeat.entrypoints.cli._modelo_maritime_cli.register_maritime_commands():

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

aeat.application.calculations.resolve_maritime_exemption():

Legal application service that produces the typed observations.

aeat.domain.renta.MaritimeWorkerFacts:

Closed profile fact carrier consumed by the maritime selectors.

aeat.domain.renta.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.

  • resultMaritimeExemptionResult 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:
facts: MaritimeWorkerFacts
result: MaritimeExemptionResult
retmar_warning_error: ProfileCompletenessError | None
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

aeat.application.user_profile.fact_value():

Reads a stored profile fact by dotted path.

aeat.application.workflow.workflow_state_repository():

Supplies the active profile record.

Return type:

MaritimeWorkerFacts

preview_maritime_exemption_for_active_profile(*, annual_salary, qualifying_days, gross_navigation_income)[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.

Return type:

ModeloMaritimeExemptionPreview

Returns:

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

See also

aeat.application.calculations.resolve_maritime_exemption():

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

aeat.application.calculations._maritime_exemption_service.MaritimeExemptionResult:

Typed observation carrier stored on the preview.