mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-19 10:53:31 +00:00
Build some transaction handling.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
/**
|
||||
@@ -319,47 +318,51 @@ class TransactionController extends BaseController
|
||||
*/
|
||||
public function update(TransactionJournal $journal)
|
||||
{
|
||||
throw new NotImplementedException;
|
||||
// switch (Input::get('post_submit_action')) {
|
||||
// case 'update':
|
||||
// case 'return_to_edit':
|
||||
// $what = strtolower($journal->transactionType->type);
|
||||
// $messageBag = $this->_helper->update($journal, Input::all());
|
||||
// if ($messageBag->count() == 0) {
|
||||
// // has been saved, return to index:
|
||||
// Session::flash('success', 'Transaction updated!');
|
||||
// Event::fire('journals.update', [$journal]);
|
||||
//
|
||||
// if (Input::get('post_submit_action') == 'return_to_edit') {
|
||||
// return Redirect::route('transactions.edit', $journal->id)->withInput();
|
||||
// } else {
|
||||
// return Redirect::route('transactions.index.' . $what);
|
||||
// }
|
||||
// } else {
|
||||
// Session::flash('error', 'Could not update transaction: ' . $journal->errors()->first());
|
||||
//
|
||||
// return Redirect::route('transactions.edit', $journal->id)->withInput()->withErrors(
|
||||
// $journal->errors()
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// case 'validate_only':
|
||||
// $data = Input::all();
|
||||
// $data['what'] = strtolower($journal->transactionType->type);
|
||||
// $messageBags = $this->_helper->validate($data);
|
||||
//
|
||||
// Session::flash('warnings', $messageBags['warnings']);
|
||||
// Session::flash('successes', $messageBags['successes']);
|
||||
// Session::flash('errors', $messageBags['errors']);
|
||||
//
|
||||
// return Redirect::route('transactions.edit', $journal->id)->withInput();
|
||||
// break;
|
||||
// default:
|
||||
// throw new FireflyException('Method ' . Input::get('post_submit_action') . ' not implemented yet.');
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
/** @var \FireflyIII\Database\TransactionJournal $repos */
|
||||
$repos = App::make('FireflyIII\Database\TransactionJournal');
|
||||
|
||||
$data = Input::except('_token');
|
||||
$data['currency'] = 'EUR';
|
||||
$data['what'] = strtolower($journal->transactionType->type);
|
||||
|
||||
|
||||
switch (Input::get('post_submit_action')) {
|
||||
case 'update':
|
||||
case 'return_to_edit':
|
||||
$messageBag = $repos->update($journal, $data);
|
||||
if ($messageBag->count() == 0) {
|
||||
// has been saved, return to index:
|
||||
Session::flash('success', 'Transaction updated!');
|
||||
// Event::fire('journals.update', [$journal]);
|
||||
|
||||
if (Input::get('post_submit_action') == 'return_to_edit') {
|
||||
return Redirect::route('transactions.edit', $journal->id)->withInput();
|
||||
} else {
|
||||
return Redirect::route('transactions.index', $data['what']);
|
||||
}
|
||||
} else {
|
||||
Session::flash('error', 'Could not update transaction: ' . $journal->errors()->first());
|
||||
|
||||
return Redirect::route('transactions.edit', $journal->id)->withInput()->withErrors(
|
||||
$journal->errors()
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'validate_only':
|
||||
$messageBags = $repos->validate($data);
|
||||
|
||||
Session::flash('warnings', $messageBags['warnings']);
|
||||
Session::flash('successes', $messageBags['successes']);
|
||||
Session::flash('errors', $messageBags['errors']);
|
||||
|
||||
return Redirect::route('transactions.edit', $journal->id)->withInput();
|
||||
break;
|
||||
default:
|
||||
throw new FireflyException('Method ' . Input::get('post_submit_action') . ' not implemented yet.');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user