aeat.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).Note: callers are responsible for ensuring
is_non_eur_without_conversionreturnsFalsebefore calling this function. An unconverted foreign-currency row would returnraw.amountin a foreign currency, which is not a valid EUR projection.- Parameters:
transaction (
Transaction) – The transaction whose effective EUR amount is needed.- Return type:
- Returns:
A
decimal.Decimalsuitable for casilla arithmetic.