diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php index fce1688a6c..882fe1d63a 100644 --- a/app/Http/Controllers/Budget/IndexController.php +++ b/app/Http/Controllers/Budget/IndexController.php @@ -70,35 +70,24 @@ class IndexController extends Controller * Show all budgets. * * @param Request $request - * @param string|null $moment + * + * @param Carbon|null $start + * @param Carbon|null $end * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function index(Request $request, string $moment = null) + public function index(Request $request, Carbon $start = null, Carbon $end = null) { // collect some basic vars: $range = app('preferences')->get('viewRange', '1M')->data; - $start = session('start', new Carbon); - $end = session('end', new Carbon); + $start = $start ?? session('start', Carbon::now()->startOfMonth()); + $end = $end ?? app('navigation')->endOfPeriod($start, $range); $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; - $moment = $moment ?? ''; $defaultCurrency = app('amount')->getDefaultCurrency(); - // make a date if the data is given. - if ('' !== (string)$moment) { - try { - $start = new Carbon($moment); - /** @var Carbon $end */ - $end = app('navigation')->endOfPeriod($start, $range); - } catch (Exception $e) { - // start and end are already defined. - Log::debug(sprintf('start and end are already defined: %s', $e->getMessage())); - } - } - // make the next and previous period, and calculate the periods used for period navigation $next = clone $end; $next->addDay(); @@ -106,7 +95,7 @@ class IndexController extends Controller $prev->subDay(); $prev = app('navigation')->startOfPeriod($prev, $range); $previousLoop = $this->getPreviousPeriods($start, $range); - $nextLoop = $this->getNextPeriods($end, $range); + $nextLoop = $this->getNextPeriods($start, $range); $currentMonth = app('navigation')->periodShow($start, $range); $nextText = app('navigation')->periodShow($next, $range); $prevText = app('navigation')->periodShow($prev, $range); diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.php index d9ff4999f5..55f3f5894e 100644 --- a/app/Http/Controllers/Budget/ShowController.php +++ b/app/Http/Controllers/Budget/ShowController.php @@ -118,7 +118,6 @@ class ShowController extends Controller $end = new Carbon; $page = (int)$request->get('page'); $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; - $moment = 'all'; /** @var JournalCollectorInterface $collector */ $collector = app(JournalCollectorInterface::class); @@ -127,7 +126,7 @@ class ShowController extends Controller $transactions = $collector->getPaginatedJournals(); $transactions->setPath(route('budgets.no-budget')); - return view('budgets.no-budget', compact('transactions', 'subTitle', 'moment', 'start', 'end')); + return view('budgets.no-budget', compact('transactions', 'subTitle', 'start', 'end')); } diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.php index 720befb907..2eda59c554 100644 --- a/app/Http/Controllers/Category/NoCategoryController.php +++ b/app/Http/Controllers/Category/NoCategoryController.php @@ -79,7 +79,6 @@ class NoCategoryController extends Controller $start = $start ?? session('start'); /** @var Carbon $end */ $end = $end ?? session('end'); - $moment = ''; $page = (int)$request->get('page'); $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $subTitle = trans( @@ -99,7 +98,7 @@ class NoCategoryController extends Controller $transactions = $collector->getPaginatedJournals(); $transactions->setPath(route('categories.no-category')); - return view('categories.no-category', compact('transactions', 'subTitle', 'moment', 'periods', 'start', 'end')); + return view('categories.no-category', compact('transactions', 'subTitle', 'periods', 'start', 'end')); } @@ -107,14 +106,12 @@ class NoCategoryController extends Controller * Show all transactions without a category. * * @param Request $request - * @param string|null $moment * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ - public function showAll(Request $request, string $moment = null) + public function showAll(Request $request) { // default values: - $moment = $moment ?? ''; $start = null; $end = null; $periods = new Collection; @@ -136,7 +133,7 @@ class NoCategoryController extends Controller $transactions = $collector->getPaginatedJournals(); $transactions->setPath(route('categories.no-category')); - return view('categories.no-category', compact('transactions', 'subTitle', 'moment', 'periods', 'start', 'end')); + return view('categories.no-category', compact('transactions', 'subTitle', 'periods', 'start', 'end')); } diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.php index 540d5a1864..ed0acbb869 100644 --- a/app/Http/Controllers/Category/ShowController.php +++ b/app/Http/Controllers/Category/ShowController.php @@ -94,7 +94,6 @@ class ShowController extends Controller /** @var Carbon $end */ $end = $end ?? session('end', Carbon::now()->endOfMonth()); $subTitleIcon = 'fa-bar-chart'; - $moment = ''; $page = (int)$request->get('page'); $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $periods = $this->getPeriodOverview($category, $start); @@ -115,7 +114,7 @@ class ShowController extends Controller Log::debug('End of show()'); - return view('categories.show', compact('category', 'transactions', 'moment', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); + return view('categories.show', compact('category', 'transactions', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); } /** @@ -135,7 +134,6 @@ class ShowController extends Controller $start = null; $end = null; $periods = new Collection; - $moment = 'all'; $subTitle = (string)trans('firefly.all_journals_for_category', ['name' => $category->name]); $first = $this->repository->firstUseDate($category); @@ -153,7 +151,7 @@ class ShowController extends Controller $transactions = $collector->getPaginatedJournals(); $transactions->setPath($path); - return view('categories.show', compact('category', 'moment', 'transactions', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); + return view('categories.show', compact('category', 'transactions', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); } /** diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 73e2cccbfb..604c192ad4 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -170,7 +170,8 @@ class TagController extends Controller * * @param Request $request * @param Tag $tag - * @param string|null $moment + * @param Carbon|null $start + * @param Carbon|null $end * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @@ -205,11 +206,10 @@ class TagController extends Controller } /** - * Show a single tag. + * Show a single tag over all time. * - * @param Request $request - * @param Tag $tag - * @param string|null $moment + * @param Request $request + * @param Tag $tag * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * diff --git a/app/Support/Http/Controllers/DateCalculation.php b/app/Support/Http/Controllers/DateCalculation.php index 7c08f640ec..fb2c5938fd 100644 --- a/app/Support/Http/Controllers/DateCalculation.php +++ b/app/Support/Http/Controllers/DateCalculation.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Support\Http\Controllers; use Carbon\Carbon; -use Log; /** * Trait DateCalculation @@ -117,7 +116,8 @@ trait DateCalculation // select thing for next 12 periods: $loop = []; /** @var Carbon $current */ - $current = clone $date; + $current = app('navigation')->startOfPeriod($date, $range); + $current = app('navigation')->endOfPeriod($current, $range); $current->addDay(); $count = 0; @@ -146,7 +146,7 @@ trait DateCalculation // select thing for last 12 periods: $loop = []; /** @var Carbon $current */ - $current = clone $date; + $current = app('navigation')->startOfPeriod($date, $range); $count = 0; while ($count < 12) { $current->subDay(); diff --git a/resources/views/accounts/reconcile/index.twig b/resources/views/accounts/reconcile/index.twig index 23754353b1..98864f7bcd 100644 --- a/resources/views/accounts/reconcile/index.twig +++ b/resources/views/accounts/reconcile/index.twig @@ -1,7 +1,7 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.render(Route.getCurrentRoute.getName, account, moment, start, end) }} + {{ Breadcrumbs.render(Route.getCurrentRoute.getName, account, start, end) }} {% endblock %} {% block content %} diff --git a/resources/views/budgets/no-budget.twig b/resources/views/budgets/no-budget.twig index 99e99236fe..36680089d5 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.render(Route.getCurrentRoute.getName, '', start, end) }} + {{ Breadcrumbs.render(Route.getCurrentRoute.getName, start, end) }} {% endblock %} {% block content %} diff --git a/resources/views/categories/no-category.twig b/resources/views/categories/no-category.twig index da8077c8b7..ed6778c54a 100644 --- a/resources/views/categories/no-category.twig +++ b/resources/views/categories/no-category.twig @@ -1,7 +1,7 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.render(Route.getCurrentRoute.getName, moment, start, end) }} + {{ Breadcrumbs.render(Route.getCurrentRoute.getName, start, end) }} {% endblock %} {% block content %} @@ -10,7 +10,7 @@ {% if periods.count > 0 %}
{% endif %} @@ -26,7 +26,7 @@ {% if periods.count > 0 %}- {{ 'show_all_no_filter'|_ }} + {{ 'show_all_no_filter'|_ }}
{% else %}diff --git a/resources/views/categories/show.twig b/resources/views/categories/show.twig index a8a3171ce5..dc79577173 100644 --- a/resources/views/categories/show.twig +++ b/resources/views/categories/show.twig @@ -1,12 +1,12 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.render(Route.getCurrentRoute.getName, category, '', start, end) }} + {{ Breadcrumbs.render(Route.getCurrentRoute.getName, category, start, end) }} {% endblock %} {% block content %}