aeat.adapters.outbound.aeat.sede._censo_live module¶
Authenticated G313 (Mis Datos Censales) fetch driver.
Mirrors _notifications and _declarations: takes an
authenticated AeatSession, drives Playwright to the G313
launcher, captures the page HTML, and runs the existing
_censo.parse_g313_html() parser to lift the response into a
typed CensoFactSet.
The launcher procedure URL is the documented G313 entry point from
external_constants.toml. The session’s storage state carries the
AEAT cookies acquired via certificate or Cl@ve Móvil, so the launcher
redirects directly to the Mis Datos Censales data page instead of
bouncing through the login surface. If the session is not valid for
the operator’s NIF (e.g. certificate not registered against the censo),
the page returns AEAT’s standard auth-gate error shape and the parser
returns a CensoFactSet with no fields populated — the caller
decides whether that is a refusal.
- BrowserSessionFactory¶
Async factory returning an object exposing
create_context(storage_state=...)+close().Real production code uses
default_browser_session_factory(); tests inject a recording double via the same protocol so the storage-state plumbing can be exercised without a real Playwright browser.
- G313_LAUNCHER_URL¶
AEAT-published entry point for Mis Datos Censales (the read-only operator-facing projection of the operator’s 036 censo record).
- async fetch_g313_censo(session, *, settings=None)[source]¶
Live-fetch the G313 page under the authenticated session.
- Parameters:
session (
AeatSession) – An authenticatedAeatSessionwhose storage state carries valid AEAT cookies.
- Return type:
- Returns:
A
CensoFactSetparsed from the live HTML. May be empty (every fieldNone) when AEAT publishes no censo for the operator’s NIF — the caller (CensoSyncService) raisesCensoNotAvailableErroron that path.- Raises:
SedeNavigationError – when the session has no persisted browser state or the navigation itself fails.
- censo_fact_set_to_mapping(fact_set)[source]¶
Project a
CensoFactSetinto the dotted-key mapping the snapshot store accepts.Mirrors the
model_selectorsdeclarations in the schema so the snapshot path keys stay aligned with the user-profile schema paths the comparison verb walks against.- Return type:
- Parameters:
fact_set (CensoFactSet)