This commit is contained in:
James Cole
2023-10-27 18:07:56 +02:00
parent c4c690f44f
commit 9e94b9e57e
2 changed files with 22 additions and 8 deletions

View File

@@ -357,8 +357,8 @@ class Navigation
'daily' => 'floatDiffInDays',
'weekly' => 'floatDiffInWeeks',
'monthly' => 'floatDiffInMonths',
//'quarterly' => 'floatDiffInMonths',
//'half-year' => 'floatDiffInQuarters',
'quarterly' => 'floatDiffInMonths',
'half-year' => 'floatDiffInMonths',
'yearly' => 'floatDiffInYears',
];
if (!array_key_exists($period, $map)) {
@@ -366,11 +366,23 @@ class Navigation
return 1;
}
$func = $map[$period];
$diff = ceil($beginning->$func($end));
app('log')->debug(sprintf('Diff is %f (%d)', $beginning->$func($end), $diff));
if ('half-year' === $period) {
$diff = ceil($diff / 2);
// first do the diff
$diff = $beginning->$func($end);
// then correct for quarterly or half-year
if('quarterly' === $period) {
app('log')->debug(sprintf('Q: Corrected %f to %f', $diff, $diff / 3));
$diff = $diff / 3;
}
if('half-year' === $period) {
app('log')->debug(sprintf('H: Corrected %f to %f', $diff, $diff / 6));
$diff = $diff / 6;
}
// then do ceil()
$diff = ceil($diff);
app('log')->debug(sprintf('Diff is %f (%d)', $beginning->$func($end), $diff));
if($skip > 0) {
$parameter = $skip + 1;

View File

@@ -302,8 +302,10 @@ class BillTransformer extends AbstractTransformer
break;
}
app('log')->debug(sprintf('Next expected match is %s', $nextExpectedMatch->format('Y-m-d')));
// add to set
$set->push(clone $nextExpectedMatch);
// add to set, if the date is ON or after the start parameter
if($nextExpectedMatch->gte($this->parameters->get('start'))) {
$set->push(clone $nextExpectedMatch);
}
// 2023-10
// for the next loop, go to end of period, THEN add day.