Skip to content

Firefly III: a personal finances manager

Fix #9789

James Cole4eb3ce7c148b
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);
},