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:
objectEngine that computes typed filing schedules from registry data.
- Variables:
due_soon_days – Window before
aeat.domain.deadlines.ModeloDeadline.closes_onthat flagsaeat.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
Scheduleforprofilexyear.Pure function: no I/O, no input mutation. Identical
(profile, year, today)always yields an equal schedule (moduloSchedule.generated_at).- Parameters:
profile (
TaxpayerProfile) – TheTaxpayerProfileto compute obligations for.year (
int) – The fiscal year to compute for.today (
date|None) – Reference date for status classification. Defaults todate.today().
- Return type:
- Returns:
The
Schedulecontaining every obligation that applies toprofileforyear.- 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) – TheTaxpayerProfileto 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:
- applies_to(profile, modelo, *, year=None)[source]¶
Return whether registry deadline conditions match for
modelo.- Parameters:
profile (
TaxpayerProfile) – TheTaxpayerProfileto evaluate conditions against.modelo (
str) – The AEAT modelo identifier to check.year (
int|None) – Optional fiscal year; defaults to the current year.
- Return type:
- next_deadline(schedule, today=None)[source]¶
Return the next obligation in
schedulethat has not yet closed.Pure function. Returns
Noneif every obligation in the schedule is already overdue (or the schedule is empty).- Parameters:
- Return type:
- Returns:
The earliest non-overdue
ModeloDeadline, orNoneif no such obligation exists.
- class ScheduleProducer(*args, **kwargs)[source]¶
Bases:
ProtocolStructural surface over
DeadlineEngine.compute.compute_obligation_schedule()is typed against this Protocol rather than the concreteDeadlineEngineso the workflow engine — which injects a protocol-typed deadline engine — and the state projection — which uses a concreteDeadlineEngine— can both feed the same single-producer function.- compute(profile, year, *, today=None)[source]¶
Return a
Scheduleforprofileinyear.- Parameters:
profile (
TaxpayerProfile) – TheTaxpayerProfileto compute obligations for.year (
int) – The fiscal year to compute for.today (
date|None) – Reference date for status classification.
- Return type:
- compute_obligation_schedule(engine, profile, *, today)[source]¶
Compute the obligation
Schedulefrom one canonical call.This is the single producer of the pending-obligation datum. Both the operator state read-projection (
pending_obligations) and theWorkflowEngineNO_PENDING_OBLIGATIONgate 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 (moduloSchedule.generated_at).The fiscal year is derived from
todayso neither consumer can pass a mismatched(year, today)pair.- Parameters:
engine (
ScheduleProducer) – The deadline engine to compute with. AnyScheduleProducer— a concreteDeadlineEngineor the workflow engine’s protocol-typed injected deadline engine.profile (
TaxpayerProfile) – TheTaxpayerProfileto schedule obligations for.today (
date) – Reference date; the fiscal year and obligation status classification are both derived from it.
- Return type:
- Returns:
The
Scheduleof obligations applicable toprofilefortoday’s fiscal year.
- applies_to(profile, modelo)[source]¶
Return whether registry deadline conditions match for
modelo.- Parameters:
profile (
TaxpayerProfile) – TheTaxpayerProfileto evaluate conditions against.modelo (
str) – The AEAT modelo identifier to check.
- Return type:
- explain(profile, modelo)[source]¶
Return registry-backed deadline applicability text for
modelo.- Parameters:
profile (
TaxpayerProfile) – TheTaxpayerProfileto evaluate conditions against.modelo (
str) – The AEAT modelo identifier to look up.
- Return type: