mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-06 18:02:42 +00:00
Code cleanup.
This commit is contained in:
@@ -290,11 +290,12 @@ class PiggyBankController extends BaseController
|
||||
Session::flash('errors', $messages['errors']);
|
||||
if ($messages['errors']->count() > 0) {
|
||||
Session::flash('error', 'Could not store piggy bank: ' . $messages['errors']->first());
|
||||
return Redirect::route('piggy_banks.create')->withInput();
|
||||
}
|
||||
|
||||
|
||||
// return to create screen:
|
||||
if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {
|
||||
if ($data['post_submit_action'] == 'validate_only') {
|
||||
return Redirect::route('piggy_banks.create')->withInput();
|
||||
}
|
||||
|
||||
|
||||
@@ -178,6 +178,8 @@ class RepeatedExpenseController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
|
||||
*
|
||||
* @param PiggyBank $repeatedExpense
|
||||
*
|
||||
* @return $this
|
||||
@@ -194,7 +196,6 @@ class RepeatedExpenseController extends BaseController
|
||||
$data['remind_me'] = isset($data['remind_me']) ? 1 : 0;
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
|
||||
// always validate:
|
||||
$messages = $this->_repository->validate($data);
|
||||
|
||||
Session::flash('warnings', $messages['warnings']);
|
||||
@@ -202,10 +203,11 @@ class RepeatedExpenseController extends BaseController
|
||||
Session::flash('errors', $messages['errors']);
|
||||
if ($messages['errors']->count() > 0) {
|
||||
Session::flash('error', 'Could not update repeated expense: ' . $messages['errors']->first());
|
||||
return Redirect::route('repeated.edit', $repeatedExpense->id)->withInput();
|
||||
}
|
||||
|
||||
// return to update screen:
|
||||
if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {
|
||||
if ($data['post_submit_action'] == 'validate_only') {
|
||||
return Redirect::route('repeated.edit', $repeatedExpense->id)->withInput();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,15 +48,15 @@ class ReportController extends BaseController
|
||||
} catch (Exception $e) {
|
||||
return View::make('error')->with('message', 'Invalid date');
|
||||
}
|
||||
$date = new Carbon($year . '-' . $month . '-01');
|
||||
$dayEarly = clone $date;
|
||||
$date = new Carbon($year . '-' . $month . '-01');
|
||||
$dayEarly = clone $date;
|
||||
$subTitle = 'Budget report for ' . $date->format('F Y');
|
||||
$subTitleIcon = 'fa-calendar';
|
||||
$dayEarly = $dayEarly->subDay();
|
||||
$accounts = $this->_repository->getAccountListBudgetOverview($date);
|
||||
$budgets = $this->_repository->getBudgetsForMonth($date);
|
||||
$dayEarly = $dayEarly->subDay();
|
||||
$accounts = $this->_repository->getAccountListBudgetOverview($date);
|
||||
$budgets = $this->_repository->getBudgetsForMonth($date);
|
||||
|
||||
return View::make('reports.budget', compact('subTitle','subTitleIcon','date', 'accounts', 'budgets', 'dayEarly'));
|
||||
return View::make('reports.budget', compact('subTitle', 'subTitleIcon', 'date', 'accounts', 'budgets', 'dayEarly'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -230,6 +230,8 @@ class TransactionController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
|
||||
*
|
||||
* @param $what
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
@@ -245,8 +247,6 @@ class TransactionController extends BaseController
|
||||
$data['completed'] = 0;
|
||||
$data['what'] = $what;
|
||||
$data['currency'] = 'EUR';
|
||||
|
||||
// always validate:
|
||||
$messages = $this->_repository->validate($data);
|
||||
|
||||
Session::flash('warnings', $messages['warnings']);
|
||||
@@ -257,17 +257,13 @@ class TransactionController extends BaseController
|
||||
return Redirect::route('transactions.create', $data['what'])->withInput();
|
||||
}
|
||||
|
||||
// return to create screen:
|
||||
if ($data['post_submit_action'] == 'validate_only') {
|
||||
return Redirect::route('transactions.create', $data['what'])->withInput();
|
||||
}
|
||||
|
||||
// store
|
||||
$journal = $this->_repository->store($data);
|
||||
Event::fire('transactionJournal.store', [$journal, Input::get('piggy_bank_id')]); // new and used.
|
||||
/*
|
||||
* Also trigger on both transactions.
|
||||
*/
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
Event::fire('transaction.store', [$transaction]);
|
||||
@@ -303,8 +299,9 @@ class TransactionController extends BaseController
|
||||
Session::flash('errors', $messages['errors']);
|
||||
if ($messages['errors']->count() > 0) {
|
||||
Session::flash('error', 'Could not update transaction: ' . $messages['errors']->first());
|
||||
return Redirect::route('transactions.edit', $journal->id)->withInput();
|
||||
}
|
||||
if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {
|
||||
if ($data['post_submit_action'] == 'validate_only') {
|
||||
return Redirect::route('transactions.edit', $journal->id)->withInput();
|
||||
}
|
||||
$this->_repository->update($journal, $data);
|
||||
|
||||
Reference in New Issue
Block a user