cadrumo.domain.transactions.retencion_facts module¶
Registry-backed loaders for withholding parameter facts.
The rate families and their legal applicability are authored in source-cited
governed-fact fragments under registry/aeat/facts. Python consumers read
the selected values from the validated authority rather than restating a
figure, category, or legal rule in this adapter. Separate legal declarations
remain only for consumers that have not yet migrated.
The loaders resolve typed scalar facts through ValidatedRegistryAuthority
at an explicit filing-period coordinate, then project only the values needed
by their frozen pydantic records. The authority owns validation, fingerprinting
and lifecycle identity; this module keeps neither a legacy parser nor
a local value cache.
The activity-rate projection supplies a governed upper bound for bounded inference, while the administrator projection supplies the selected rate and turnover condition for an advisory comparison. This module performs only authority resolution, typed projection, and generic numeric validation; it does not choose a legal category for a transaction.
See also
domain.iva.componentsDeclares, per IVA category, whether a retención is expected at all.
domain.iva.recargo_equivalenciaThe loader idiom this module follows.
- class RirpfArt95RetencionRates(**data)[source]¶
Bases:
BaseModelFrozen projection of the authority’s activity withholding rates.
- Variables:
activity (Each field is a named projection of one registry-declared)
contract; (withholding family. The field names preserve the consumer)
in (the selected values, legal references, and applicability remain)
authority. (the registry)
- Parameters:
data (Any)
- general_rate: Decimal¶
- inicio_actividad_rate: Decimal¶
- agricola_ganadera_rate: Decimal¶
- ganadera_engorde_rate: Decimal¶
- forestal_rate: Decimal¶
- estimacion_objetiva_rate: Decimal¶
- retencion_effective_date(*, value_date, booked_date)[source]¶
Return the settlement date that selects a transaction’s withholding facts.
A bank’s value date records when the payment became effective and therefore takes precedence. Some providers do not supply it; their booked date is the recorded settlement coordinate. No wall-clock fallback is lawful here: a row with neither dated payment fact is unsupported and must not select a rate from a different legal period.
- load_retencion_actividades_rates(*, effective_date, authority=None)[source]¶
Return the authority-selected activity withholding rates.
- Return type:
- Returns:
A
RirpfArt95RetencionRatesrecord with every rate value.- Raises:
TransactionValidationError – If any expected fact id is absent, carries no string value, or does not parse as a
Decimal, or if fact authority cannot be resolved.- Parameters:
effective_date (date)
authority (GovernedFactSource | None)
- rirpf_art95_retencion_legal_refs(*, effective_date, authority=None)[source]¶
Return legal references grounding the selected activity-rate set.
Read off the facts this module already resolves rather than restated here, which is the whole point: an advisory that names an article from a Python literal asserts law the registry cannot confirm it still says, while one carrying the fact’s own refs moves with the registry.
- Return type:
- Returns:
The distinct reference ids, in first-seen order so the sequence is stable for an operator comparing two runs.
- Parameters:
effective_date (date)
authority (GovernedFactSource | None)
- statutory_activity_retencion_rates(*, effective_date, authority=None)[source]¶
Return every distinct authority-declared activity withholding rate.
Distinct values are returned because callers use this surface only for arithmetic matching. A consumer that needs the governing category must resolve the named registry fact instead; this set deliberately discards that legal selection.
- Return type:
- Returns:
The distinct rates selected by the registry for the date.
- Parameters:
effective_date (date)
authority (GovernedFactSource | None)
- professional_activity_retencion_rates(*, effective_date, authority=None)[source]¶
Return the authority-declared professional-classified rates.
This projection is separate because consumers assign different confidence to a match by registry classification. The classification itself remains registry-owned.
- Return type:
- Returns:
The registry-declared professional rate subset.
- Parameters:
effective_date (date)
authority (GovernedFactSource | None)
- maximum_supported_activity_retencion_rate(*, effective_date, authority=None)[source]¶
Return the authority-selected upper bound for amount inference.
The inference refuses a result above the selected authority bound rather than persisting a fabricated withholding.
- Return type:
- Returns:
The maximum retención rate the activity inference will accept.
- Parameters:
effective_date (date)
authority (GovernedFactSource | None)
- class AdministradorRetencionRates(**data)[source]¶
Bases:
BaseModelFrozen projection of authority-selected administrator withholding data.
- Variables:
rate (general_rate and reduced_rate are authority-selected)
turnover (projections; reduced_incn_threshold_eur is the selected)
registry (condition. Their values and legal applicability remain in)
facts.
- Parameters:
data (Any)
- general_rate: Decimal¶
- reduced_rate: Decimal¶
- reduced_incn_threshold_eur: Decimal¶
- load_administrador_retencion_rates(*, effective_date, authority=None)[source]¶
Return authority-selected administrator withholding data.
- Return type:
- Returns:
An
AdministradorRetencionRatesrecord with every rate value.- Raises:
TransactionValidationError – If any expected fact id is absent, carries no string value, or does not parse as a
Decimal, or if fact authority cannot be resolved.- Parameters:
effective_date (date)
authority (GovernedFactSource | None)
- administrador_retencion_legal_refs(*, effective_date, authority=None)[source]¶
Return legal references grounding the administrator-rate set.
Read off the facts this module already resolves rather than restated here, for the same reason
rirpf_art95_retencion_legal_refs()states: an advisory that names an article from a Python literal asserts law the registry cannot confirm it still says, while one carrying the fact’s own refs moves with the registry.- Return type:
- Returns:
The distinct reference ids, in first-seen order so the sequence is stable for an operator comparing two runs.
- Parameters:
effective_date (date)
authority (GovernedFactSource | None)