mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Expand support for weekend and add some logging.
This commit is contained in:
@@ -79,14 +79,15 @@ class RecurrenceFormRequest extends Request
|
|||||||
],
|
],
|
||||||
'meta' => [
|
'meta' => [
|
||||||
// tags and piggy bank ID.
|
// tags and piggy bank ID.
|
||||||
'tags' => '' !== $this->string('tags') ? explode(',', $this->string('tags')): [],
|
'tags' => '' !== $this->string('tags') ? explode(',', $this->string('tags')) : [],
|
||||||
'piggy_bank_id' => $this->integer('piggy_bank_id'),
|
'piggy_bank_id' => $this->integer('piggy_bank_id'),
|
||||||
],
|
],
|
||||||
'repetitions' => [
|
'repetitions' => [
|
||||||
[
|
[
|
||||||
'type' => $repetitionData['type'],
|
'type' => $repetitionData['type'],
|
||||||
'moment' => $repetitionData['moment'],
|
'moment' => $repetitionData['moment'],
|
||||||
'skip' => $this->integer('skip'),
|
'skip' => $this->integer('skip'),
|
||||||
|
'weekend' => $this->integer('weekend'),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@@ -195,14 +195,18 @@ class RecurringRepository implements RecurringRepositoryInterface
|
|||||||
$skipMod = $repetition->repetition_skip + 1;
|
$skipMod = $repetition->repetition_skip + 1;
|
||||||
$attempts = 0;
|
$attempts = 0;
|
||||||
Log::debug(sprintf('Calculating occurrences for rep type "%s"', $repetition->repetition_type));
|
Log::debug(sprintf('Calculating occurrences for rep type "%s"', $repetition->repetition_type));
|
||||||
|
Log::debug(sprintf('Mutator is now: %s', $mutator->format('Y-m-d')));
|
||||||
switch ($repetition->repetition_type) {
|
switch ($repetition->repetition_type) {
|
||||||
default:
|
default:
|
||||||
throw new FireflyException(
|
throw new FireflyException(
|
||||||
sprintf('Cannot calculate occurrences for recurring transaction repetition type "%s"', $repetition->repetition_type)
|
sprintf('Cannot calculate occurrences for recurring transaction repetition type "%s"', $repetition->repetition_type)
|
||||||
);
|
);
|
||||||
case 'daily':
|
case 'daily':
|
||||||
|
Log::debug('Rep is daily. Start of loop.');
|
||||||
while ($mutator <= $end) {
|
while ($mutator <= $end) {
|
||||||
|
Log::debug(sprintf('Mutator is now: %s', $mutator->format('Y-m-d')));
|
||||||
if ($attempts % $skipMod === 0) {
|
if ($attempts % $skipMod === 0) {
|
||||||
|
Log::debug(sprintf('Attempts modulo skipmod is zero, include %s', $mutator->format('Y-m-d')));
|
||||||
$return[] = clone $mutator;
|
$return[] = clone $mutator;
|
||||||
}
|
}
|
||||||
$mutator->addDay();
|
$mutator->addDay();
|
||||||
@@ -210,9 +214,10 @@ class RecurringRepository implements RecurringRepositoryInterface
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'weekly':
|
case 'weekly':
|
||||||
|
Log::debug('Rep is weekly.');
|
||||||
// monday = 1
|
// monday = 1
|
||||||
// sunday = 7
|
// sunday = 7
|
||||||
$mutator->addDay(); // always assume today has passed.
|
$mutator->addDay(); // always assume today has passed. TODO why?
|
||||||
$dayOfWeek = (int)$repetition->repetition_moment;
|
$dayOfWeek = (int)$repetition->repetition_moment;
|
||||||
if ($mutator->dayOfWeekIso > $dayOfWeek) {
|
if ($mutator->dayOfWeekIso > $dayOfWeek) {
|
||||||
// day has already passed this week, add one week:
|
// day has already passed this week, add one week:
|
||||||
|
@@ -56,6 +56,7 @@ trait RecurringTransactionTrait
|
|||||||
'repetition_type' => $array['type'],
|
'repetition_type' => $array['type'],
|
||||||
'repetition_moment' => $array['moment'],
|
'repetition_moment' => $array['moment'],
|
||||||
'repetition_skip' => $array['skip'],
|
'repetition_skip' => $array['skip'],
|
||||||
|
'weekend' => $array['weekend'] ?? 1,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user