cadrumo.application.aggregation.currency_predicates module¶
Shared currency predicates for aggregation gates.
Used by iva_ledger, renta_ledger,
renta_income_ledger, and renta_gasto_ledger to gate
non-EUR rows and extract effective EUR amounts.
Provides two predicates that replace independent
if transaction.raw.currency != "EUR": ... guards.
- is_non_eur_without_conversion(transaction)[source]¶
Return whether a transaction is foreign-currency with no pre-converted EUR value.
Returns
Trueonly when both conditions hold: - the raw currency is not EUR, AND -value_in_eurisNone(no conversion was applied at import).Aggregation gates use this predicate to decide whether to emit
UNSUPPORTED_CURRENCY. A non-EUR row withvalue_in_eurset can proceed through the gate using the pre-converted amount.- Parameters:
transaction (
Transaction) – The transaction to inspect.- Return type:
- Returns:
Trueif the currency is foreign and no EUR equivalent is available.
- effective_eur_amount(transaction)[source]¶
Return the EUR amount to use for this transaction in casilla projections.
Returns
transaction.value_in_eurfor foreign-currency rows whose conversion was pre-applied at import; otherwise returnstransaction.raw.amount(the native EUR amount for domestic rows).Raises
AggregationConfigErrorwhenis_non_eur_without_conversionisTruefor the row, rather than documenting the precondition and trusting every caller to check it first. An unconverted foreign-currency row has no valid EUR projection to return, and a caller that skipped the gate must fail loud, not foldraw.amountinto a EUR-denominated total in a foreign currency.- Parameters:
transaction (
Transaction) – The transaction whose effective EUR amount is needed.- Return type:
- Returns:
A
decimal.Decimalsuitable for casilla arithmetic.- Raises:
AggregationConfigError – The row is foreign-currency with no EUR conversion applied.
- effective_eur_taxable_base(transaction)[source]¶
Return the EUR-equivalent
taxable_base, orNoneif unset.transaction.taxable_baseis denominated in the row’s NATIVE currency (thegross == base + iva + recargoinvariant reconstitutesraw.amount, nevervalue_in_eur– seedomain.transactions.tests.test_gross_invariant). A converted foreign-currency row must apply the samefx_ratemultiplier import used to derivevalue_in_eurfromraw.amount(raw.amount * fx_rate == value_in_eur), so the base cannot be summed as EUR while still carrying its native-currency figure.Raises the same way
effective_eur_amountdoes when the row is foreign-currency with no conversion applied.- Parameters:
transaction (
Transaction) – The transaction whose EUR-equivalent taxable base is needed.- Return type:
- Returns:
A
decimal.Decimal, orNonewhentaxable_baseis unset.- Raises:
AggregationConfigError – The row is foreign-currency with no EUR conversion applied.
- effective_eur_iva_amount(transaction)[source]¶
Return the EUR-equivalent
iva_amount, orNoneif unset.Same native-currency contract and
fx_rateconversion aseffective_eur_taxable_base(), applied toiva_amount.- Parameters:
transaction (
Transaction) – The transaction whose EUR-equivalent IVA amount is needed.- Return type:
- Returns:
A
decimal.Decimal, orNonewheniva_amountis unset.- Raises:
AggregationConfigError – The row is foreign-currency with no EUR conversion applied.