Skip to content

Firefly III: a personal finances manager

Fix date range issue.

James Cole6bae8ab70a76
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;
}