diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index 487357342b..1e6b5dbb6e 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -432,9 +432,15 @@ class AccountController extends Controller $cache->addProperty($end); $cache->addProperty($account->id); if ($cache->has()) { - return response()->json($cache->get()); // @codeCoverageIgnore + return response()->json($cache->get()); // @codeCoverageIgnore } $currencies = $this->accountRepository->getUsedCurrencies($account); + + // if the account is not expense or revenue, just use the account's default currency. + if (!in_array($account->accountType->type, [AccountType::REVENUE, AccountType::EXPENSE], true)) { + $currencies= [$this->accountRepository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency()]; + } + /** @var TransactionCurrency $currency */ foreach ($currencies as $currency) { $chartData[] = $this->periodByCurrency($start, $end, $account, $currency);