From f72f8b03dff74c03025a2a897b78a844073bf2a8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 5 Jun 2017 07:03:32 +0200 Subject: [PATCH] Catch empty currency preference --- app/Support/Twig/AmountFormat.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.php index cc4c45dc19..ba7011f902 100644 --- a/app/Support/Twig/AmountFormat.php +++ b/app/Support/Twig/AmountFormat.php @@ -92,13 +92,17 @@ class AmountFormat extends Twig_Extension return new Twig_SimpleFunction( 'formatAmountByAccount', function (AccountModel $account, string $amount, bool $coloured = true): string { $currencyId = intval($account->getMeta('currency_id')); - if ($currencyId === 0) { - // Format using default currency: - return app('amount')->format($amount, $coloured); + + if ($currencyId !== 0) { + $currency = TransactionCurrency::find($currencyId); + + return app('amount')->formatAnything($currency, $amount, $coloured); } - $currency = TransactionCurrency::find($currencyId); + $currency = app('amount')->getDefaultCurrency(); return app('amount')->formatAnything($currency, $amount, $coloured); + + }, ['is_safe' => ['html']] ); }