mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Small experimental cleaning up.
This commit is contained in:
parent
8eb84acf4f
commit
1887977b92
@ -248,7 +248,6 @@ class TransactionController extends BaseController
|
||||
$data['transaction_currency_id'] = $transactionCurrency->id;
|
||||
$data['completed'] = 0;
|
||||
$data['what'] = $what;
|
||||
$data['currency'] = 'EUR';
|
||||
$messages = $this->_repository->validate($data);
|
||||
|
||||
Session::flash('warnings', $messages['warnings']);
|
||||
@ -256,6 +255,7 @@ class TransactionController extends BaseController
|
||||
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') {
|
||||
|
@ -63,11 +63,11 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
$currency = $this->getJournalCurrency($data['currency']);
|
||||
$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.
|
||||
*
|
||||
|
@ -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 .= '<div class="input-group"><div class="input-group-addon">' . \Amount::getCurrencySymbol() . '</div>';
|
||||
// currency button:
|
||||
$defaultCurrency = \Amount::getDefaultCurrency();
|
||||
$html .=
|
||||
'<div class="input-group"><div class="input-group-btn"><button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">'
|
||||
. $defaultCurrency->symbol . ' <span class="caret"></span></button>';
|
||||
// all currencies:
|
||||
$list = \TransactionCurrency::where('name', '!=', $defaultCurrency->name)->get();
|
||||
$html .= '<ul class="dropdown-menu" role="menu">';
|
||||
foreach ($list as $entry) {
|
||||
$html .= '<li><a href="#">' . e($entry->name) . '</a></li>';
|
||||
}
|
||||
$html .= ' </ul></div>';
|
||||
//$html .= '<div class="input-group"><div class="input-group-addon">' . \Amount::getCurrencySymbol() . '</div>';
|
||||
$html .= \Form::input('number', $name, $value, $options);
|
||||
$html .= '</div>';
|
||||
break;
|
||||
@ -204,7 +216,9 @@ class Form
|
||||
return $options['label'];
|
||||
}
|
||||
$labels = ['amount_min' => 'Amount (min)', 'amount_max' => 'Amount (max)', 'match' => 'Matches on', 'repeat_freq' => 'Repetition',
|
||||
'account_from_id' => 'Account from', 'account_to_id' => 'Account to', 'account_id' => 'Asset account'];
|
||||
'account_from_id' => 'Account from', 'account_to_id' => 'Account to', 'account_id' => 'Asset account','budget_id' => 'Budget'
|
||||
,'piggy_bank_id' => 'Piggy bank'];
|
||||
|
||||
|
||||
return isset($labels[$name]) ? $labels[$name] : str_replace('_', ' ', ucfirst($name));
|
||||
|
||||
|
@ -177,7 +177,7 @@
|
||||
<a @if($isTransfer)class="active"@endif href="{{route('transactions.create','transfer')}}"><i class="fa fa-arrows-h fa-fw"></i> Transfer</a>
|
||||
</li>
|
||||
<li>
|
||||
<a @if($isBill)class="active"@endif href="{{route('bills.create')}}"><i class="fa fa-rotate-right fa-fw"></i> Bills</a>
|
||||
<a @if($isBill)class="active"@endif href="{{route('bills.create')}}"><i class="fa fa-calendar-o fa-fw"></i> Bill</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- /.nav-second-level -->
|
||||
|
Loading…
Reference in New Issue
Block a user