aeat.application.aggregation._business_proportion module

Shared BUSINESS / MIXED business-proportion dispatch.

Centralises business proportion dispatch: four aggregation sites (_iva_ledger, _renta_ledger, _renta_income_ledger, and _renta_gasto_ledger) each carry the same dispatch shape:

if classification is BusinessClassification.BUSINESS:
    return Decimal("1")  # or the unit-scaled amount
if classification is BusinessClassification.MIXED:
    assert business_pct is not None
    return business_pct  # or amount * business_pct
return None

This module centralises the proportion lookup so every call site uses one canonical mapping; the per-site multiplication into an amount stays local because the unit semantics differ (IVA ledger returns a bare proportion; renta sites return amount * proportion).

business_proportion(classification, business_pct)[source]

Return the BUSINESS / MIXED dispatch proportion, or None.

  • BUSINESSDecimal("1") (the whole row is deductible / business-attributable).

  • MIXED with a business_pct set → business_pct.

  • MIXED with business_pct=NoneNone (caller treats as not-yet-classified; preflight surfaces the gap separately via MISSING_PROPORTIONALITY_REFERENCE).

  • Any other classification (e.g. PERSONAL, NOT_YET_PROCESSED) → None.

Return type:

Decimal | None

Parameters: