loadCurrencies function

Future<void> loadCurrencies(
  1. RestClient restClient
)

Load currencies from the backend via the UOM list service. Replaces the global currencies list with all available currencies. Safe to call multiple times — subsequent calls are no-ops.

Implementation

Future<void> loadCurrencies(RestClient restClient) async {
  if (_currenciesLoaded) return;
  try {
    final uoms = await restClient.getUom(['UT_CURRENCY_MEASURE']);
    if (uoms.uoms.isNotEmpty) {
      currencies = uoms.uoms
          .map(
            (uom) =>
                Currency(currencyId: uom.uomId, description: uom.description),
          )
          .toList();
      _currenciesLoaded = true;
    }
  } catch (_) {
    // Keep the fallback list on failure
  }
}