Code cleanup

This commit is contained in:
James Cole
2024-12-22 08:43:12 +01:00
parent 5751f7e5a3
commit 565bd87959
574 changed files with 4600 additions and 4604 deletions

View File

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