diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 96cae6de8c..b2e9c1c1b0 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -94,7 +94,7 @@ class AccountController extends Controller $subTitle = trans('firefly.make_new_' . $what . '_account'); $roles = []; foreach (config('firefly.accountRoles') as $role) { - $roles[$role] = strval(trans('firefly.account_role_' . $role)); + $roles[$role] = (string)trans('firefly.account_role_' . $role); } // pre fill some data @@ -345,7 +345,9 @@ class AccountController extends Controller if (AccountType::INITIAL_BALANCE === $account->accountType->type) { return $this->redirectToOriginalAccount($account); } + $end = new Carbon; $today = new Carbon; + $start = $this->repository->oldestJournalDate($account); $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type); $page = (int)$request->get('page'); $pageSize = (int)Preferences::get('listPageSize', 50)->data; @@ -360,11 +362,12 @@ class AccountController extends Controller $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page); $transactions = $collector->getPaginatedJournals(); $transactions->setPath(route('accounts.show.all', [$account->id])); - $showAll = true; + $chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]); + $showAll = true; return view( 'accounts.show', - compact('account', 'showAll', 'currency', 'today', 'periods', 'subTitleIcon', 'transactions', 'subTitle') + compact('account', 'showAll', 'currency', 'today', 'chartUri', 'periods', 'subTitleIcon', 'transactions', 'subTitle', 'start', 'end') ); } diff --git a/public/js/ff/accounts/show.js b/public/js/ff/accounts/show.js index 440a49e5d3..c91cd4f37f 100644 --- a/public/js/ff/accounts/show.js +++ b/public/js/ff/accounts/show.js @@ -33,8 +33,8 @@ var fixHelper = function (e, tr) { $(function () { "use strict"; + lineChart(chartUri, 'overview-chart'); if (!showAll) { - lineChart(chartUri, 'overview-chart'); pieChart(incomeCategoryUri, 'account-cat-in'); pieChart(expenseCategoryUri, 'account-cat-out'); pieChart(expenseBudgetUri, 'account-budget-out'); diff --git a/resources/views/accounts/show.twig b/resources/views/accounts/show.twig index b13a802da1..b702c942e1 100644 --- a/resources/views/accounts/show.twig +++ b/resources/views/accounts/show.twig @@ -5,7 +5,7 @@ {% endblock %} {% block content %} - {% if not showAll %} +
@@ -29,6 +29,7 @@
+ {% if not showAll %}
@@ -153,10 +154,11 @@ var showAll = true; currencySymbol = "{{ currency.symbol }}"; var accountID = {{ account.id }}; + var chartUri = '{{ chartUri }}'; {% if not showAll %} showAll = false; // uri's for charts: - var chartUri = '{{ chartUri }}'; + var incomeCategoryUri = '{{ route('chart.account.income-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}'; var expenseCategoryUri = '{{ route('chart.account.expense-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}'; var expenseBudgetUri = '{{ route('chart.account.expense-budget', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';