aeat.adapters.outbound.aeat.sede._iva_compensation_wallet_parsing module

Pure HTML-parsing and URL-audit layer for the AEAT IVA compensation wallet.

This module is the side-effect-free half of the wallet reader: it takes captured AEAT cartera HTML (or URLs) and returns parsed observations, structural shape diagnostics, and host/path audit decisions. It has no Playwright, browser-session, or navigation dependency, so the navigation/state-machine half (_iva_compensation_wallet) imports from here rather than the reverse.

The wallet URL/host constants live here too because both halves consume them; the navigation module re-imports them so there is a single definition.

parse_iva_compensation_wallet_html(html, *, taxpayer_nif, authenticated_identity, target_year, target_period, source_url, captured_at, allow_empty_wallet_shell=False)[source]

Parse wallet rows and the total from a captured AEAT cartera HTML page.

Returns a IvaCompensationWalletObservation with the aggregate and per-period detail rows.

The own-name “Cartera de cuotas de IVA a compensar” results view carries an authoritative aggregate — the “Cuotas a compensar pendientes de períodos anteriores” line — plus a detail table (Ejercicio / Período / Cuota Disponible) itemising the still-available balance per generation period. The aggregate is the contract value surfaced as total_pending; the detail rows are cross-checked against it so a parse drift cannot silently under-declare. A genuinely empty wallet renders the same aggregate line at 0,00 with no detail rows.

Return type:

IvaCompensationWalletObservation

Parameters:
  • html (str)

  • taxpayer_nif (str)

  • authenticated_identity (str)

  • target_year (int)

  • target_period (Period)

  • source_url (str)

  • captured_at (datetime)

  • allow_empty_wallet_shell (bool)

discover_iva_compensation_wallet_entrypoint(html, *, base_url)[source]

Return AEAT’s Pre303-provided wallet URL when the authenticated page exposes one.

Return type:

str | None

Parameters:
is_aeat_wallet_auth_gate_redirect(current_url)[source]

Return True when wallet navigation lands on AEAT’s certificate/auth 4033 page.

Return type:

bool

Parameters:

current_url (str)