aeat.application.modelo._local_observation_spreadsheet module¶
Parse a two-column casilla-value spreadsheet into a decimal mapping.
An operator keeps a hand-authored CSV or XLSX spreadsheet of casilla_code, value
rows — a cert-free reconstruction path for a past filing when neither the
justificante PDF (application.filing._import) nor a live AEAT pull
is available. This module owns exactly the tabular-to-mapping projection: read
the two declared columns, coerce every value to Decimal, and
hand the caller a plain {casilla_code: Decimal} mapping keyed by the raw
spreadsheet token (not yet validated against any registry revision).
Casilla-id canonicalisation, registry-membership validation, and
CasillaObservation construction
remain owned by record_operator_local_observation(),
which this module’s CLI caller feeds directly — there is no second casilla
validation path here (no-dormant-source-resolvers companion: one
validation authority, not two).
See also
record_operator_local_observation():Consumes the parsed mapping, validates every casilla id against the law-determined
RegistrySnapshot, and persists the non-official observation.adapters.inbound.financial.providers._csv:Sibling tabular-ingest module for bank-statement rows; this module is deliberately smaller — a casilla-value sheet has two logical columns and no bank-layout detection, date parsing, or currency handling.
- CSV_EXTENSIONS: Final[frozenset[str]]¶
Extensions routed to the CSV reader; anything else is routed to XLSX.
- parse_casilla_value_spreadsheet(path)[source]¶
Parse a
casilla_code, valuespreadsheet into a raw code-to-Decimal mapping.Accepts CSV (
.csv/.txt) or XLSX (.xlsx). The first non-blank row is treated as the header; a header row naming both a casilla-code column (casilla_code/casilla/casilla_id/code/id/box) and a value column (value/valor/amount/importe, case-insensitive) selects those columns by name. A headerless two-column sheet falls back positionally: column A is the casilla code, column B is the value.Every value is coerced to
Decimal; a non-numeric value raisesModeloLocalObservationErrornaming the offending row. A blank row is skipped. A row that omits the casilla code but carries a value (or vice versa) raises, naming the row.- Return type:
- Returns:
A
{raw_casilla_code: Decimal}mapping in row order. Keys are the spreadsheet’s literal cell text — not yet canonicalised or validated against any registry revision.- Raises:
ModeloLocalObservationError – The file cannot be opened, carries no data rows, or a data row cannot be parsed into a
(casilla_code, Decimal)pair.- Parameters:
path (Path)