diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.php index ce6a2afe22..c05c6ea0a8 100644 --- a/app/Http/Requests/RecurrenceFormRequest.php +++ b/app/Http/Requests/RecurrenceFormRequest.php @@ -79,14 +79,15 @@ class RecurrenceFormRequest extends Request ], 'meta' => [ // 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'), ], 'repetitions' => [ [ - 'type' => $repetitionData['type'], - 'moment' => $repetitionData['moment'], - 'skip' => $this->integer('skip'), + 'type' => $repetitionData['type'], + 'moment' => $repetitionData['moment'], + 'skip' => $this->integer('skip'), + 'weekend' => $this->integer('weekend'), ], ], diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.php index 0ae942e8f0..7d8e4b7b48 100644 --- a/app/Repositories/Recurring/RecurringRepository.php +++ b/app/Repositories/Recurring/RecurringRepository.php @@ -195,14 +195,18 @@ class RecurringRepository implements RecurringRepositoryInterface $skipMod = $repetition->repetition_skip + 1; $attempts = 0; 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) { default: throw new FireflyException( sprintf('Cannot calculate occurrences for recurring transaction repetition type "%s"', $repetition->repetition_type) ); case 'daily': + Log::debug('Rep is daily. Start of loop.'); while ($mutator <= $end) { + Log::debug(sprintf('Mutator is now: %s', $mutator->format('Y-m-d'))); if ($attempts % $skipMod === 0) { + Log::debug(sprintf('Attempts modulo skipmod is zero, include %s', $mutator->format('Y-m-d'))); $return[] = clone $mutator; } $mutator->addDay(); @@ -210,9 +214,10 @@ class RecurringRepository implements RecurringRepositoryInterface } break; case 'weekly': + Log::debug('Rep is weekly.'); // monday = 1 // sunday = 7 - $mutator->addDay(); // always assume today has passed. + $mutator->addDay(); // always assume today has passed. TODO why? $dayOfWeek = (int)$repetition->repetition_moment; if ($mutator->dayOfWeekIso > $dayOfWeek) { // day has already passed this week, add one week: diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.php index 6495c35577..4de55141ce 100644 --- a/app/Services/Internal/Support/RecurringTransactionTrait.php +++ b/app/Services/Internal/Support/RecurringTransactionTrait.php @@ -56,6 +56,7 @@ trait RecurringTransactionTrait 'repetition_type' => $array['type'], 'repetition_moment' => $array['moment'], 'repetition_skip' => $array['skip'], + 'weekend' => $array['weekend'] ?? 1, ] );