Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix null pointer in account format.
James Cole9f8c75efc6ba
diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.phpindex 9d78bd8dfe..89ff951b5b 100644--- a/app/Support/Twig/AmountFormat.php+++ b/app/Support/Twig/AmountFormat.php@@ -24,6 +24,8 @@ namespace FireflyIII\Support\Twig;use FireflyIII\Models\Account as AccountModel;use FireflyIII\Models\TransactionCurrency;+use FireflyIII\Repositories\Account\AccountRepositoryInterface;+use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;use Twig_Extension;use Twig_SimpleFilter;use Twig_SimpleFunction;@@ -82,14 +84,19 @@ class AmountFormat extends Twig_Extensionreturn new Twig_SimpleFunction('formatAmountByAccount',function (AccountModel $account, string $amount, bool $coloured = true): string {- $currencyId = intval($account->getMeta('currency_id'));-+ /** @var AccountRepositoryInterface $accountRepos */+ $accountRepos = app(AccountRepositoryInterface::class);+ /** @var CurrencyRepositoryInterface $currencyRepos */+ $currencyRepos = app(CurrencyRepositoryInterface::class);+ $currency = app('amount')->getDefaultCurrency();+ $currencyId = (int)$accountRepos->getMetaValue($account, 'currency_id');+ $accountCurrency = nullif (0 !== $currencyId) {- $currency = TransactionCurrency::find($currencyId);-- return app('amount')->formatAnything($currency, $amount, $coloured);+ $accountCurrency = $currencyRepos->findNull($currencyId);+ }+ if (null !== $accountCurrency) {+ $currency = $accountCurrency;}- $currency = app('amount')->getDefaultCurrency();return app('amount')->formatAnything($currency, $amount, $coloured);},