aeat.application.user_profile._projections module

Canonical projections from UserProfileRecord to consumer shapes.

The schema-driven user-profile backend is the canonical authority. Every existing consumer (deadlines, filing runtime, overview calendar, wizard, workflow adapters) reads through one of these projection helpers rather than keeping its own profile fact decoding branch.

The projections compose against a fact map (path -> str(value)) derived from the record. Deadline-engine projection uses the domain coercer so field-level coercion logic stays in one place.

facts_to_values(facts, *, schema=None)[source]

Project a tuple of profile facts into the flat selector -> str(value) map.

The flat shape is the selector-keyed mapping consumed by taxpayer_profile_from_mapping() and similar coercers. Each schema field’s model_selectors are honored: a fact at identity.tax_id whose schema declares model_selectors = ["tax.id"] is emitted under the key tax.id. Facts whose path is not in the schema fall through untranslated.

Return type:

dict[str, str]

Parameters:
record_to_values(record, *, schema=None)[source]

Project a live profile record into the selector-keyed flat values mapping.

Parameters:
Return type:

dict[str, str]

snapshot_to_values(snapshot, *, schema=None)[source]

Project an immutable filing snapshot into the selector-keyed flat values mapping.

Return type:

dict[str, str]

Parameters:
record_to_path_values(record)[source]

Project a UserProfileRecord (or snapshot) into a schema-path-keyed string mapping.

Unlike record_to_values() (which projects via the schema’s model_selectors aliases), this keeps the canonical schema path as the key. The mapping is what the wizard catalogue, validate_profile_values(), and CLI status surfaces consume.

Return type:

dict[str, str]

Parameters:

record (UserProfileRecord | UserProfileSnapshot | None)

projection_for_taxpayer(facts, *, tax_id_default='00000000T', iva_regime_default=IVARegime.GENERAL, schema=None)[source]

Return the deadline-engine TaxpayerProfile for the supplied profile facts.

Parameters:
Return type:

TaxpayerProfile

The single coercion path goes through taxpayer_profile_from_mapping() so canonical-token semantics stay in lockstep with the wizard descriptor.