mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 20:38:57 +00:00
Expand repeated expenses.
This commit is contained in:
@@ -98,6 +98,51 @@ class Date
|
||||
return $currentEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $theCurrentEnd
|
||||
* @param $repeatFreq
|
||||
*
|
||||
* @return mixed
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function endOfX(Carbon $theCurrentEnd, $repeatFreq)
|
||||
{
|
||||
$currentEnd = clone $theCurrentEnd;
|
||||
switch ($repeatFreq) {
|
||||
default:
|
||||
throw new FireflyException('Cannot do endOfPeriod for $repeat_freq ' . $repeatFreq);
|
||||
break;
|
||||
case 'daily':
|
||||
$currentEnd->endOfDay();
|
||||
break;
|
||||
case 'week':
|
||||
case 'weekly':
|
||||
$currentEnd->endOfWeek();
|
||||
break;
|
||||
case 'month':
|
||||
case 'monthly':
|
||||
$currentEnd->endOfMonth();
|
||||
break;
|
||||
case 'quarter':
|
||||
case 'quarterly':
|
||||
$currentEnd->lastOfQuarter();
|
||||
break;
|
||||
case 'half-year':
|
||||
$month = intval($theCurrentEnd->format('m'));
|
||||
$currentEnd->endOfYear();
|
||||
if($month <= 6) {
|
||||
$currentEnd->subMonths(6);
|
||||
}
|
||||
break;
|
||||
case 'year':
|
||||
case 'yearly':
|
||||
$currentEnd->endOfYear();
|
||||
break;
|
||||
}
|
||||
|
||||
return $currentEnd;
|
||||
}
|
||||
|
||||
public function periodShow(Carbon $date, $repeatFrequency)
|
||||
{
|
||||
switch ($repeatFrequency) {
|
||||
@@ -107,13 +152,18 @@ class Date
|
||||
case 'daily':
|
||||
return $date->format('j F Y');
|
||||
break;
|
||||
case 'week':
|
||||
case 'weekly':
|
||||
return $date->format('\W\e\e\k W, Y');
|
||||
break;
|
||||
case 'quarter':
|
||||
return $date->format('F Y');
|
||||
break;
|
||||
case 'monthly':
|
||||
case 'month':
|
||||
return $date->format('F Y');
|
||||
break;
|
||||
case 'year':
|
||||
case 'yearly':
|
||||
return $date->format('Y');
|
||||
break;
|
||||
|
||||
@@ -85,6 +85,8 @@ class Reminders
|
||||
}
|
||||
}
|
||||
);
|
||||
$today = Carbon::now();
|
||||
//$today = new Carbon('15-12-2014');
|
||||
|
||||
/** @var \Piggybank $piggybank */
|
||||
foreach ($set as $piggybank) {
|
||||
@@ -95,8 +97,8 @@ class Reminders
|
||||
*/
|
||||
/** @var \PiggybankRepetition $repetition */
|
||||
$repetition = $piggybank->currentRelevantRep();
|
||||
$start = \DateKit::startOfPeriod(Carbon::now(), $piggybank->reminder);
|
||||
if ($repetition->targetdate && $repetition->targetdate <= Carbon::now()) {
|
||||
$start = \DateKit::startOfPeriod($today, $piggybank->reminder);
|
||||
if ($repetition->targetdate && $repetition->targetdate <= $today) {
|
||||
// break when no longer relevant:
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user