Skip to content

Firefly III: a personal finances manager

Fix a bug where the report page would mess up the session dates.

James Cole1ab3f05b3ae0
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index e9cee699e6..59bf1f01ac 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -42,8 +42,16 @@ class ReportController extends Controller
*/
public function index(AccountRepositoryInterface $repository)
{
- $start = Session::get('first');
- $months = $this->helper->listOfMonths($start);
+ $start = Session::get('first');
+ $months = $this->helper->listOfMonths($start);
+ $startOfMonth = clone Session::get('start');
+ $endOfMonth = clone Session::get('start');
+ $startOfYear = clone Session::get('start');
+ $endOfYear = clone Session::get('start');
+ $startOfMonth->startOfMonth();
+ $endOfMonth->endOfMonth();
+ $startOfYear->startOfYear();
+ $endOfYear->endOfYear();
// does the user have shared accounts?
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
@@ -56,7 +64,9 @@ class ReportController extends Controller
$accountList = join(',', $accountIds);
- return view('reports.index', compact('months', 'accounts', 'start', 'accountList'));
+ return view('reports.index', compact('months', 'accounts', 'start', 'accountList',
+ 'startOfMonth', 'endOfMonth', 'startOfYear', 'endOfYear'
+ ));
}
/**
@@ -194,7 +204,7 @@ class ReportController extends Controller
'firefly.report_default',
[
'start' => $start->formatLocalized($this->monthFormat),
- 'end' => $end->formatLocalized($this->monthFormat)
+ 'end' => $end->formatLocalized($this->monthFormat),
]
)
);
diff --git a/resources/twig/reports/index.twig b/resources/twig/reports/index.twig
index 773de4e3d8..93ca24c200 100644
--- a/resources/twig/reports/index.twig
+++ b/resources/twig/reports/index.twig
@@ -95,16 +95,16 @@
<li>
<a href="{{ route('reports.report',
['default',
- Session.get('start').startOfMonth.format('Ymd'),
- Session.get('start').endOfMonth.format('Ymd'),
+ startOfMonth.format('Ymd'),
+ endOfMonth.format('Ymd'),
accountList
]) }}">{{ 'report_this_month_quick'|_ }}</a>
</li>
<li>
<a href="{{ route('reports.report',
['default',
- Session.get('start').startOfYear.format('Ymd'),
- Session.get('start').endOfYear.format('Ymd'),
+ startOfYear.format('Ymd'),
+ endOfYear.format('Ymd'),
accountList
]) }}">{{ 'report_this_year_quick'|_ }}</a>
</li>
@@ -112,7 +112,7 @@
<a href="{{ route('reports.report',
['default',
start.format('Ymd'),
- Session.get('end').endOfMonth.format('Ymd'),
+ endOfMonth.format('Ymd'),
accountList
]) }}">{{ 'report_all_time_quick'|_ }}</a>
</li>