diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.php index 5be29c9855..91cd99c644 100644 --- a/app/controllers/TransactionController.php +++ b/app/controllers/TransactionController.php @@ -248,14 +248,14 @@ class TransactionController extends BaseController $data['transaction_currency_id'] = $transactionCurrency->id; $data['completed'] = 0; $data['what'] = $what; - $data['currency'] = 'EUR'; - $messages = $this->_repository->validate($data); + $messages = $this->_repository->validate($data); Session::flash('warnings', $messages['warnings']); Session::flash('successes', $messages['successes']); Session::flash('errors', $messages['errors']); if ($messages['errors']->count() > 0) { Session::flash('error', 'Could not store transaction: ' . $messages['errors']->first()); + return Redirect::route('transactions.create', $data['what'])->withInput(); } @@ -301,6 +301,7 @@ 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') { diff --git a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php b/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php index ce0cfbafcc..65b842871d 100644 --- a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php +++ b/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php @@ -63,11 +63,11 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C */ public function store(array $data) { - $currency = $this->getJournalCurrency($data['currency']); - $journal = new \TransactionJournal( + $journal = new \TransactionJournal( [ 'transaction_type_id' => $data['transaction_type_id'], - 'transaction_currency_id' => $currency->id, 'user_id' => $this->getUser()->id, + 'transaction_currency_id' => $data['transaction_currency_id'], + 'user_id' => $this->getUser()->id, 'description' => $data['description'], 'date' => $data['date'], 'completed' => 0] ); $journal->save(); @@ -178,19 +178,6 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C } - /** - * @param $currency - * - * @return null|\TransactionCurrency - */ - public function getJournalCurrency($currency) - { - /** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencyRepository */ - $currencyRepository = \App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency'); - - return $currencyRepository->findByCode($currency); - } - /** * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. * @@ -304,6 +291,19 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C return $typeRepository->findByWhat($type); } + /** + * @param $currency + * + * @return null|\TransactionCurrency + */ + public function getJournalCurrency($currency) + { + /** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencyRepository */ + $currencyRepository = \App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency'); + + return $currencyRepository->findByCode($currency); + } + /** * @SuppressWarnings("CamelCase") // I'm fine with this. * diff --git a/app/lib/FireflyIII/Form/Form.php b/app/lib/FireflyIII/Form/Form.php index 68409ab2df..2548b2d511 100644 --- a/app/lib/FireflyIII/Form/Form.php +++ b/app/lib/FireflyIII/Form/Form.php @@ -54,7 +54,7 @@ class Form /* * Make label and placeholder look nice. */ - $options['placeholder'] = ucfirst($name); + $options['placeholder'] = ucfirst($label); /* * Get pre filled value: @@ -123,7 +123,19 @@ class Form $html .= \Form::input('text', $name, $value, $options); break; case 'amount': - $html .= '