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 True only when both conditions hold: - the raw currency is not EUR, AND - value_in_eur is None (no conversion was applied at import).

Aggregation gates use this predicate to decide whether to emit UNSUPPORTED_CURRENCY. A non-EUR row with value_in_eur set can proceed through the gate using the pre-converted amount.

Parameters:

transaction (Transaction) – The transaction to inspect.

Return type:

bool

Returns:

True if 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_eur for foreign-currency rows whose conversion was pre-applied at import; otherwise returns transaction.raw.amount (the native EUR amount for domestic rows).

Note: callers are responsible for ensuring is_non_eur_without_conversion returns False before calling this function. An unconverted foreign-currency row would return raw.amount in a foreign currency, which is not a valid EUR projection.

Parameters:

transaction (Transaction) – The transaction whose effective EUR amount is needed.

Return type:

Decimal

Returns:

A decimal.Decimal suitable for casilla arithmetic.