Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Consistency for #595
James Coleebc712f6b5f0
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.phpindex 520d3b8516..2e0758a4cf 100644--- a/app/Http/Controllers/AccountController.php+++ b/app/Http/Controllers/AccountController.php@@ -25,6 +25,7 @@ use FireflyIII\Models\Transaction;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\Account\AccountTaskerInterface;use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Http\Request;use Illuminate\Support\Collection;@@ -229,16 +230,18 @@ class AccountController extends Controller/**- * @param Request $request- * @param Account $account- * @param string $moment+ * @param Request $request+ * @param JournalRepositoryInterface $repository+ * @param Account $account+ * @param string $moment+ *+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View*/- public function show(Request $request, Account $account, string $moment = '')+ public function show(Request $request, JournalRepositoryInterface $repository, Account $account, string $moment = ''){if ($account->accountType->type === AccountType::INITIAL_BALANCE) {return $this->redirectToOriginalAccount($account);}- $subTitle = $account->name;$range = Preferences::get('viewRange', '1M')->data;$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));@@ -250,29 +253,34 @@ class AccountController extends Controller// prep for "all" view.if ($moment === 'all') {- $subTitle = $account->name . ' (' . strtolower(strval(trans('firefly.everything'))) . ')';+ $subTitle = trans('firefly.all_journals_for_account', ['name' => $account->name]);$chartUri = route('chart.account.all', [$account->id]);+ $first = $repository->first();+ $start = $first->date ?? new Carbon;+ $end = new Carbon;}// prep for "specific date" view.if (strlen($moment) > 0 && $moment !== 'all') {$start = new Carbon($moment);$end = Navigation::endOfPeriod($start, $range);- $subTitle = $account->name . ' (' . strval(- trans(- 'firefly.from_to_breadcrumb',- ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]- )- ) . ')';+ $subTitle = trans(+ 'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),+ 'end' => $end->formatLocalized($this->monthAndDayFormat)]+ );$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d')]);$periods = $this->periodEntries($account);}// prep for current periodif (strlen($moment) === 0) {- $start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));- $end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));- $periods = $this->periodEntries($account);+ $start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));+ $end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));+ $subTitle = trans(+ 'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),+ 'end' => $end->formatLocalized($this->monthAndDayFormat)]+ );+ $periods = $this->periodEntries($account);}$accountType = $account->accountType->type;@@ -299,8 +307,16 @@ class AccountController extends Controller}}+ // fix title:+ if ((strlen($moment) > 0 && $moment !== 'all') || strlen($moment) === 0) {+ $subTitle = trans(+ 'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),+ 'end' => $end->formatLocalized($this->monthAndDayFormat)]+ );+ }+- return view('accounts.show', compact('account', 'accountType', 'periods', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri'));+ return view('accounts.show', compact('account','moment', 'accountType', 'periods', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri'));}/**diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.phpindex f758a9bdc3..9d79bfd7cf 100644--- a/app/Http/Controllers/BudgetController.php+++ b/app/Http/Controllers/BudgetController.php@@ -215,10 +215,7 @@ class BudgetController extends Controllerif (strlen($moment) > 0 && $moment !== 'all') {$start = new Carbon($moment);$end = Navigation::endOfPeriod($start, $range);- $subTitle = trans(- 'firefly.without_budget_between',- ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]- );+ $subTitle = trans('firefly.without_budget_between', ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]);$periods = $this->noBudgetPeriodEntries();}@@ -257,7 +254,12 @@ class BudgetController extends Controller}}- return view('budgets.no-budget', compact('journals', 'subTitle', 'periods', 'start', 'end'));+ // fix title:+ if ((strlen($moment) > 0 && $moment !== 'all') || strlen($moment) === 0) {+ $subTitle = trans('firefly.without_budget_between', ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]);+ }++ return view('budgets.no-budget', compact('journals', 'subTitle', 'moment', 'periods', 'start', 'end'));}/**diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.phpindex c39ad146e1..1d79655dd1 100644--- a/app/Http/breadcrumbs.php+++ b/app/Http/breadcrumbs.php@@ -67,32 +67,25 @@ Breadcrumbs::register();Breadcrumbs::register(- 'accounts.show', function (BreadCrumbGenerator $breadcrumbs, Account $account) {+ 'accounts.show', function (BreadCrumbGenerator $breadcrumbs, Account $account, string $moment, Carbon $start, Carbon $end) {$what = config('firefly.shortNamesByFullName.' . $account->accountType->type);$breadcrumbs->parent('accounts.index', $what);$breadcrumbs->push($account->name, route('accounts.show', [$account->id]));-}-);--Breadcrumbs::register(- 'accounts.show.date', function (BreadCrumbGenerator $breadcrumbs, Account $account, Carbon $start = null, Carbon $end = null) {- $title = '';- $route = '';- if (!is_null($start) && !is_null($end)) {- $startString = $start->formatLocalized(strval(trans('config.month_and_day')));- $endString = $end->formatLocalized(strval(trans('config.month_and_day')));- $title = sprintf('%s (%s)', $account->name, trans('firefly.from_to_breadcrumb', ['start' => $startString, 'end' => $endString]));- $route = route('accounts.show.date', [$account->id, $start->format('Y-m-d')]);+ // push when is all:+ if ($moment === 'all') {+ $breadcrumbs->push(trans('firefly.all_journals_for_account', ['name' => $account->name]), route('accounts.show', [$account->id]));}- if (is_null($start) && is_null($end)) {- $title = $title = $account->name . ' (' . strtolower(strval(trans('firefly.everything'))) . ')';- $route = route('accounts.show.date', [$account->id, 'all']);+ // when is specific period:+ if (strlen($moment) > 0 && $moment !== 'all') {+ $title = trans('firefly.journals_in_period_for_account', ['name' => $account->name,+ 'start' => $start->formatLocalized(strval(trans('config.month_and_day'))),+ 'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]+ );+ $breadcrumbs->push($title, route('accounts.show', [$account->id, $moment]));}- $breadcrumbs->parent('accounts.show', $account);- $breadcrumbs->push($title, $route);});@@ -256,9 +249,23 @@ Breadcrumbs::register();Breadcrumbs::register(- 'budgets.no-budget', function (BreadCrumbGenerator $breadcrumbs, $subTitle) {+ 'budgets.no-budget', function (BreadCrumbGenerator $breadcrumbs, string $moment, Carbon $start, Carbon $end) {$breadcrumbs->parent('budgets.index');- $breadcrumbs->push($subTitle, route('budgets.no-budget'));+ $breadcrumbs->push(trans('firefly.journals_without_budget'), route('budgets.no-budget'));++ // push when is all:+ if ($moment === 'all') {+ $breadcrumbs->push(trans('firefly.all_journals_without_budget'), route('budgets.no-budget', ['all']));+ }+ // when is specific period:+ if (strlen($moment) > 0 && $moment !== 'all') {+ $title = trans('firefly.without_budget_between', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),+ 'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]+ );+ $breadcrumbs->push($title, route('budgets.no-budget', [$moment]));+ }++});@@ -792,15 +799,16 @@ Breadcrumbs::register(Breadcrumbs::register('transactions.mass.edit', function (BreadCrumbGenerator $breadcrumbs, Collection $journals) {- if($journals->count() > 0) {- $journalIds = $journals->pluck('id')->toArray();- $what = strtolower($journals->first()->transactionType->type);- $breadcrumbs->parent('transactions.index', $what);- $breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', $journalIds));- return;- }+ if ($journals->count() > 0) {+ $journalIds = $journals->pluck('id')->toArray();+ $what = strtolower($journals->first()->transactionType->type);+ $breadcrumbs->parent('transactions.index', $what);+ $breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', $journalIds));++ return;+ }- $breadcrumbs->parent('index');+ $breadcrumbs->parent('index');});diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex c33e58cfd8..cbf0516c67 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -116,6 +116,9 @@ return ['multi_select_all_selected' => 'All selected','multi_select_filter_placeholder' => 'Find..','all_journals_without_budget' => 'All transactions without a budget',+ 'journals_without_budget' => 'Transactions without a budget',+ 'all_journals_for_account' => 'All transactions for account :name',+ 'journals_in_period_for_account' => 'All transactions for account :name between :start and :end',// repeat frequencies:diff --git a/resources/views/accounts/show.twig b/resources/views/accounts/show.twigindex 395e71767b..b4fe840ed1 100644--- a/resources/views/accounts/show.twig+++ b/resources/views/accounts/show.twig@@ -1,7 +1,7 @@{% extends "./layout/default" %}{% block breadcrumbs %}- {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account, start, end) }}+ {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account, moment, start, end) }}{% endblock %}{% block content %}@@ -9,12 +9,8 @@<div class="col-lg-12 col-md-10 col-sm-12"><div class="box"><div class="box-header with-border">- <h3 class="box-title">{{ account.name }}- {% if start and end %}- ({{ trans('firefly.from_to_breadcrumb', {start: start.formatLocalized(monthAndDayFormat), end: end.formatLocalized(monthAndDayFormat)}) }})- {% else %}- ({{ trans('firefly.everything')|lower }})- {% endif %}+ <h3 class="box-title">+ {{ subTitle }}</h3><!-- ACTIONS MENU --><div class="box-tools pull-right">@@ -74,7 +70,7 @@{% if periods.count > 0 %}<div class="row"><div class="col-lg-offset-10 col-lg-2 col-md-offset-10 col-md-2 col-sm-12 col-xs-12">- <p class="small text-center"><a href="{{ route('accounts.show.date',[account.id, 'all']) }}">{{ 'showEverything'|_ }}</a></p>+ <p class="small text-center"><a href="{{ route('accounts.show',[account.id, 'all']) }}">{{ 'showEverything'|_ }}</a></p></div></div>{% endif %}@@ -90,7 +86,7 @@{% if periods.count > 0 %}<p><i class="fa fa-calendar" aria-hidden="true"></i>- <a href="{{ route('accounts.show.date', [account.id, 'all']) }}">+ <a href="{{ route('accounts.show', [account.id, 'all']) }}">{{ 'show_all_no_filter'|_ }}</a></p>@@ -111,7 +107,7 @@{% if (entry[2] != 0 or entry[3] != 0) or (accountType == 'Asset account') %}<div class="box {% if entry[4] == start %}box-solid box-primary{% endif %}"><div class="box-header with-border">- <h3 class="box-title"><a href="{{ route('accounts.show.date',[account.id,entry[0]]) }}">{{ entry[1] }}</a>+ <h3 class="box-title"><a href="{{ route('accounts.show',[account.id,entry[0]]) }}">{{ entry[1] }}</a></h3></div><div class="box-body no-padding">@@ -133,7 +129,7 @@</div>{% endif %}{% endfor %}- <p class="small text-center"><a href="{{ route('accounts.show.date',[account.id, 'all']) }}">{{ 'showEverything'|_ }}</a></p>+ <p class="small text-center"><a href="{{ route('accounts.show',[account.id, 'all']) }}">{{ 'showEverything'|_ }}</a></p></div>{% endif %}</div>diff --git a/resources/views/budgets/no-budget.twig b/resources/views/budgets/no-budget.twigindex 83ef89391e..20166e601d 100644--- a/resources/views/budgets/no-budget.twig+++ b/resources/views/budgets/no-budget.twig@@ -1,7 +1,7 @@{% extends "./layout/default" %}{% block breadcrumbs %}- {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, subTitle) }}+ {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, moment, start, end) }}{% endblock %}{% block content %}@@ -41,22 +41,20 @@{% if periods.count > 0 %}<div class="col-lg-2 col-md-2 col-sm-12 col-xs-12">{% for entry in periods %}- {% if entry[2] > 0 %}- <div class="box {% if entry[3] == start %}box-solid box-primary{% endif %}">- <div class="box-header with-border">- <h3 class="box-title"><a href="{{ route('budgets.no-budget',[entry[0]]) }}">{{ entry[1] }}</a>- </h3>- </div>- <div class="box-body no-padding">- <table class="table table-hover">- <tr>- <td style="width:33%;">{{ 'transactions'|_ }}</td>- <td style="text-align: right;">{{ entry[2] }}</td>- </tr>- </table>- </div>+ <div class="box {% if entry[3] == start %}box-solid box-primary{% endif %}">+ <div class="box-header with-border">+ <h3 class="box-title"><a href="{{ route('budgets.no-budget',[entry[0]]) }}">{{ entry[1] }}</a>+ </h3></div>- {% endif %}+ <div class="box-body no-padding">+ <table class="table table-hover">+ <tr>+ <td style="width:33%;">{{ 'transactions'|_ }}</td>+ <td style="text-align: right;">{{ entry[2] }}</td>+ </tr>+ </table>+ </div>+ </div>{% endfor %}</div>{% endif %}diff --git a/routes/web.php b/routes/web.phpindex 36571253d9..2d94859db5 100755--- a/routes/web.php+++ b/routes/web.php@@ -87,8 +87,7 @@ Route::group(Route::get('edit/{account}', ['uses' => 'AccountController@edit', 'as' => 'edit']);Route::get('delete/{account}', ['uses' => 'AccountController@delete', 'as' => 'delete']);- Route::get('show/{account}', ['uses' => 'AccountController@show', 'as' => 'show']);- Route::get('show/{account}/{date}', ['uses' => 'AccountController@show', 'as' => 'show.date']);+ Route::get('show/{account}/{moment?}', ['uses' => 'AccountController@show', 'as' => 'show']);Route::post('store', ['uses' => 'AccountController@store', 'as' => 'store']);Route::post('update/{account}', ['uses' => 'AccountController@update', 'as' => 'update']);