diff --git a/application/Espo/Controllers/Settings.php b/application/Espo/Controllers/Settings.php index 34e4124ae1..c3d7ad622d 100644 --- a/application/Espo/Controllers/Settings.php +++ b/application/Espo/Controllers/Settings.php @@ -90,11 +90,9 @@ class Settings extends \Espo\Core\Controllers\Base throw new Error('Cannot save settings'); } - /** Rebuild for Currency Settings */ - if (isset($data->baseCurrency) || isset($data->currencyRates)) { + if (isset($data->defaultCurrency) || isset($data->baseCurrency) || isset($data->currencyRates)) { $this->getContainer()->get('dataManager')->rebuildDatabase([]); } - /** END Rebuild for Currency Settings */ return $this->getConfigData(); } diff --git a/application/Espo/Core/Export/Xlsx.php b/application/Espo/Core/Export/Xlsx.php index 6082ce24fe..868daf4120 100644 --- a/application/Espo/Core/Export/Xlsx.php +++ b/application/Espo/Core/Export/Xlsx.php @@ -303,7 +303,7 @@ class Xlsx extends \Espo\Core\Injectable } } else if ($type == 'currencyConverted') { if (array_key_exists($name, $row)) { - $currency = $this->getConfig()->get('baseCurrency'); + $currency = $this->getConfig()->get('defaultCurrency'); $currencySymbol = $this->getMetadata()->get(['app', 'currency', 'symbolMap', $currency], ''); $sheet->getStyle("$col$rowNumber") diff --git a/application/Espo/Core/Utils/Database/Schema/rebuildActions/Currency.php b/application/Espo/Core/Utils/Database/Schema/rebuildActions/Currency.php index dde6c13a6b..723d23ef58 100644 --- a/application/Espo/Core/Utils/Database/Schema/rebuildActions/Currency.php +++ b/application/Espo/Core/Utils/Database/Schema/rebuildActions/Currency.php @@ -28,6 +28,7 @@ ************************************************************************/ namespace Espo\Core\Utils\Database\Schema\rebuildActions; + class Currency extends \Espo\Core\Utils\Database\Schema\BaseRebuildActions { diff --git a/client/src/views/settings/fields/currency-rates.js b/client/src/views/settings/fields/currency-rates.js index 5c9ecd37f2..673e24bd55 100644 --- a/client/src/views/settings/fields/currency-rates.js +++ b/client/src/views/settings/fields/currency-rates.js @@ -38,7 +38,15 @@ Espo.define('views/settings/fields/currency-rates', 'views/fields/base', functio var rateValues = {}; (this.model.get('currencyList') || []).forEach(function (currency) { if (currency != baseCurrency) { - rateValues[currency] = currencyRates[currency] || 1.00; + rateValues[currency] = currencyRates[currency]; + if (!rateValues[currency]) { + if (currencyRates[baseCurrency]) { + rateValues[currency] = Math.round(1 / currencyRates[baseCurrency] * 1000) / 1000; + } + if (!rateValues[currency]) { + rateValues[currency] = 1.00 + } + } } }, this);