diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 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 period if (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.php index f758a9bdc3..9d79bfd7cf 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -215,10 +215,7 @@ class BudgetController extends Controller if (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.php index 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)); - $breadcrumbs->parent('index'); + return; + } + + $breadcrumbs->parent('index'); } ); diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 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.twig index 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 @@
- + {{ 'show_all_no_filter'|_ }}
@@ -111,7 +107,7 @@ {% if (entry[2] != 0 or entry[3] != 0) or (accountType == 'Asset account') %}{{ 'transactions'|_ }} | -{{ entry[2] }} | -
{{ 'transactions'|_ }} | +{{ entry[2] }} | +