aeat.domain.contribuyente._descendant_facts module

Helpers for persisting and reloading DescendantInfo as profile facts.

DescendantInfo records are stored as individual profile facts under the renta_family.descendiente.{n}.{field} key hierarchy. Aggregate summary facts are derived and stored alongside individual facts so that the registry binding resolver can look them up by a simple profile_key selector.

Stored fact paths per descendant (n = 0-based index):

renta_family.descendiente.{n}.birth_date ISO-8601 date string renta_family.descendiente.{n}.adoption_date ISO-8601 date string or absent renta_family.descendiente.{n}.discapacidad “0” / “33” / “65” or absent renta_family.descendiente.{n}.convivencia “true” / “false” renta_family.descendiente.{n}.custodia_compartida “true” / “false” (absent means False) renta_family.descendiente.{n}.meses_madre_trabajo “0”..”12” (absent means 0) renta_family.descendiente.{n}.gastos_guarderia non-negative integer euros (absent means 0) renta_family.descendiente.{n}.nif NIF string or absent

Aggregate facts stored:

renta_family.descendientes_count int count renta_family.gastos_guarderia_reales_2024 sum of gastos_guarderia for eligible menores-3 (absent when zero)

descendant_facts_from_list(descendientes)[source]

Return a list of (path, canonical-value-string) tuples for all DescendantInfo entries.

The caller converts these to domain.user_profile.UserProfileFact records; this function only computes the canonical key-value pairs.

Return type:

list[tuple[str, str]]

Parameters:

descendientes (Sequence[DescendantInfo])

descendant_list_from_facts(facts)[source]

Reconstruct a tuple of DescendantInfo from a flat profile-fact dict.

facts is a {path: canonical-value-string} mapping. Only renta_family.descendiente.* paths are consumed; all others are ignored.

Entries are sorted by index so the reconstructed tuple preserves the original insertion order.

Return type:

tuple[DescendantInfo, ...]

Returns:

Tuple of DescendantInfo reconstructed from the profile facts.

Parameters:

facts (dict[str, str])

parse_descendiente_flag(raw)[source]

Parse a --descendiente NACIMIENTO=YYYY-MM-DD,... flag value.

Return type:

DescendantInfo

Parameters:

raw (str)

Accepted keys (case-insensitive):

NACIMIENTO=YYYY-MM-DD (required) birth date ADOPCION=YYYY-MM-DD (optional) adoption finalisation date DISCAPACIDAD=0|33|65 (optional) discapacidad grade CONVIVENCIA=true|false (optional, default true) cohabitation flag CUSTODIA=true|false (optional, default false) custodia compartida (Art. 61 LIRPF) MESES_TRABAJO=0..12 (optional, default 0) months mother worked — Art. 81 deducción maternidad GASTOS_GUARDERIA=N (optional, default 0) actual guardería euros — Art. 81 bis incremento 0613 NIF=XXXXXXXXX (optional) NIF/NIE

Returns a validated DescendantInfo. Raises ValueError on missing required keys or invalid values.