diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index b59de1fcbf..96cae6de8c 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -285,8 +285,6 @@ class AccountController extends Controller * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View * * @throws FireflyException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so. - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * */ public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null) @@ -306,9 +304,9 @@ class AccountController extends Controller $today = new Carbon; $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type); - $page = intval($request->get('page')); - $pageSize = intval(Preferences::get('listPageSize', 50)->data); - $currencyId = intval($this->repository->getMetaValue($account, 'currency_id')); + $page = (int)$request->get('page'); + $pageSize = (int)Preferences::get('listPageSize', 50)->data; + $currencyId = (int)$this->repository->getMetaValue($account, 'currency_id'); $currency = $this->currencyRepos->findNull($currencyId); if (0 === $currencyId) { $currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore @@ -320,15 +318,53 @@ class AccountController extends Controller $periods = $this->getPeriodOverview($account, $end); $collector = app(JournalCollectorInterface::class); $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page); - if (null !== $start) { - $collector->setRange($start, $end); - } + $collector->setRange($start, $end); $transactions = $collector->getPaginatedJournals(); $transactions->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')])); + $showAll = false; return view( 'accounts.show', - compact('account', 'currency', 'today', 'periods', 'subTitleIcon', 'transactions', 'subTitle', 'start', 'end', 'chartUri') + compact('account', 'showAll', 'currency', 'today', 'periods', 'subTitleIcon', 'transactions', 'subTitle', 'start', 'end', 'chartUri') + ); + } + + /** + * Show an account. + * + * @param Request $request + * @param Account $account + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View + * + * @throws FireflyException + * + */ + public function showAll(Request $request, Account $account) + { + if (AccountType::INITIAL_BALANCE === $account->accountType->type) { + return $this->redirectToOriginalAccount($account); + } + $today = new Carbon; + $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type); + $page = (int)$request->get('page'); + $pageSize = (int)Preferences::get('listPageSize', 50)->data; + $currencyId = (int)$this->repository->getMetaValue($account, 'currency_id'); + $currency = $this->currencyRepos->findNull($currencyId); + if (0 === $currencyId) { + $currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore + } + $subTitle = trans('firefly.all_journals_for_account', ['name' => $account->name]); + $periods = new Collection; + $collector = app(JournalCollectorInterface::class); + $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page); + $transactions = $collector->getPaginatedJournals(); + $transactions->setPath(route('accounts.show.all', [$account->id])); + $showAll = true; + + return view( + 'accounts.show', + compact('account', 'showAll', 'currency', 'today', 'periods', 'subTitleIcon', 'transactions', 'subTitle') ); } diff --git a/public/js/ff/accounts/show.js b/public/js/ff/accounts/show.js index ba77ebff95..440a49e5d3 100644 --- a/public/js/ff/accounts/show.js +++ b/public/js/ff/accounts/show.js @@ -18,7 +18,7 @@ * along with Firefly III. If not, see . */ -/** global: chartUri, incomeCategoryUri, expenseCategoryUri, expenseBudgetUri, token */ +/** global: chartUri, incomeCategoryUri, showAll, expenseCategoryUri, expenseBudgetUri, token */ var fixHelper = function (e, tr) { "use strict"; @@ -33,11 +33,12 @@ var fixHelper = function (e, tr) { $(function () { "use strict"; - lineChart(chartUri, 'overview-chart'); - pieChart(incomeCategoryUri, 'account-cat-in'); - pieChart(expenseCategoryUri, 'account-cat-out'); - pieChart(expenseBudgetUri, 'account-budget-out'); - + if (!showAll) { + lineChart(chartUri, 'overview-chart'); + pieChart(incomeCategoryUri, 'account-cat-in'); + pieChart(expenseCategoryUri, 'account-cat-out'); + pieChart(expenseBudgetUri, 'account-budget-out'); + } // sortable! if (typeof $(".sortable-table tbody").sortable !== "undefined") { diff --git a/resources/views/accounts/show.twig b/resources/views/accounts/show.twig index eb584a5c2d..216e632b5e 100644 --- a/resources/views/accounts/show.twig +++ b/resources/views/accounts/show.twig @@ -5,67 +5,69 @@ {% endblock %} {% block content %} -
-
-
-
-

- {{ trans('firefly.chart_account_in_period', {name: account.name, start: start.formatLocalized(monthAndDayFormat), end: end.formatLocalized(monthAndDayFormat) }) }} -

-
-
- - + {% if not showAll %} +
+
+
+
+

+ {{ trans('firefly.chart_account_in_period', {name: account.name, start: start.formatLocalized(monthAndDayFormat), end: end.formatLocalized(monthAndDayFormat) }) }} +

+ +
+
+ +
+
+
+
+
+
+
+
+

{{ 'expenses_by_category'|_ }}

+
+
+
+
-
- +
+
+
+
+

{{ 'expenses_by_budget'|_ }}

+
+
+
+ +
+
-
-
-
-
-
-
-

{{ 'expenses_by_category'|_ }}

-
-
-
- +
+
+
+

{{ 'income_by_category'|_ }}

+
+
+
+ +
-
-
-
-

{{ 'expenses_by_budget'|_ }}

-
-
-
- -
-
-
-
-
-
-
-

{{ 'income_by_category'|_ }}

-
-
-
- -
-
-
-
-
+ {% endif %} {% if account.notes.count == 1 %}
@@ -94,9 +96,15 @@ {% include 'list.journals' with {sorting:true, hideBills:true, hideBudgets: true, hideCategories: true, showReconcile: showReconcile} %}

- - {{ 'show_the_current_period_and_overview'|_ }} - + {% if periods.count > 0 %} + + {{ 'show_all_no_filter'|_ }} + + {% else %} + + {{ 'show_the_current_period_and_overview'|_ }} + + {% endif %}

@@ -139,21 +147,23 @@ {% block scripts %} diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php index a06f33150c..eb617e8d9c 100644 --- a/routes/breadcrumbs.php +++ b/routes/breadcrumbs.php @@ -92,6 +92,16 @@ Breadcrumbs::register( } ); +Breadcrumbs::register( + 'accounts.show.all', + function (BreadCrumbsGenerator $breadcrumbs, Account $account, Carbon $start = null, Carbon $end = null) { + $what = config('firefly.shortNamesByFullName.' . $account->accountType->type); + + $breadcrumbs->parent('accounts.index', $what); + $breadcrumbs->push($account->name, route('accounts.show', [$account->id])); + } +); + Breadcrumbs::register( 'accounts.reconcile', function (BreadCrumbsGenerator $breadcrumbs, Account $account) { @@ -966,7 +976,7 @@ Breadcrumbs::register( if ($journals->count() > 0) { $journalIds = $journals->pluck('id')->toArray(); $what = strtolower($journals->first()->transactionType->type); - $breadcrumbs->parent('transactions.index'); + $breadcrumbs->parent('transactions.index', $what); $breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', $journalIds)); return; @@ -983,7 +993,7 @@ Breadcrumbs::register( function (BreadCrumbsGenerator $breadcrumbs, Collection $journals) { $journalIds = $journals->pluck('id')->toArray(); $what = strtolower($journals->first()->transactionType->type); - $breadcrumbs->parent('transactions.index'); + $breadcrumbs->parent('transactions.index', $what); $breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.delete', $journalIds)); } ); @@ -995,7 +1005,7 @@ Breadcrumbs::register( if ($journals->count() > 0) { $journalIds = $journals->pluck('id')->toArray(); $what = strtolower($journals->first()->transactionType->type); - $breadcrumbs->parent('transactions.index'); + $breadcrumbs->parent('transactions.index', $what); $breadcrumbs->push(trans('firefly.mass_bulk_journals'), route('transactions.bulk.edit', $journalIds)); return; diff --git a/routes/web.php b/routes/web.php index 084fcd6dd9..5f251b5b73 100755 --- a/routes/web.php +++ b/routes/web.php @@ -112,6 +112,7 @@ Route::group( Route::get('create/{what}', ['uses' => 'AccountController@create', 'as' => 'create'])->where('what', 'revenue|asset|expense'); Route::get('edit/{account}', ['uses' => 'AccountController@edit', 'as' => 'edit']); Route::get('delete/{account}', ['uses' => 'AccountController@delete', 'as' => 'delete']); + Route::get('show/{account}/all', ['uses' => 'AccountController@showAll', 'as' => 'show.all']); Route::get('show/{account}/{start_date?}/{end_date?}', ['uses' => 'AccountController@show', 'as' => 'show']); // reconcile routes: