Coverage for src/backend/InvenTree/plugin/base/integration/CurrencyExchangeMixin.py: 90%
10 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
1"""Plugin mixin class for supporting currency exchange data."""
3from plugin import PluginMixinEnum
4from plugin.helpers import MixinNotImplementedError
7class CurrencyExchangeMixin:
8 """Mixin class which provides support for currency exchange rates.
10 Nominally this plugin mixin would be used to interface with an external API,
11 to periodically retrieve currency exchange rate information.
13 The plugin class *must* implement the update_exchange_rates method,
14 which is called periodically by the background worker thread.
15 """
17 class MixinMeta:
18 """Meta options for this mixin class."""
20 MIXIN_NAME = 'CurrentExchange'
22 def __init__(self):
23 """Register the mixin."""
24 super().__init__()
25 self.add_mixin(PluginMixinEnum.CURRENCY_EXCHANGE, True, __class__)
27 def update_exchange_rates(self, base_currency: str, symbols: list[str]) -> dict:
28 """Update currency exchange rates.
30 This method *must* be implemented by the plugin class.
32 Arguments:
33 base_currency: The base currency to use for exchange rates
34 symbols: A list of currency symbols to retrieve exchange rates for
36 Returns:
37 A dictionary of exchange rates, or None if the update failed
39 Raises:
40 Can raise any exception if the update fails
41 """
42 raise MixinNotImplementedError(
43 'Plugin must implement update_exchange_rates method'
44 )