mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-01 11:47:14 -06:00
Account list is capable of showing the selected currency
This commit is contained in:
parent
bac7a73555
commit
89ee9c058a
@ -43,6 +43,7 @@ use FireflyIII\Support\FireflyConfig;
|
|||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
use FireflyIII\Support\Preferences;
|
use FireflyIII\Support\Preferences;
|
||||||
use FireflyIII\Support\Steam;
|
use FireflyIII\Support\Steam;
|
||||||
|
use FireflyIII\Support\Twig\Account;
|
||||||
use FireflyIII\Support\Twig\General;
|
use FireflyIII\Support\Twig\General;
|
||||||
use FireflyIII\Support\Twig\Journal;
|
use FireflyIII\Support\Twig\Journal;
|
||||||
use FireflyIII\Support\Twig\PiggyBank;
|
use FireflyIII\Support\Twig\PiggyBank;
|
||||||
@ -77,6 +78,7 @@ class FireflyServiceProvider extends ServiceProvider
|
|||||||
Twig::addExtension(new Translation);
|
Twig::addExtension(new Translation);
|
||||||
Twig::addExtension(new Transaction);
|
Twig::addExtension(new Transaction);
|
||||||
Twig::addExtension(new Rule);
|
Twig::addExtension(new Rule);
|
||||||
|
Twig::addExtension(new Account);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
63
app/Support/Twig/Account.php
Normal file
63
app/Support/Twig/Account.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Account.php
|
||||||
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||||
|
* 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']]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -36,7 +36,7 @@
|
|||||||
<td class="hidden-sm hidden-xs">{{ account.iban }}</td>
|
<td class="hidden-sm hidden-xs">{{ account.iban }}</td>
|
||||||
<td data-value="{{ account.endBalance }}" style="text-align: right;">
|
<td data-value="{{ account.endBalance }}" style="text-align: right;">
|
||||||
<span style="margin-right:5px;">
|
<span style="margin-right:5px;">
|
||||||
{{ account.endBalance|formatAmount }}
|
{{ formatAmountByAccount(account, account.endBalance) }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="hidden-sm hidden-xs" data-value="{{ account.active }}">
|
<td class="hidden-sm hidden-xs" data-value="{{ account.active }}">
|
||||||
@ -57,7 +57,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="hidden-sm hidden-xs" data-value="{{ account.difference }}" style="text-align: right;">
|
<td class="hidden-sm hidden-xs" data-value="{{ account.difference }}" style="text-align: right;">
|
||||||
<span style="margin-right:5px;">
|
<span style="margin-right:5px;">
|
||||||
{{ (account.difference)|formatAmount }}
|
{{ formatAmountByAccount(account, account.difference) }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user