From 4eb3ce7c148b3dacafbfd0adb37307fb1dafa4e6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 7 Feb 2025 05:26:03 +0100 Subject: [PATCH] Fix #9789 --- app/Support/Twig/AmountFormat.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.php index 278b2ea12c..874d4fb9fa 100644 --- a/app/Support/Twig/AmountFormat.php +++ b/app/Support/Twig/AmountFormat.php @@ -26,6 +26,8 @@ namespace FireflyIII\Support\Twig; use FireflyIII\Models\Account as AccountModel; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Account\AccountRepositoryInterface; +use FireflyIII\Support\Facades\Amount; +use Illuminate\Support\Facades\Log; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; use Twig\TwigFunction; @@ -114,6 +116,11 @@ class AmountFormat extends AbstractExtension /** @var TransactionCurrency $currency */ $currency = TransactionCurrency::whereCode($code)->first(); + if(null === $currency) { + Log::error(sprintf('Could not find currency with code "%s". Fallback to native currency.', $code)); + $currency = Amount::getNativeCurrency(); + Log::error(sprintf('Fallback currency is "%s".', $currency->code)); + } return app('amount')->formatAnything($currency, $amount, $coloured); },