aeat.domain.deadlines._engine module

Registry-backed deadline computation engine.

Takes an TaxpayerProfile and a year and produces a deterministic, typed Schedule. Filing windows and applicability conditions are read from validated calculation registry data supplied by ValidatedRegistryAuthority. Each window is described by a ModeloRevision paired with its deadline window definitions.

class DeadlineEngine(*, due_soon_days=14, registry_root=None, source_root=None)[source]

Bases: object

Engine that computes typed filing schedules from registry data.

Variables:

due_soon_days – Window before aeat.domain.deadlines.ModeloDeadline.closes_on that flags aeat.domain.deadlines.ObligationStatus.DUE_SOON (default 14).

Parameters:
  • due_soon_days (int)

  • registry_root (Path | None)

  • source_root (Path | None)

compute(profile, year, *, today=None)[source]

Compute the full Schedule for profile x year.

Pure function: no I/O, no input mutation. Identical (profile, year, today) always yields an equal schedule (modulo Schedule.generated_at).

Parameters:
  • profile (TaxpayerProfile) – The TaxpayerProfile to compute obligations for.

  • year (int) – The fiscal year to compute for.

  • today (date | None) – Reference date for status classification. Defaults to date.today().

Return type:

Schedule

Returns:

The Schedule containing every obligation that applies to profile for year.

Raises:

NoDeadlineWindowsError – If no validated registry deadline windows are registered for year — the benign data gap callers degrade around.

explain(profile, modelo, *, year=None)[source]

Return registry-backed deadline applicability text for modelo.

Parameters:
  • profile (TaxpayerProfile) – The TaxpayerProfile to evaluate conditions against.

  • modelo (str) – The AEAT modelo identifier to look up.

  • year (int | None) – Optional fiscal year; defaults to the current year.

Return type:

str

applies_to(profile, modelo, *, year=None)[source]

Return whether registry deadline conditions match for modelo.

Parameters:
  • profile (TaxpayerProfile) – The TaxpayerProfile to evaluate conditions against.

  • modelo (str) – The AEAT modelo identifier to check.

  • year (int | None) – Optional fiscal year; defaults to the current year.

Return type:

bool

next_deadline(schedule, today=None)[source]

Return the next obligation in schedule that has not yet closed.

Pure function. Returns None if every obligation in the schedule is already overdue (or the schedule is empty).

Parameters:
  • schedule (Schedule) – The Schedule to scan for upcoming obligations.

  • today (date | None) – Reference date. Defaults to date.today().

Return type:

ModeloDeadline | None

Returns:

The earliest non-overdue ModeloDeadline, or None if no such obligation exists.

class ScheduleProducer(*args, **kwargs)[source]

Bases: Protocol

Structural surface over DeadlineEngine.compute.

compute_obligation_schedule() is typed against this Protocol rather than the concrete DeadlineEngine so the workflow engine — which injects a protocol-typed deadline engine — and the state projection — which uses a concrete DeadlineEngine — can both feed the same single-producer function.

compute(profile, year, *, today=None)[source]

Return a Schedule for profile in year.

Parameters:
Return type:

Schedule

compute_obligation_schedule(engine, profile, *, today)[source]

Compute the obligation Schedule from one canonical call.

This is the single producer of the pending-obligation datum. Both the operator state read-projection (pending_obligations) and the WorkflowEngine NO_PENDING_OBLIGATION gate route their schedule computation through here, so the gate and the projection cannot draw a divergent obligation set: identical (engine, profile, today) always yields an equal schedule (modulo Schedule.generated_at).

The fiscal year is derived from today so neither consumer can pass a mismatched (year, today) pair.

Parameters:
Return type:

Schedule

Returns:

The Schedule of obligations applicable to profile for today’s fiscal year.

applies_to(profile, modelo)[source]

Return whether registry deadline conditions match for modelo.

Parameters:
Return type:

bool

explain(profile, modelo)[source]

Return registry-backed deadline applicability text for modelo.

Parameters:
Return type:

str