mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-04 03:43:07 +00:00
Fix #8276
This commit is contained in:
@@ -57,6 +57,6 @@ return $config->setRules([
|
|||||||
'statement_indentation' => true,
|
'statement_indentation' => true,
|
||||||
'type_declaration_spaces' => false,
|
'type_declaration_spaces' => false,
|
||||||
'cast_spaces' => false,
|
'cast_spaces' => false,
|
||||||
'binary_operator_spaces' => false,
|
'binary_operator_spaces' => false,
|
||||||
])
|
])
|
||||||
->setFinder($finder);
|
->setFinder($finder);
|
||||||
|
@@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
|
|||||||
use FireflyIII\Models\CurrencyExchangeRate;
|
use FireflyIII\Models\CurrencyExchangeRate;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ExchangeRateConverter
|
* Class ExchangeRateConverter
|
||||||
@@ -78,7 +79,9 @@ class ExchangeRateConverter
|
|||||||
$second = $this->getEuroRate($to, $date);
|
$second = $this->getEuroRate($to, $date);
|
||||||
|
|
||||||
// combined (if present), they can be used to calculate the necessary conversion rate.
|
// combined (if present), they can be used to calculate the necessary conversion rate.
|
||||||
if ('0' === $first || '0' === $second) {
|
if (0 === bccomp('0', $first) || 0 === bccomp('0', $second)) {
|
||||||
|
Log::warning(sprintf('$first is "%s" and $second is "%s"', $first, $second));
|
||||||
|
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +115,7 @@ class ExchangeRateConverter
|
|||||||
->orderBy('date', 'DESC')
|
->orderBy('date', 'DESC')
|
||||||
->first()
|
->first()
|
||||||
;
|
;
|
||||||
$rate = (string)$result?->rate;
|
$rate = (string) $result?->rate;
|
||||||
$cache->store($rate);
|
$cache->store($rate);
|
||||||
if ('' === $rate) {
|
if ('' === $rate) {
|
||||||
return null;
|
return null;
|
||||||
@@ -145,7 +148,7 @@ class ExchangeRateConverter
|
|||||||
// grab backup values from config file:
|
// grab backup values from config file:
|
||||||
$backup = config(sprintf('cer.rates.%s', $currency->code));
|
$backup = config(sprintf('cer.rates.%s', $currency->code));
|
||||||
if (null !== $backup) {
|
if (null !== $backup) {
|
||||||
return bcdiv('1', (string)$backup);
|
return bcdiv('1', (string) $backup);
|
||||||
// app('log')->debug(sprintf('Backup rate for %s to EUR is %s.', $currency->code, $backup));
|
// app('log')->debug(sprintf('Backup rate for %s to EUR is %s.', $currency->code, $backup));
|
||||||
// return $backup;
|
// return $backup;
|
||||||
}
|
}
|
||||||
@@ -162,7 +165,7 @@ class ExchangeRateConverter
|
|||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty('cer-euro-id');
|
$cache->addProperty('cer-euro-id');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return (int)$cache->get();
|
return (int) $cache->get();
|
||||||
}
|
}
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||||
if (null === $euro) {
|
if (null === $euro) {
|
||||||
|
Reference in New Issue
Block a user