cadrumo.domain.deadlines.profiles module

Profile construction helpers for deadline and schedule consumers.

The helper projects a ProfileRecord.values-shaped mapping into an TaxpayerProfile through project_setup_answers(), which reads stored facts by their profile path and applies the canonical-token parsing every field declares.

The projection deliberately depends on the registry answer declarations and not on any interactive surface. Deciding which modelos a taxpayer must file is a regulatory computation that runs on stored facts; when it instead walked the terminal wizard’s question catalogue, a schedule could not be computed in a process that had never built a setup UI, and the UI could not be replaced without moving the tax logic with it.

taxpayer_profile_from_mapping(values, *, tax_id_default, iva_regime_default=None)[source]

Build an TaxpayerProfile from a profile-values mapping.

The mapping is projected through the descriptor’s project_answers so canonical-token semantics for every boolean / select / text field stay in lockstep with the wizard’s on-prompt validation. Missing identity fields fall back to tax_id_default. Missing IVA regime falls back to NO_APLICA for natural persons without economic-activity income and to iva_regime_default for profiles that still require an IVA regime declaration.

Return type:

TaxpayerProfile

Parameters:
MODELO_IVA_BLOCK_CLAIMING_PATHS: frozenset[str]

Every profile path whose presence claims the Modelo IVA block.

The claiming set and MODELO_IVA_BLOCK_REQUIRED_PATHS are one family read from both directions: declaring any path here obliges every path there. Consumers that gate a surface on the block – the wizard’s question visibility, profile completeness – need the membership set itself, not only the mapping-shaped profile_claims_modelo_iva_block() predicate over it.

MODELO_IVA_BLOCK_REQUIRED_PATHS: tuple[str, ...]

Every path _resolve_modelo_iva_profile() refuses to build without.

Declared beside the resolver that enforces it so the readiness surfaces and the resolver read ONE answer. They did not: the resolver hard-required six facts while profile completeness knew of none of them, so a profile declaring any IVA fact was reported ready and then refused two commands later by a resolver naming a path no surface had asked for.

profile_claims_modelo_iva_block(values)[source]

Report whether values declares any fact owned by the Modelo IVA block.

Presence is value-bearing, not truth-bearing: answering “no” to an IVA enrolment still claims the block, because declining a regime is a declaration about IVA. Only an absent or blank path leaves it unclaimed.

Return type:

bool

Parameters:

values (Mapping[str, object])

modelo_iva_profile_required_paths(values)[source]

Return the profile paths a claimed Modelo IVA block obliges values to carry.

Empty when no IVA fact is declared at all, so a taxpayer with no IVA obligation is never asked for one.

Return type:

tuple[str, ...]

Parameters:

values (Mapping[str, object])