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’smodel_selectorsare honored: a fact atidentity.tax_idwhose schema declaresmodel_selectors = ["tax.id"]is emitted under the keytax.id. Facts whose path is not in the schema fall through untranslated.- Return type:
- Parameters:
facts (tuple[UserProfileFact, ...])
schema (ProfileSchemaDefinition | None)
- record_to_values(record, *, schema=None)[source]¶
Project a live profile record into the selector-keyed flat values mapping.
- Parameters:
record (
UserProfileRecord) – TheUserProfileRecordto project.schema (
ProfileSchemaDefinition|None) – Optional profile schema definition override.
- Return type:
- snapshot_to_values(snapshot, *, schema=None)[source]¶
Project an immutable filing snapshot into the selector-keyed flat values mapping.
- Return type:
- Parameters:
snapshot (UserProfileSnapshot)
schema (ProfileSchemaDefinition | None)
- 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’smodel_selectorsaliases), 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:
- 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
TaxpayerProfilefor the supplied profile facts.- Parameters:
facts (
Mapping[str,object] |UserProfileRecord|UserProfileSnapshot) – Either aUserProfileRecord, an immutableUserProfileSnapshot, or a pre-projected flat mapping.tax_id_default (
str) – Fallback NIF when the profile carries none.iva_regime_default (
IVARegime) – Fallback IVA regime when the profile carries none.schema (
ProfileSchemaDefinition|None) – Optional profile schema definition override.
- Return type:
The single coercion path goes through
taxpayer_profile_from_mapping()so canonical-token semantics stay in lockstep with the wizard descriptor.