fix currency

This commit is contained in:
yuri
2018-03-07 11:52:31 +02:00
parent c776150ce0
commit 493ab0396a
4 changed files with 12 additions and 5 deletions

View File

@@ -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();
}

View File

@@ -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")

View File

@@ -28,6 +28,7 @@
************************************************************************/
namespace Espo\Core\Utils\Database\Schema\rebuildActions;
class Currency extends \Espo\Core\Utils\Database\Schema\BaseRebuildActions
{

View File

@@ -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);