cadrumo.adapters.outbound.aeat.sede.iva_compensation_wallet module

Read-only AEAT IVA compensation wallet reader.

The wallet is external AEAT account state. This module only captures and parses evidence from the authenticated Sede surface; calculation selection happens later in the application reconciliation layer.

This module owns the Playwright navigation and representation-gate state machine; the side-effect-free HTML parsing, URL-audit, and page-shape diagnostics live in the sibling iva_compensation_wallet_parsing module and are re-imported here so the public read surface is unchanged.

async fetch_iva_compensation_wallet(session, *, target_year, target_period, taxpayer_nif=None, settings=None)[source]

Fetch and parse AEAT’s read-only IVA compensation wallet as a IvaCompensationWalletObservation.

Return type:

IvaCompensationWalletObservation

Parameters:
prune_wallet_diagnostic_dumps(dump_dir, *, retention_days=None, settings=None)[source]

Delete wallet diagnostic dump files older than the retention window.

The dump directory is opt-in (cadrumo_wallet_diagnostic_dump_dir); callers pass the configured directory in. retention_days defaults to cadrumo_wallet_diagnostic_retention_days. Invoked automatically after each dump so the opt-in directory carries a declared retention lifecycle instead of accumulating stale summaries once captures stop. Entirely best-effort: an unenumerable directory or an unremovable file is logged and skipped, never raised. The survivor decision (age cutoff alone) delegates to the shared select_filesystem_retention_survivors() selector; the enumeration and the removal side effect stay here.

Return type:

int

Returns:

Number of dump files removed.

Parameters:
assert_wallet_read_landing(landing_url)[source]

Refuse a landing outside the four pages this wallet read traverses.

This is the most write-adjacent driver in the package: it fills an ejercicio and periodo and then clicks AEAT’s ejecutar SUBMIT input. That click issues a browser form POST which the first-party HTTP guard never sees and which the package’s forbidden-verb source scan permits by design, so before this rule nothing established where the POST had landed. The post-execute shape check reads the returned HTML’s form action, which is a DOM AEAT controls and says nothing about the URL actually served.

The allow-list is the traversal itself, and every entry is an existing declared constant rather than a new claim: the Cl@ve access selector, AEAT’s representation gate, the Pre303 presentation service, and the wallet path. The wallet path is additionally the surface’s only declared read-POST path on the guard policy, so a POST landing there is admitted by the policy while a POST landing anywhere else is not.

Public so the wallet’s proof exercises this exact rule rather than a mirrored copy that would keep agreeing with itself.

Parameters:

landing_url (str) – The URL AEAT actually served, read off the page.

Raises:

SedeNavigationError – When the landing is not a declared read page.

Return type:

None