aeat.domain.fincas._aggregates module¶
Rental-register aggregate calculations.
compute_finca_aggregates() pulls per-finca and per-contract data from the
rental register repositories for a given ejercicio and returns a
FincaAggregates result with FincaAttribution and
ContractTierAttribution audit breakdowns for factual LIRPF rental amounts:
gross rent collected from active contracts.
deductible expenses after the art. 23.1 cap.
amortization under art. 23.1.f.
residential rental reduction under art. 23.2.
real-estate imputation under art. 85.
Filing targets are registry-owned; this module does not encode filing-line identifiers.
- class FincaAttribution(**data)[source]¶
Bases:
BaseModelPer-finca contribution to rental aggregate totals.
- Parameters:
- finca_id: int¶
- finca_identifier: str¶
- ingresos: Decimal¶
- gastos_deducibles: Decimal¶
- amortizacion: Decimal¶
- reduccion_total: Decimal¶
- imputacion: Decimal¶
- class ContractTierAttribution(**data)[source]¶
Bases:
BaseModelPer-contract tier resolution + reducción amount.
- Parameters:
contract_id (int)
finca_id (int)
rendimiento_neto_positivo (Decimal)
tier (TierResolution)
reduccion_amount (Decimal)
- contract_id: int¶
- finca_id: int¶
- rendimiento_neto_positivo: Decimal¶
- tier: TierResolution¶
- reduccion_amount: Decimal¶
- class FincaAggregates(**data)[source]¶
Bases:
BaseModelDerived rental aggregates plus audit attribution.
- Variables:
period_year – Ejercicio.
ingresos_integros – Sum of rental income.
gastos_deducibles – Sum of deductible expenses per LIRPF art. 23.1 (capped + uncapped + consumed carry-forward).
amortizacion – Sum of amortization per LIRPF art. 23.1.f.
reduccion_arrendamiento_vivienda – Sum of art. 23.2 reduction.
imputacion_rentas_inmobiliarias – Sum of art. 85 imputation.
per_finca_attribution – Per-finca breakdown of the above.
per_contract_tier – Per-contract tier resolution + reducción amount.
- Parameters:
- period_year: int¶
- ingresos_integros: Decimal¶
- gastos_deducibles: Decimal¶
- amortizacion: Decimal¶
- reduccion_arrendamiento_vivienda: Decimal¶
- imputacion_rentas_inmobiliarias: Decimal¶
- per_finca_attribution: Mapping[int, FincaAttribution]¶
- per_contract_tier: Mapping[int, ContractTierAttribution]¶
- compute_finca_aggregates(*, period_year, finca_repo, contract_repo, income_repo, expense_repo, ledger_repo)[source]¶
Aggregate factual rental amounts from the rental register.
- Parameters:
period_year (
int) – Ejercicio whose rental amounts to compute.finca_repo (
FincaReader) – LiveFincaReader.contract_repo (
ArrendamientoReader) – LiveArrendamientoReader.income_repo (
FincaRendimientoReader) – LiveFincaRendimientoReader.expense_repo (
FincaGastoReader) – LiveFincaGastoReader.ledger_repo (
FincaAmortizacionLedgerReader) – LiveFincaAmortizacionLedgerReader.
- Return type:
- Returns:
FincaAggregatescarrying the derived rental totals and attribution maps for audit traceability.- Raises:
FincaAggregationError – When a contract references a missing finca, or when the ledger surfaces an inconsistent cumulative entry.