Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Account list is capable of showing the selected currency
James Cole89ee9c058a03
diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.phpindex 7a9e9d68d6..58952a3301 100644--- a/app/Providers/FireflyServiceProvider.php+++ b/app/Providers/FireflyServiceProvider.php@@ -43,6 +43,7 @@ use FireflyIII\Support\FireflyConfig;use FireflyIII\Support\Navigation;use FireflyIII\Support\Preferences;use FireflyIII\Support\Steam;+use FireflyIII\Support\Twig\Account;use FireflyIII\Support\Twig\General;use FireflyIII\Support\Twig\Journal;use FireflyIII\Support\Twig\PiggyBank;@@ -77,6 +78,7 @@ class FireflyServiceProvider extends ServiceProviderTwig::addExtension(new Translation);Twig::addExtension(new Transaction);Twig::addExtension(new Rule);+ Twig::addExtension(new Account);}/**diff --git a/app/Support/Twig/Account.php b/app/Support/Twig/Account.phpnew file mode 100644index 0000000000..d2a5520505--- /dev/null+++ b/app/Support/Twig/Account.php@@ -0,0 +1,63 @@+<?php+/**+ * Account.php+ * Copyright (c) 2017 [email protected]+ * This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.+ *+ * See the LICENSE file for details.+ */++declare(strict_types=1);++namespace FireflyIII\Support\Twig;+++use FireflyIII\Models\Account as AccountModel;+use FireflyIII\Models\TransactionCurrency;+use FireflyIII\Support\Facades\Amount as AmountFacade;+use Twig_Extension;+use Twig_SimpleFunction;++/**+ * Class Account+ *+ * @package FireflyIII\Support\Twig+ */+class Account extends Twig_Extension+{++ /**+ * {@inheritDoc}+ */+ public function getFunctions(): array+ {+ return [+ $this->formatAmountByAccount(),+ ];++ }++ /**+ * Will return "active" when a part of the route matches the argument.+ * ie. "accounts" will match "accounts.index".+ *+ * @return Twig_SimpleFunction+ */+ protected function formatAmountByAccount(): Twig_SimpleFunction+ {+ 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 AmountFacade::format($amount, $coloured);+ }+ $currency = TransactionCurrency::find($currencyId);++ return AmountFacade::formatAnything($currency, $amount, $coloured);+ }, ['is_safe' => ['html']]+ );+ }+++}\ No newline at end of filediff --git a/resources/views/list/accounts.twig b/resources/views/list/accounts.twigindex baa896e1b7..46d4fad1d8 100644--- a/resources/views/list/accounts.twig+++ b/resources/views/list/accounts.twig@@ -36,7 +36,7 @@<td class="hidden-sm hidden-xs">{{ account.iban }}</td><td data-value="{{ account.endBalance }}" style="text-align: right;"><span style="margin-right:5px;">- {{ account.endBalance|formatAmount }}+ {{ formatAmountByAccount(account, account.endBalance) }}</span></td><td class="hidden-sm hidden-xs" data-value="{{ account.active }}">@@ -57,7 +57,7 @@{% endif %}<td class="hidden-sm hidden-xs" data-value="{{ account.difference }}" style="text-align: right;"><span style="margin-right:5px;">- {{ (account.difference)|formatAmount }}+ {{ formatAmountByAccount(account, account.difference) }}</span></td>