cadrumo.domain.calculations.registry.convenio module¶
Cross-cutting Convenio doble imposición (CDI) treaty-override authority.
A development compiler reads the registry authoring surface into the immutable
artifact. This runtime module retains only the resulting treaty authority types
that any IRNR rate formula consumes through the
RegistrySnapshot — so a second consumer
(M216 retenciones a no residentes) reads treaty data without reaching across a
modelo boundary.
Each override row carries a typed ConvenioOverrideKind so the
“más favorable” / limitation-of-benefits decision is computed rather than
coincidental: flat replaces the domestic rate, ceiling applies
min(domestic, treaty), allocation_domestic_tariff delegates the amount to
the domestic tariff, and exempt drives the source-state rate to zero.
- class ConvenioOverrideRow(**data)[source]¶
Bases:
RegistryModelOne per-income-type treaty override keyed by
TipoRentaIrnr.The typed
ConvenioOverrideKinddecides how the row acts on the domestic IRNR rate.flatandceilingrows MUST declare aratein[0, 1];allocation_domestic_tariffandexemptrows MUST NOT (the amount is delegated to the domestic tariff or driven to zero). Thelegal_ref_anchorMUST be one of the row’slegal_refsand resolve to a treaty article in the sharedlegal/catalogue.- Parameters:
tipo_renta (TipoRentaIrnr)
kind (ConvenioOverrideKind)
rate (str | None)
legal_ref_anchor (LegalRefId)
legal_refs (tuple[LegalRefId, ...])
notes (str | None)
valid_from (date)
valid_to (date | None)
- tipo_renta: TipoRentaIrnr¶
- kind: ConvenioOverrideKind¶
- rate: str | None¶
- legal_ref_anchor: LegalRefId¶
- legal_refs: tuple[LegalRefId, ...]¶
- notes: str | None¶
- valid_from: date¶
- valid_to: date | None¶
- class ConvenioTreaty(**data)[source]¶
Bases:
RegistryModelOne bilateral double-taxation treaty and its per-income-type overrides.
Projected from the canonical
irnr.convenio.overridegoverned fact and keyed by the counterpartcountry_code(ISO 3166-1 alpha-2). The optional permanent-establishment / employment-income surfaces are deliberately not modelled yet; the schema leaves room for them without foreclosing.- Parameters:
country_code (str)
document_id (str)
overrides (tuple[ConvenioOverrideRow, ...])
notes (str | None)
- country_code: str¶
- document_id: str¶
- overrides: tuple[ConvenioOverrideRow, ...]¶
- notes: str | None¶
- class ConvenioOverride(**data)[source]¶
Bases:
RegistryModelThe resolved treaty override returned by
ConvenioAuthority.resolve().A flat projection of the matched
ConvenioOverrideRowbound to its treaty’scountry_codeanddocument_id— the shape the IRNR rate op and the modelo verification sweep branch on.rateis populated only for the rate-bearing kinds (flat/ceiling).- Parameters:
data (Any)
- country_code: str¶
- document_id: str¶
- tipo_renta: TipoRentaIrnr¶
- kind: ConvenioOverrideKind¶
- rate: Decimal | None¶
- legal_refs: tuple[LegalRefId, ...]¶
- class ConvenioAuthority(**data)[source]¶
Bases:
RegistryModelThe compiled cross-cutting treaty authority projected onto every snapshot.
Owns the
{country_code: ConvenioTreaty}map and the singleresolve()lookup any IRNR rate formula consumes. Projected onto theRegistrySnapshotthe same way the sharedlegal/catalogue is, so the treaty override is one branch of the single tipo-de-gravamen resolution path, never a parallel rate mechanism.- Parameters:
treaties (Annotated[Mapping[str, ConvenioTreaty], <cadrumo.core.frozen_mapping.FrozenMappingMarker object at 0x7f8c00a93860>])
- treaties: Annotated[Mapping[str, ConvenioTreaty], FROZEN_MAPPING]¶
- classmethod empty()[source]¶
Return a
ConvenioAuthoritywith no treaties (the no-override default).- Return type:
- resolve(country_code, tipo_renta, year)[source]¶
Return the
ConvenioOverridefor(country_code, tipo_renta, year), orNone.Nonemeans no treaty row applies — the caller keeps the domestic baseline (no country declared) or raises the missing-row BLOCKING sentinel (a treaty country was declared but carries no row for the filed income type), never a silent blank.- Return type:
- Parameters:
country_code (str)
tipo_renta (TipoRentaIrnr)
year (int)
- class ResolvedConvenioOverride(kind, rate, country_code, document_id, fact)[source]¶
Bases:
objectOne provider-selected treaty override with legal provenance.
- Parameters:
kind (ConvenioOverrideKind)
rate (Decimal | None)
country_code (str)
document_id (str)
fact (ResolvedOverrideFact)
-
kind:
ConvenioOverrideKind¶
-
fact:
ResolvedOverrideFact¶
- resolve_convenio_override(*, country_code, tipo_renta, devengo_date, operation)[source]¶
Resolve and validate the exact dated treaty fact, or return no row.
Registry corruption, an ambiguous selection, unsupported payloads, and missing legal provenance remain registry refusals. Only the absence of a matching dated selector is represented by
None.- Return type:
- Parameters:
country_code (str)
tipo_renta (TipoRentaIrnr)
devengo_date (date)
operation (PinnedAuthorityOperation)