From fade9ae6f9804f05160dce28af15ce195cd97fe7 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 27 Jul 2020 07:06:44 +0200 Subject: [PATCH] Simpler get currency routine --- app/Http/Controllers/JavascriptController.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php index 1384e541b1..7d02153055 100644 --- a/app/Http/Controllers/JavascriptController.php +++ b/app/Http/Controllers/JavascriptController.php @@ -132,16 +132,9 @@ class JavascriptController extends Controller public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response { $account = $repository->findNull((int) $request->get('account')); - $currencyId = 0; - if (null !== $account) { - // TODO we can use getAccountCurrency() instead - $currencyId = (int) $repository->getMetaValue($account, 'currency_id'); - } - /** @var TransactionCurrency $currency */ - $currency = $currencyRepository->findNull($currencyId); - if (null === $currency) { - /** @var TransactionCurrency $currency */ - $currency = app('amount')->getDefaultCurrency(); + $currency = app('amount')->getDefaultCurrency(); + if(null !== $account) { + $currency = $repository->getAccountCurrency($account) ?? $currency; } $localeconv = app('amount')->getLocaleInfo();