From b561e79a6c7e862fc7e20891576625cb6ac92bf2 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 8 Apr 2018 16:21:17 +0200 Subject: [PATCH] Catch null in currency pref. [skip ci] --- app/Http/Controllers/Chart/AccountController.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index cca8691431..2ecbddb591 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -439,13 +439,14 @@ class AccountController extends Controller /** @var CurrencyRepositoryInterface $repository */ $repository = app(CurrencyRepositoryInterface::class); - $chartData = []; + $default = app('amount')->getDefaultCurrency(); + $chartData = []; foreach ($accounts as $account) { - Log::debug(sprintf('Now at account #%d', $account->id)); - Log::debug(sprintf('Currency preference is: %d', (int)$account->getMeta('currency_id'))); - $currency = $repository->findNull((int)$account->getMeta('currency_id')); - Log::debug(sprintf('Currency is null? %s', var_export($currency === null, true))); - $currentSet = [ + $currency = $repository->findNull((int)$account->getMeta('currency_id')); + if (null === $currency) { + $currency = $default; + } + $currentSet = [ 'label' => $account->name, 'currency_symbol' => $currency->symbol, 'entries' => [],