Various extensions to recurring transactions.

This commit is contained in:
James Cole
2018-06-26 18:49:33 +02:00
parent 7591f3fa29
commit 5d01955133
12 changed files with 88 additions and 17 deletions

View File

@@ -27,6 +27,7 @@ namespace FireflyIII\Http\Controllers\Recurring;
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\RecurrenceFormRequest;
use FireflyIII\Models\RecurrenceRepetition;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
use Illuminate\Http\Request;
@@ -89,10 +90,17 @@ class CreateController extends Controller
'until_date' => trans('firefly.repeat_until_date'),
'times' => trans('firefly.repeat_times'),
];
// what to do in the weekend?
$weekendResponses = [
RecurrenceRepetition::WEEKEND_DO_NOTHING => trans('firefly.do_nothing'),
RecurrenceRepetition::WEEKEND_SKIP_CREATION => trans('firefly.skip_transaction'),
RecurrenceRepetition::WEEKEND_TO_FRIDAY => trans('firefly.jump_to_friday'),
RecurrenceRepetition::WEEKEND_TO_MONDAY => trans('firefly.jump_to_monday'),
];
// flash some data:
$hasOldInput = null !== $request->old('_token');
$preFilled = [
$preFilled = [
'first_date' => $tomorrow->format('Y-m-d'),
'transaction_type' => $hasOldInput ? $request->old('transaction_type') : 'withdrawal',
'active' => $hasOldInput ? (bool)$request->old('active') : true,
@@ -100,7 +108,9 @@ class CreateController extends Controller
];
$request->session()->flash('preFilled', $preFilled);
return view('recurring.create', compact('tomorrow', 'oldRepetitionType', 'preFilled', 'repetitionEnds', 'defaultCurrency', 'budgets'));
return view(
'recurring.create', compact('tomorrow', 'oldRepetitionType', 'weekendResponses', 'preFilled', 'repetitionEnds', 'defaultCurrency', 'budgets')
);
}
/**

View File

@@ -110,6 +110,7 @@ class IndexController extends Controller
$repetition->repetition_type = $repetitionType;
$repetition->repetition_moment = $repetitionMoment;
$repetition->repetition_skip = (int)$request->get('skip');
$repetition->weekend = (int)$request->get('weekend');
$actualEnd = clone $end;
switch ($endsAt) {
@@ -222,8 +223,9 @@ class IndexController extends Controller
'daily' => ['label' => trans('firefly.recurring_daily'), 'selected' => 0 === strpos($preSelected, 'daily')],
$weekly => ['label' => trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]), 'selected' => 0 === strpos($preSelected, 'weekly')],
$monthly => ['label' => trans('firefly.recurring_monthly', ['dayOfMonth' => $date->day]), 'selected' => 0 === strpos($preSelected, 'monthly')],
$ndom => ['label' => trans('firefly.recurring_ndom', ['weekday' => $dayOfWeek, 'dayOfMonth' => $date->weekOfMonth]),'selected' => 0 === strpos($preSelected, 'ndom')],
$yearly => ['label' => trans('firefly.recurring_yearly', ['date' => $yearlyDate]),'selected' => 0 === strpos($preSelected, 'yearly')],
$ndom => ['label' => trans('firefly.recurring_ndom', ['weekday' => $dayOfWeek, 'dayOfMonth' => $date->weekOfMonth]),
'selected' => 0 === strpos($preSelected, 'ndom')],
$yearly => ['label' => trans('firefly.recurring_yearly', ['date' => $yearlyDate]), 'selected' => 0 === strpos($preSelected, 'yearly')],
];
}