Improved chart for #2938

This commit is contained in:
James Cole
2020-03-20 04:37:45 +01:00
parent 6dba44ba71
commit 7eb2451e3d
5 changed files with 96 additions and 45 deletions

View File

@@ -653,4 +653,20 @@ class AccountRepository implements AccountRepositoryInterface
{
return $account->attachments()->get();
}
/**
* @inheritDoc
*/
public function getUsedCurrencies(Account $account): Collection
{
$info = $account->transactions()->get(['transaction_currency_id', 'foreign_currency_id'])->toArray();
$currencyIds = [];
foreach ($info as $entry) {
$currencyIds[] = (int) $entry['transaction_currency_id'];
$currencyIds[] = (int) $entry['foreign_currency_id'];
}
$currencyIds = array_unique($currencyIds);
return TransactionCurrency::whereIn('id', $currencyIds)->get();
}
}

View File

@@ -47,6 +47,13 @@ interface AccountRepositoryInterface
*/
public function count(array $types): int;
/**
* @param Account $account
*
* @return Collection
*/
public function getUsedCurrencies(Account $account): Collection;
/**
* @param Account $account
*