Start recurring on date provided by user through TransactionWizard component, instead of today
MODIFY
app/Http/Controllers/RecurringController.php
app/Http/Controllers/RecurringController.php
@@ -52,6 +52,7 @@ class RecurringController extends Controller
$request->type,
$request->interval,
(int) ltrim($request->input('day'), 0),
+ $request->start,
$request->input('end', null),
$request->input('tag', null),
$request->input('description'),

MODIFY
app/Repositories/RecurringRepository.php
app/Repositories/RecurringRepository.php
@@ -16,6 +16,7 @@ class RecurringRepository
'day' => ['required',
'regex:/\b(0?[1-9]|[12][0-9]|3[01])\b/',
],
+ 'start' => 'date|date_format:Y-m-d',
'end' => 'nullable|date|date_format:Y-m-d',
'tag' => 'nullable|exists:tags,id', // TODO CHECK IF TAG BELONGS TO USER
'description' => 'required|max:255',
@@ -158,6 +159,7 @@ class RecurringRepository
string $type,
string $interval,
int $day,
+ string $startDate,
?string $endDate,
?int $tagId,
string $description,
@@ -176,7 +178,7 @@ class RecurringRepository
'type' => $type,
'interval' => $interval,
'day' => $day,
- 'starts_on' => date('Y-m-d'),
+ 'starts_on' => $startDate,
'ends_on' => $endDate,
'tag_id' => $tagId,
'description' => $description,

MODIFY
resources/assets/js/components/TransactionWizard.vue
resources/assets/js/components/TransactionWizard.vue
type: this.type,
interval: this.recurringInterval,
day: this.date.slice(-2),
+ start: this.date,
description: this.description,
amount: this.amount
}

MODIFY
tests/Feature/RecurringTest.php
tests/Feature/RecurringTest.php
@@ -34,6 +34,7 @@ class RecurringTest extends TestCase
'type' => 'spending',
'interval' => 'monthly',
'day' => 1,
+ 'start' => date('Y-m-d'),
'description' => 'Test',
'amount' => 123
];

MODIFY
tests/Unit/Repositories/RecurringRepositoryTest.php
tests/Unit/Repositories/RecurringRepositoryTest.php
@@ -29,7 +29,17 @@ class RecurringRepositoryTest extends TestCase
$spaceId = 1;
$tagId = 1;
- $recurring = $this->recurringRepository->create($spaceId, 'spending', 'monthly', 3, null, $tagId, 'Foo', 10000);
+ $recurring = $this->recurringRepository->create(
+ $spaceId,
+ 'spending',
+ 'monthly',
+ 3,
+ date('Y-m-d'),
+ null,
+ $tagId,
+ 'Foo',
+ 10000
+ );
$this->assertNotNull($recurring);
$this->assertEquals(10000, $recurring->amount);

Start recurring on date provided by user through TransactionWizard component, instead of today