From 6bae8ab70a76488db1ddde247ce7d878d791bf1a Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 1 Mar 2026 06:52:26 +0100 Subject: [PATCH] Fix date range issue. --- app/Http/Controllers/Chart/ReportController.php | 10 +++++++--- app/Support/Navigation.php | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php index e711dc4c25..46223164bf 100644 --- a/app/Http/Controllers/Chart/ReportController.php +++ b/app/Http/Controllers/Chart/ReportController.php @@ -151,7 +151,7 @@ class ReportController extends Controller $cache->addProperty($end); $cache->addProperty($this->convertToPrimary); if ($cache->has()) { - return response()->json($cache->get()); + // return response()->json($cache->get()); } Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray()); @@ -219,7 +219,7 @@ class ReportController extends Controller /** @var array $currency */ foreach ($data as $currency) { - Log::debug(sprintf('Now processing currency "%s"', $currency['currency_name'])); + Log::debug(sprintf('Now processing currency %s', $currency['currency_code'])); $income = [ 'label' => (string) trans('firefly.box_earned_in_currency', ['currency' => $currency['currency_name']]), 'type' => 'bar', @@ -247,7 +247,11 @@ class ReportController extends Controller if ('1Y' === $preferredRange) { $currentEnd = Navigation::endOfPeriod($currentEnd, $preferredRange); } - Log::debug('Start of sub-loop'); + // 2026-03-01 similar fix for monthly ranges. + if ('1M' === $preferredRange) { + $currentEnd = Navigation::endOfPeriod($currentEnd, $preferredRange); + } + Log::debug(sprintf('Start of sub-loop, current end is %s', $currentEnd->toW3cString())); while ($currentStart <= $currentEnd) { Log::debug(sprintf('Current start: %s', $currentStart->toW3cString())); $key = $currentStart->format($format); diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 291418b388..83f5bf140e 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -453,7 +453,7 @@ class Navigation $diff = $start->diffInMonths($end, true); // increment by month (for year) if ($diff >= 1.0001 && $diff < 12.001) { - $increment = 'addMonth'; + $increment = 'addMonthsNoOverflow'; $displayFormat = (string) trans('config.month_js'); } @@ -464,12 +464,15 @@ class Navigation } $begin = clone $start; $entries = []; + Log::debug(sprintf('listOfPeriods start of loop (end: %s).', $end->format('Y-m-d H:i:s'))); while ($begin < $end) { + Log::debug(sprintf('Begin is now %s.', $begin->format('Y-m-d H:i:s'))); $formatted = $begin->format($format); $displayed = $begin->isoFormat($displayFormat); $entries[$formatted] = $displayed; $begin->{$increment}(); // @phpstan-ignore-line } + Log::debug('listOfPeriods end of loop.'); return $entries; }