From 56700ef984068811e916bd438626dc42a5509854 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 30 Dec 2019 14:41:16 +0100 Subject: [PATCH] Add balance #2933 --- app/Http/Controllers/Account/ShowController.php | 7 +++++-- resources/lang/en_US/firefly.php | 2 +- resources/views/v1/accounts/show.twig | 12 +++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php index f45f37e419..cbe3d80d8d 100644 --- a/app/Http/Controllers/Account/ShowController.php +++ b/app/Http/Controllers/Account/ShowController.php @@ -123,12 +123,13 @@ class ShowController extends Controller $groups = $collector->getPaginatedGroups(); $groups->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')])); $showAll = false; + $balance = app('steam')->balance($account, $end); return view( 'accounts.show', compact( 'account', 'showAll', 'objectType', 'currency', 'today', 'periods', 'subTitleIcon', 'groups', 'subTitle', 'start', 'end', - 'chartUri', 'location' + 'chartUri', 'location','balance' ) ); } @@ -147,6 +148,7 @@ class ShowController extends Controller return $this->redirectAccountToAccount($account); // @codeCoverageIgnore } + $location = $this->repository->getLocation($account); $isLiability = $this->repository->isLiability($account); $objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); @@ -166,12 +168,13 @@ class ShowController extends Controller $groups->setPath(route('accounts.show.all', [$account->id])); $chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]); $showAll = true; + $balance = app('steam')->balance($account, $end); return view( 'accounts.show', compact( 'account', 'showAll', 'location', 'objectType', 'isLiability', 'currency', 'today', - 'chartUri', 'periods', 'subTitleIcon', 'groups', 'subTitle', 'start', 'end' + 'chartUri', 'periods', 'subTitleIcon', 'groups', 'subTitle', 'start', 'end', 'balance' ) ); } diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 2591bcde27..d812cd7bbc 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -138,7 +138,7 @@ return [ 'budget_in_period' => 'All transactions for budget ":name" between :start and :end in :currency', 'chart_budget_in_period' => 'Chart for all transactions for budget ":name" between :start and :end in :currency', 'chart_budget_in_period_only_currency' => 'The amount you budgeted was in :currency, so this chart will only show transactions in :currency.', - 'chart_account_in_period' => 'Chart for all transactions for account ":name" between :start and :end', + 'chart_account_in_period' => 'Chart for all transactions for account ":name" (:balance) between :start and :end', 'chart_category_in_period' => 'Chart for all transactions for category ":name" between :start and :end', 'chart_category_all' => 'Chart for all transactions for category ":name"', 'clone_withdrawal' => 'Clone this withdrawal', diff --git a/resources/views/v1/accounts/show.twig b/resources/views/v1/accounts/show.twig index d8757863ad..5acff5f48b 100644 --- a/resources/views/v1/accounts/show.twig +++ b/resources/views/v1/accounts/show.twig @@ -11,7 +11,9 @@

- {{ trans('firefly.chart_account_in_period', {name: account.name, start: start.formatLocalized(monthAndDayFormat), end: end.formatLocalized(monthAndDayFormat) }) }} + {{ trans('firefly.chart_account_in_period', { + balance: formatAmountBySymbol(balance, currency.symbol, currency.decimal_places, true), + name: account.name, start: start.formatLocalized(monthAndDayFormat), end: end.formatLocalized(monthAndDayFormat) })|raw }}

@@ -87,18 +89,18 @@ {% endif %}
+ {% if(location) %}

{{ 'location'|_ }}

- {% if(location) %} -
- {% endif %} +
+ {% endif %} {% if account.notes.count == 1 %}
@@ -117,7 +119,7 @@
-

{{ 'transactions'|_ }}

+

{{ 'transactions'|_ }} ({{ formatAmountBySymbol(balance, currency.symbol, currency.decimal_places, true)|raw }})

{% if account.accountType.type == 'Asset account' %}