aeat.adapters.outbound.aeat.sede._parse module¶
Pure-function HTML parsers for the authenticated AEAT sede.
All parsers take raw HTML strings and return strict pydantic records.
No Playwright, no I/O. This makes them trivially unit-testable
against captured fixtures and keeps the navigation (side-effect)
concerns isolated in adapters.outbound.aeat.sede._walker.
Public surface: parse_resumen_tree() (top-level expediente
listing), parse_expediente_detail() (per-expediente CSV
extraction).
- parse_resumen_tree(html, *, base_url)[source]¶
Extract every expediente leaf from a ResumenVlt page.
The sede renders an AJAX-expanded category tree. After every relevant category has been expanded (by the walker), every expediente shows up as an
<a>whosehrefpoints at one of AEAT’s per-filing-family endpoints and whose text is the expediente id.- Parameters:
- Return type:
- Returns:
Tuple of
Expedienterecords, one per discovered leaf. Order matches document order.- Raises:
SedeParseError – If the page has no category tree at all (the authenticated session likely expired).
- parse_expediente_detail(html, *, expediente_id, base_url)[source]¶
Extract the CSV-keyed justificante handle from a detail page.
Captured live: every IRPF detail page (
/wlpl/DASR-CORE/ AccesoDR<YYYY>RVlt) exposes the filed declaration via aGrabación de la declaración ... (Consulta / Copia)link that points at/wlpl/KATA-APLI/cotejo/CotejoIdSv?CSV=<csv>.- Parameters:
html (
str) – Full HTML body of the expediente detail page.expediente_id (
str) – AEAT-assigned identifier (copied through onto the returnedJustificanteRef).base_url (
str) – The sede base URL for absolutising the cotejo and PDF endpoints.
- Return type:
- Returns:
A
JustificanteRefready forcapture_justificante().- Raises:
SedeParseError – If no CSV-carrying anchor is present.