mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup
This commit is contained in:
@@ -39,21 +39,11 @@ class ExchangeRateConverter
|
||||
{
|
||||
// use ConvertsExchangeRates;
|
||||
private array $fallback = [];
|
||||
private bool $ignoreSettings = false;
|
||||
private bool $isPrepared = false;
|
||||
private bool $noPreparedRates = false;
|
||||
private array $prepared = [];
|
||||
private int $queryCount = 0;
|
||||
private bool $ignoreSettings = false;
|
||||
|
||||
public function setIgnoreSettings(bool $ignoreSettings): void
|
||||
{
|
||||
$this->ignoreSettings = $ignoreSettings;
|
||||
}
|
||||
|
||||
public function enabled(): bool
|
||||
{
|
||||
return false !== config('cer.enabled') || true === $this->ignoreSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
@@ -70,6 +60,11 @@ class ExchangeRateConverter
|
||||
return bcmul($amount, $rate);
|
||||
}
|
||||
|
||||
public function enabled(): bool
|
||||
{
|
||||
return false !== config('cer.enabled') || true === $this->ignoreSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
@@ -138,6 +133,11 @@ class ExchangeRateConverter
|
||||
return $rate;
|
||||
}
|
||||
|
||||
private function getCacheKey(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): string
|
||||
{
|
||||
return sprintf('cer-%d-%d-%s', $from->id, $to->id, $date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
private function getFromDB(int $from, int $to, string $date): ?string
|
||||
{
|
||||
if ($from === $to) {
|
||||
@@ -338,6 +338,11 @@ class ExchangeRateConverter
|
||||
Log::debug(sprintf('Fallback rate %s > %s = %s', $to->code, $from->code, bcdiv('1', $fallback)));
|
||||
}
|
||||
|
||||
public function setIgnoreSettings(bool $ignoreSettings): void
|
||||
{
|
||||
$this->ignoreSettings = $ignoreSettings;
|
||||
}
|
||||
|
||||
public function summarize(): void
|
||||
{
|
||||
if (false === $this->enabled()) {
|
||||
@@ -345,9 +350,4 @@ class ExchangeRateConverter
|
||||
}
|
||||
Log::debug(sprintf('ExchangeRateConverter ran %d queries.', $this->queryCount));
|
||||
}
|
||||
|
||||
private function getCacheKey(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): string
|
||||
{
|
||||
return sprintf('cer-%d-%d-%s', $from->id, $to->id, $date->format('Y-m-d'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user