mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 06:01:21 +00:00
Debug bill transformer
This commit is contained in:
@@ -58,6 +58,7 @@ class Navigation
|
||||
*/
|
||||
public function addPeriod(Carbon $theDate, string $repeatFreq, int $skip = 0): Carbon
|
||||
{
|
||||
$date = clone $theDate;
|
||||
$functionMap = [
|
||||
'1D' => Periodicity::Daily,
|
||||
'daily' => Periodicity::Daily,
|
||||
@@ -95,7 +96,7 @@ class Navigation
|
||||
return $theDate;
|
||||
}
|
||||
|
||||
return $this->nextDateByInterval($theDate, $functionMap[$repeatFreq], $skip);
|
||||
return $this->nextDateByInterval($date, $functionMap[$repeatFreq], $skip);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,25 +349,36 @@ class Navigation
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function diffInPeriods(string $period, Carbon $beginning, Carbon $end): int
|
||||
public function diffInPeriods(string $period, int $skip, Carbon $beginning, Carbon $end): int
|
||||
{
|
||||
app('log')->debug(sprintf('diffInPeriods: %s (skip: %d), between %s and %s.',
|
||||
$period, $skip, $beginning->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
$map = [
|
||||
'daily' => 'diffInDays',
|
||||
'weekly' => 'diffInWeeks',
|
||||
'monthly' => 'diffInMonths',
|
||||
'quarterly' => 'diffInQuarters',
|
||||
'half-year' => 'diffInQuarters',
|
||||
'yearly' => 'diffInYears',
|
||||
'daily' => 'floatDiffInDays',
|
||||
'weekly' => 'floatDiffInWeeks',
|
||||
'monthly' => 'floatDiffInMonths',
|
||||
//'quarterly' => 'floatDiffInMonths',
|
||||
//'half-year' => 'floatDiffInQuarters',
|
||||
'yearly' => 'floatDiffInYears',
|
||||
];
|
||||
if (!array_key_exists($period, $map)) {
|
||||
app('log')->warning(sprintf('No diffInPeriods for period "%s"', $period));
|
||||
return 1;
|
||||
}
|
||||
$func = $map[$period];
|
||||
$diff = $beginning->$func($end);
|
||||
$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);
|
||||
}
|
||||
|
||||
if($skip > 0) {
|
||||
$parameter = $skip + 1;
|
||||
$diff = ceil($diff / $parameter) * $parameter;
|
||||
app('log')->debug(sprintf('diffInPeriods: skip is %d, so param is %d, and diff becomes %d',
|
||||
$skip, $parameter, $diff));
|
||||
}
|
||||
|
||||
return (int)$diff;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user