From 4a7d9b130adc23e139cbf3dd60eb08b1b6c4f16b Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 12 Apr 2020 06:23:35 +0200 Subject: [PATCH] Fix issue with multi-currency in asset accounts. --- app/Http/Controllers/Chart/AccountController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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);