mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Is now capable of updating transactions over the API.
This commit is contained in:
@@ -265,16 +265,13 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*/
|
||||
public function findCurrency(?int $currencyId, ?string $currencyCode): TransactionCurrency
|
||||
{
|
||||
Log::debug('Now in findCurrency()');
|
||||
$result = $this->find((int)$currencyId);
|
||||
if (null === $result) {
|
||||
Log::debug(sprintf('Searching for currency with code %s...', $currencyCode));
|
||||
$result = $this->findByCode((string)$currencyCode);
|
||||
}
|
||||
$result = $this->findCurrencyNull($currencyId, $currencyCode);
|
||||
|
||||
if (null === $result) {
|
||||
Log::debug('Grabbing default currency for this user...');
|
||||
$result = app('amount')->getDefaultCurrencyByUser($this->user);
|
||||
}
|
||||
|
||||
if (null === $result) {
|
||||
Log::debug('Grabbing EUR as fallback.');
|
||||
$result = $this->findByCode('EUR');
|
||||
@@ -288,6 +285,30 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find by object, ID or code. Returns NULL if nothing found.
|
||||
*
|
||||
* @param int|null $currencyId
|
||||
* @param string|null $currencyCode
|
||||
*
|
||||
* @return TransactionCurrency|null
|
||||
*/
|
||||
public function findCurrencyNull(?int $currencyId, ?string $currencyCode): ?TransactionCurrency
|
||||
{
|
||||
Log::debug('Now in findCurrencyNull()');
|
||||
$result = $this->find((int)$currencyId);
|
||||
if (null === $result) {
|
||||
Log::debug(sprintf('Searching for currency with code %s...', $currencyCode));
|
||||
$result = $this->findByCode((string)$currencyCode);
|
||||
}
|
||||
if (null !== $result && false === $result->enabled) {
|
||||
Log::debug(sprintf('Also enabled currency %s', $result->code));
|
||||
$this->enable($result);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find by ID, return NULL if not found.
|
||||
* Used in Import Currency!
|
||||
|
Reference in New Issue
Block a user