aeat.application.overview._data_prep module

Data-prep walkthrough: ordered readiness checklist for one (modelo, period).

build_data_prep_walkthrough() is the application service backing aeat app overview prepare --modelo MODELO --year YEAR --period PERIOD. It walks the operator through the data-preparation phase that precedes a modelo calculation - import transactions, classify them, attach purchase-invoice evidence, register business invoices, resolve ledger readiness gaps, then start or resume a modelo work unit - showing each step’s current state against the active profile bucket and the exact next command to run.

The builder is READ-ONLY: it inspects the transaction catalogue, the invoice catalogue, the purchase-invoice evidence store, the ledger preflight report, and the modelo work-unit catalogue for the requested (modelo, filing_year, period) scope. It persists nothing and never contacts AEAT. Every counter it reports is already produced by an existing read model (preflight_ledger_tax_readiness(), list_work_units()) or a direct repository read; this module composes them into one ordered checklist rather than introducing a new aggregation.

See also

overview

Sibling read-only overview builders (status, calendar, agenda, backlog, explain) this module follows the same shape as.

ledger

Owns preflight_ledger_tax_readiness(), the classification/category/IVA-fact readiness gate this walkthrough’s “classify” step reuses rather than re-deriving.

WorkUnit

The modelo work-unit record the final step resolves against.

class DataPrepStepState(*values)[source]

Bases: StrEnum

Closed lifecycle state for one data-prep walkthrough step.

Variables:
  • DONE – The step’s readiness condition is fully satisfied for the requested scope.

  • IN_PROGRESS – Some but not all of the step’s underlying facts are present (e.g. some transactions classified, others not).

  • PENDING – The step has not been started for the requested scope.

  • BLOCKED – The step cannot proceed because an upstream capability the step depends on is not yet available in this application.

DONE
IN_PROGRESS
PENDING
BLOCKED
class DataPrepStepId(*values)[source]

Bases: StrEnum

Closed identifier for one ordered data-prep walkthrough step.

IMPORT_TRANSACTIONS
CLASSIFY_TRANSACTIONS
ATTACH_EVIDENCE
REGISTER_INVOICES
RESOLVE_READINESS
START_MODELO_WORK
class DataPrepStep(**data)[source]

Bases: BaseModel

One ordered row in the data-prep walkthrough.

Variables:
  • step_id – Closed DataPrepStepId for this row.

  • state – Current DataPrepStepState against the active profile bucket and the requested scope.

  • summary – Human-readable progress counter (e.g. “247 transactions ingested”, “14 unclassified”).

  • next_command – The exact next aeat command to run to advance this step, or resolve its current gap. Always populated so the operator (human or autonomous agent) never has to guess.

Parameters:
step_id: DataPrepStepId
state: DataPrepStepState
summary: str
next_command: str
class DataPrepWalkthrough(**data)[source]

Bases: BaseModel

Outcome of build_data_prep_walkthrough().

Variables:
  • modelo – Registry-validated AEAT modelo code the walkthrough targets.

  • filing_year – Filing year for the requested scope.

  • period – Registry period token for the requested scope (e.g. 1T).

  • steps – Ordered DataPrepStep rows; step 1 is always import_transactions, the final step is always start_modelo_work.

  • ready_for_calculationTrue only when every step is DONE.

Parameters:
modelo: str
filing_year: int
period: str
steps: tuple[DataPrepStep, ...]
ready_for_calculation: bool
build_data_prep_walkthrough(*, bucket_id, modelo, period, transaction_repository, invoice_catalogue, evidence_records, preflight_report, work_units)[source]

Build the ordered data-prep checklist for one (modelo, period) scope.

Parameters:
Return type:

DataPrepWalkthrough

Returns:

A DataPrepWalkthrough with one ordered step per data-prep phase and the exact next command for each.