Skip to content

Firefly III: a personal finances manager

Small experimental cleaning up.

James Cole1887977b929c
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 .= '<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));
diff --git a/app/views/partials/menu.blade.php b/app/views/partials/menu.blade.php
index 05ed6c3bbd..07c825d9e3 100644
--- a/app/views/partials/menu.blade.php
+++ b/app/views/partials/menu.blade.php
@@ -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 -->