FINANCIAL ENGINE
Multi-Currency Support
Invenicum supports multi-currency inventory management with automatic currency conversion and real-time exchange rates.
Overview
The system allows you to store asset values in a unified base currency (USD) while displaying them in any preferred global currency.
Base Currency
All prices are stored as USD in the database for consistency.
Auto Conversion
Prices are converted on-the-fly using cached exchange rates.
How It Works
Base
USD internal storage
Display
User-selected preference
Logic
On-the-fly conversion
Rates
Fetched from backend
Setting Your Currency
- 1. Navigate to Settings: Open Settings → General Settings.
- 2. Select Currency: Locate the Currency section and click the dropdown.
- 3. Supported Currencies: Choose from USD, EUR (€), GBP (£), JPY (¥), MXN ($), and more.
- 4. Exchange Rate: View the current rate (e.g.,
1 USD = 0.92 EUR) immediately after selection.
Currency Configuration
User Preferences Model
Defined in lib/data/models/user_preferences.dart:6.
class UserPreferences {
final String currency; // ‘USD’, ‘EUR’, etc.
final Map<String, double>? exchangeRates;
UserPreferences({this.currency = ‘USD’, this.exchangeRates});
}
Exchange Rates Payload
{ “EUR”: 0.92, “GBP”: 0.79, “JPY”: 149.50, “MXN”: 17.25 }
Price Conversion Logic
Automatic Conversion
Handled by PreferencesProvider (lib/providers/preferences_provider.dart).
double convertPrice(double amount) {
final rates = _prefs.exchangeRates;
final selectedCurrency = _prefs.currency;
if (selectedCurrency == ‘USD’ || rates == null) return amount;
final double rate = rates[selectedCurrency] ?? 1.0;
return amount * rate;
}
Display Components
Consistent formatting via PriceDisplayWidget.
PriceDisplayWidget(
value: item.marketValue, // USD from DB
fontSize: 16,
color: Colors.green,
) // Output: ”€ 92.00”
Currency Symbols Mapping
| Code | Symbol | Name |
|---|---|---|
| USD | $ | US Dollar |
| EUR | € | Euro |
| GBP | £ | British Pound |
| JPY | ¥ | Japanese Yen |
| MXN | $ | Mexican Peso |
| BRL | R$ | Brazilian Real |
| INR | ₹ | Indian Rupee |
Implementation Details
Price History & Charts
Charts in price_history_chart_widget.dart respect the user’s currency selection for axes and data points.
Custom Fields
Custom fields of type price are automatically prefixed with the active symbol and converted during the editing process.
Backend Synchronization
Preferences are synced via PUT /api/v1/preferences/currency.
Future<void> updateCurrency(String currencyCode) async {
await _dio.put(‘/preferences/currency’, data: {‘currency’: currencyCode});
}
Localization
Relevant keys in lib/l10n/app_en.arb:
Best Practices
Consistent Storage: Database always store prices in USD to simplify global aggregation and reporting.
Rate Updates: Ensure the backend pulls from a reliable provider (e.g., Open Exchange Rates) to update the cached rates.
Price Entry: Users enter prices in their local currency; the app converts to USD before transmission.