aeat.application.modelo._profile_readiness_gate module

Profile readiness gate for filing-grade modelo work.

Loads the active domain.user_profile.UserProfileRecord, builds a application.user_profile.ProfilePreflightReport, projects local-work applicability through domain.deadlines.TaxpayerProfile, and raises application.modelo.ModeloProfileReadinessError before filing-grade work proceeds when required profile facts are missing. The revision-specific preflight branch may receive a ModeloRevision that has already been resolved by an operator-facing readiness surface. The same gate also refuses Modelo 130 and Modelo 303 target periods whose date span ends before the profile’s censo.activity_start_date; those pre-activity periods have no filing obligation and must not produce stale work, calculation, verification, filing, or export state.

See also

require_profile_ready_for_work_unit():

Replays the same readiness checks for an existing domain.modelos.WorkUnit.

application.user_profile.ProfilePreflightReport:

User-profile preflight result consumed by this application gate.

modelo_work_profile_baseline_missing_paths(record)[source]

Return profile facts required before any filing-grade modelo work starts.

Parameters:

record (UserProfileRecord) – Active domain.user_profile.UserProfileRecord projected into schema-path values.

Return type:

tuple[str, ...]

modelo_work_profile_baseline_validation_issues(record)[source]

Return validate-surface issues for the central modelo work profile baseline.

Parameters:

record (UserProfileRecord) – Active domain.user_profile.UserProfileRecord checked against the filing-grade baseline.

Return type:

tuple[ProfileValidationIssue, ...]

Returns:

Tuple of application.user_profile.ProfileValidationIssue instances for missing filing-grade baseline facts.

modelo_work_profile_preflight_report(*, record, modelo, revision_id, filing_year, period, revision=None, resolve_revision_when_missing=True)[source]

Return the profile-field report enforced by the modelo work creation gate.

This combines the filing-grade baseline that every modelo work unit needs with the modelo/revision-specific profile selectors. Public readiness surfaces consume this function so they cannot claim profile readiness before application.modelo.create_work_unit() would reject the same active profile.

Parameters:
  • record (UserProfileRecord) – Active domain.user_profile.UserProfileRecord.

  • modelo (str) – Modelo code being checked.

  • revision_id (str) – Registry revision identifier for the target modelo work.

  • filing_year (int) – Filing year for the target period.

  • period (Period) – Target core.Period used for registry revision resolution and profile selector evaluation.

  • revision (ModeloRevision | None) – Optional ModeloRevision supplied when the caller has already resolved the target revision.

  • resolve_revision_when_missing (bool) – Whether to resolve the registry revision when revision is not supplied.

Return type:

ProfilePreflightReport

Returns:

application.user_profile.ProfilePreflightReport combining baseline, validation, and modelo/revision-specific missing requirements.

modelo_applicability_refusal(*, record, bucket_id, modelo)[source]

Return the local-work applicability refusal for a target, if any.

Parameters:
Return type:

tuple[str, dict[str, str]] | None

pre_activity_period_refusal(*, record, bucket_id, modelo, filing_year, period)[source]

Return the pre-activity lifecycle refusal for a target, if any.

Parameters:
  • record (UserProfileRecord) – Active domain.user_profile.UserProfileRecord carrying the profile facts used to resolve censo.activity_start_date.

  • bucket_id (str) – Active profile bucket identifier included in the refusal context.

  • modelo (str) – Modelo code being checked.

  • filing_year (int) – Filing year for the target period.

  • period (Period) – Target core.Period whose date span is compared against the profile activity-start date.

Return type:

tuple[str, dict[str, str | int]] | None

require_profile_ready_for_modelo_work(*, bucket_id, modelo, revision_id, filing_year, period, enforce_applicability=True)[source]

Refuse filing-grade modelo work when the active profile is not eligible.

Loads the bucket’s domain.user_profile.UserProfileRecord, evaluates modelo-specific profile requirements through application.user_profile.ProfilePreflightReport, and then applies the pre-activity period check for lifecycle modelos whose obligation starts at censo.activity_start_date.

Return type:

None

Parameters:
  • bucket_id (str)

  • modelo (str)

  • revision_id (str)

  • filing_year (int)

  • period (Period)

  • enforce_applicability (bool)

require_existing_profile_baseline_ready_for_modelo_work(*, bucket_id, modelo, filing_year, period, enforce_applicability=True)[source]

Refuse plainly incomplete existing profiles before registry work.

This early gate is used by application.modelo.create_work_unit() before the registry revision and period are validated. It catches missing baseline profile facts, local-work applicability refusals, and pre-activity lifecycle periods without requiring a resolvable ModeloRevision. Missing profiles still pass through so the later full readiness gate can raise the canonical missing-profile error.

Return type:

None

Parameters:
require_profile_ready_for_work_unit(work_unit, *, enforce_applicability=True)[source]

Run the profile readiness gate for an existing work unit.

Calculation, verification, filing, and export services call this wrapper so a previously created domain.modelos.WorkUnit is rechecked against the current domain.user_profile.UserProfileRecord before any filing-grade mutation proceeds.

Return type:

None

Parameters: