Skip to content

EspoCRM – Open Source CRM Application

Currency rate fallback

Yuriif31b501bdbf9
diff --git a/application/Espo/Core/ORM/QueryComposer/Part/FunctionConverters/CurrencyRate.php b/application/Espo/Core/ORM/QueryComposer/Part/FunctionConverters/CurrencyRate.php
index 4dcf0f8125..fd93919de9 100644
--- a/application/Espo/Core/ORM/QueryComposer/Part/FunctionConverters/CurrencyRate.php
+++ b/application/Espo/Core/ORM/QueryComposer/Part/FunctionConverters/CurrencyRate.php
@@ -80,7 +80,10 @@ class CurrencyRate implements FunctionConverter
*/
private function exchangeRates(string $baseCurrency, string $defaultCurrency, array $currencyRates): array
{
- $defaultCurrencyRate = round(1 / $currencyRates[$defaultCurrency], self::PRECISION);
+ // Not supposed to happen. If the default currency is not listed in the currency list.
+ $defaultNormalRate = $currencyRates[$defaultCurrency] ?? 1.0;
+
+ $defaultCurrencyRate = round(1 / $defaultNormalRate, self::PRECISION);
$exchangedRates = [];
$exchangedRates[$baseCurrency] = $defaultCurrencyRate;