Catch empty currency preference

This commit is contained in:
James Cole 2017-06-05 07:03:32 +02:00
parent 0b47e5d05d
commit f72f8b03df
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -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 = app('amount')->getDefaultCurrency();
return app('amount')->formatAnything($currency, $amount, $coloured);
}, ['is_safe' => ['html']]
);
}