mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-02-11 22:35:13 +00:00
Autoformat lol
This commit is contained in:
@@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Recurring;
|
||||
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Enums\RecurrenceRepetitionWeekend;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
@@ -36,6 +35,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\ExpandedForm;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Support\JsonApi\Enrichments\RecurringEnrichment;
|
||||
use FireflyIII\Transformers\RecurrenceTransformer;
|
||||
use FireflyIII\User;
|
||||
@@ -51,9 +51,9 @@ use Illuminate\View\View;
|
||||
*/
|
||||
class EditController extends Controller
|
||||
{
|
||||
private AttachmentHelperInterface $attachments;
|
||||
private BillRepositoryInterface $billRepository;
|
||||
private BudgetRepositoryInterface $budgetRepos;
|
||||
private AttachmentHelperInterface $attachments;
|
||||
private BillRepositoryInterface $billRepository;
|
||||
private BudgetRepositoryInterface $budgetRepos;
|
||||
private RecurringRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
@@ -64,20 +64,18 @@ class EditController extends Controller
|
||||
parent::__construct();
|
||||
|
||||
// translations:
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string) trans('firefly.recurrences'));
|
||||
$this->middleware(function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->repository = app(RecurringRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
$this->billRepository = app(BillRepositoryInterface::class);
|
||||
$this->repository = app(RecurringRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
$this->billRepository = app(BillRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,29 +88,29 @@ class EditController extends Controller
|
||||
public function edit(Request $request, Recurrence $recurrence): Factory|\Illuminate\Contracts\View\View
|
||||
{
|
||||
// TODO this should be in the repository.
|
||||
$count = $recurrence->recurrenceTransactions()->count();
|
||||
$count = $recurrence->recurrenceTransactions()->count();
|
||||
if (0 === $count) {
|
||||
throw new FireflyException('This recurring transaction has no meta-data. You will have to delete it and recreate it. Sorry!');
|
||||
}
|
||||
|
||||
// enrich
|
||||
/** @var User $admin */
|
||||
$admin = auth()->user();
|
||||
$enrichment = new RecurringEnrichment();
|
||||
$admin = auth()->user();
|
||||
$enrichment = new RecurringEnrichment();
|
||||
$enrichment->setUser($admin);
|
||||
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $enrichment->enrichSingle($recurrence);
|
||||
$recurrence = $enrichment->enrichSingle($recurrence);
|
||||
|
||||
/** @var RecurrenceTransformer $transformer */
|
||||
$transformer = app(RecurrenceTransformer::class);
|
||||
$array = $transformer->transform($recurrence);
|
||||
$budgets = ExpandedForm::makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||
$bills = ExpandedForm::makeSelectListWithEmpty($this->billRepository->getActiveBills());
|
||||
$transformer = app(RecurrenceTransformer::class);
|
||||
$array = $transformer->transform($recurrence);
|
||||
$budgets = ExpandedForm::makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||
$bills = ExpandedForm::makeSelectListWithEmpty($this->billRepository->getActiveBills());
|
||||
|
||||
/** @var RecurrenceRepetition $repetition */
|
||||
$repetition = $recurrence->recurrenceRepetitions()->first();
|
||||
$currentRepType = $repetition->repetition_type;
|
||||
$repetition = $recurrence->recurrenceRepetitions()->first();
|
||||
$currentRepType = $repetition->repetition_type;
|
||||
if ('' !== $repetition->repetition_moment) {
|
||||
$currentRepType = sprintf('%s,%s', $currentRepType, $repetition->repetition_moment);
|
||||
}
|
||||
@@ -123,11 +121,11 @@ class EditController extends Controller
|
||||
}
|
||||
$request->session()->forget('recurrences.edit.fromUpdate');
|
||||
|
||||
$repetitionEnd = 'forever';
|
||||
$repetitionEnds = [
|
||||
$repetitionEnd = 'forever';
|
||||
$repetitionEnds = [
|
||||
'forever' => (string) trans('firefly.repeat_forever'),
|
||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
||||
'times' => (string) trans('firefly.repeat_times'),
|
||||
'times' => (string) trans('firefly.repeat_times')
|
||||
];
|
||||
if (null !== $recurrence->repeat_until) {
|
||||
$repetitionEnd = 'until_date';
|
||||
@@ -136,33 +134,43 @@ class EditController extends Controller
|
||||
$repetitionEnd = 'times';
|
||||
}
|
||||
|
||||
$weekendResponses = [
|
||||
$weekendResponses = [
|
||||
RecurrenceRepetitionWeekend::WEEKEND_DO_NOTHING->value => (string) trans('firefly.do_nothing'),
|
||||
RecurrenceRepetitionWeekend::WEEKEND_SKIP_CREATION->value => (string) trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetitionWeekend::WEEKEND_TO_FRIDAY->value => (string) trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value => (string) trans('firefly.jump_to_monday'),
|
||||
RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value => (string) trans('firefly.jump_to_monday')
|
||||
];
|
||||
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'transaction_type' => strtolower((string) $recurrence->transactionType->type),
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active,
|
||||
'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules,
|
||||
'deposit_source_id' => $array['transactions'][0]['source_id'],
|
||||
'withdrawal_destination_id' => $array['transactions'][0]['destination_id'],
|
||||
'withdrawal_destination_id' => $array['transactions'][0]['destination_id']
|
||||
];
|
||||
$array['first_date'] = substr((string) $array['first_date'], 0, 10);
|
||||
$array['repeat_until'] = substr((string) $array['repeat_until'], 0, 10);
|
||||
$array['transactions'][0]['tags'] = implode(',', $array['transactions'][0]['tags'] ?? []);
|
||||
$array['first_date'] = substr((string) $array['first_date'], 0, 10);
|
||||
$array['repeat_until'] = substr((string) $array['repeat_until'], 0, 10);
|
||||
$array['transactions'][0]['tags'] = implode(',', $array['transactions'][0]['tags'] ?? []);
|
||||
$array['transactions'][0]['amount'] = round((float) $array['transactions'][0]['amount'], $array['transactions'][0]['currency_decimal_places']);
|
||||
if (null !== $array['transactions'][0]['foreign_amount'] && '' !== $array['transactions'][0]['foreign_amount']) {
|
||||
$array['transactions'][0]['foreign_amount'] = round((float) $array['transactions'][0]['foreign_amount'], $array['transactions'][0]['foreign_currency_decimal_places'] ?? 2);
|
||||
$array['transactions'][0]['foreign_amount'] = round(
|
||||
(float) $array['transactions'][0]['foreign_amount'],
|
||||
$array['transactions'][0]['foreign_currency_decimal_places'] ?? 2
|
||||
);
|
||||
}
|
||||
|
||||
return view(
|
||||
'recurring.edit',
|
||||
['recurrence' => $recurrence, 'array' => $array, 'bills' => $bills, 'weekendResponses' => $weekendResponses, 'budgets' => $budgets, 'preFilled' => $preFilled, 'currentRepType' => $currentRepType, 'repetitionEnd' => $repetitionEnd, 'repetitionEnds' => $repetitionEnds]
|
||||
);
|
||||
return view('recurring.edit', [
|
||||
'recurrence' => $recurrence,
|
||||
'array' => $array,
|
||||
'bills' => $bills,
|
||||
'weekendResponses' => $weekendResponses,
|
||||
'budgets' => $budgets,
|
||||
'preFilled' => $preFilled,
|
||||
'currentRepType' => $currentRepType,
|
||||
'repetitionEnd' => $repetitionEnd,
|
||||
'repetitionEnds' => $repetitionEnds
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,7 +190,7 @@ class EditController extends Controller
|
||||
|
||||
// store new attachment(s):
|
||||
/** @var null|array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($recurrence, $files);
|
||||
}
|
||||
@@ -195,7 +203,7 @@ class EditController extends Controller
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
|
||||
}
|
||||
Preferences::mark();
|
||||
$redirect = redirect($this->getPreviousUrl('recurrences.edit.url'));
|
||||
$redirect = redirect($this->getPreviousUrl('recurrences.edit.url'));
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
$request->session()->put('recurrences.edit.fromUpdate', true);
|
||||
|
||||
Reference in New Issue
Block a user