Fix date range issue.

This commit is contained in:
James Cole
2026-03-01 06:52:26 +01:00
parent 88030784a5
commit 6bae8ab70a
2 changed files with 11 additions and 4 deletions
@@ -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);
+4 -1
View File
@@ -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;
}