aeat.domain.currency._service module¶
Currency normalization service: convert foreign amounts to EUR.
Provides ExchangeRateProvider — the protocol an exchange-rate
backend must implement — and CurrencyNormalizationService, which
applies a provider-supplied rate to produce a NormalizedAmount
(from ._models). When no provider is configured or no rate is
available the service returns a NormalizedAmount with
status = CurrencyNormalizationStatus.MISSING_RATE so callers can
surface a human-readable warning rather than silently propagating a zero
amount into a filing (modelo = an AEAT tax form).
- class ExchangeRateProvider(*args, **kwargs)[source]¶
Bases:
ProtocolProtocol for fetching exchange rates.
- class CurrencyNormalizationService(rate_provider=None)[source]¶
Bases:
objectService to normalize foreign currencies to EUR.
- Parameters:
rate_provider (ExchangeRateProvider | None)
- normalize(amount, rate_date)[source]¶
Normalize an amount to EUR using the rate for the given date.
- Return type:
- Returns:
A
NormalizedAmountwith the EUR-equivalent and conversion metadata.- Parameters:
amount (MonetaryAmount)
rate_date (date)