Skip to content

Firefly III: a personal finances manager

Simpler get currency routine

James Colefade9ae6f980
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();