Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Various bug fixes.
James Cole3bbecfe830d5
diff --git a/app/controllers/JsonController.php b/app/controllers/JsonController.phpindex d74a923a8a..3e62c3470c 100644--- a/app/controllers/JsonController.php+++ b/app/controllers/JsonController.php@@ -184,7 +184,7 @@ class JsonController extends BaseController* Build query:*/$query = \TransactionJournal::transactionTypes($parameters['transactionTypes'])->withRelevantData();-+ $query->where('completed',1);/** This is complex. Join `transactions` twice, once for the "to" account and once for the* "from" account. Then get the amount from one of these (depends on type).diff --git a/app/controllers/SearchController.php b/app/controllers/SearchController.phpindex c3ad87bbf3..205933400b 100644--- a/app/controllers/SearchController.php+++ b/app/controllers/SearchController.php@@ -21,20 +21,30 @@ class SearchController extends BaseControllerpublic function index(){$subTitle = null;+ $rawQuery = null;+ $result = [];if (!is_null(Input::get('q'))) {$rawQuery = trim(Input::get('q'));$words = explode(' ', $rawQuery);$subTitle = 'Results for "' . e($rawQuery) . '"';- /*- * Search for transactions:- */- $result = $this->_helper->transactions($words);+ $transactions = $this->_helper->searchTransactions($words);+ $accounts = $this->_helper->searchAccounts($words);+ $categories = $this->_helper->searchCategories($words);+ $budgets = $this->_helper->searchBudgets($words);+ $tags = $this->_helper->searchTags($words);+ $result = [+ 'transactions' => $transactions,+ 'accounts' => $accounts,+ 'categories' => $categories,+ 'budgets' => $budgets,+ 'tags' => $tags+ ];}return View::make('search.index')->with('title', 'Search')->with('subTitle', $subTitle)->with('mainTitleIcon', 'fa-search'- );+ )->with('query', $rawQuery)->with('result',$result);}}\ No newline at end of filediff --git a/app/lib/Firefly/Helper/Controllers/Search.php b/app/lib/Firefly/Helper/Controllers/Search.phpindex 03ece09fed..743f109121 100644--- a/app/lib/Firefly/Helper/Controllers/Search.php+++ b/app/lib/Firefly/Helper/Controllers/Search.php@@ -8,6 +8,8 @@namespace Firefly\Helper\Controllers;+use Illuminate\Support\Collection;+/*** Class Search*@@ -18,26 +20,89 @@ class Search implements SearchInterface/*** @param array $words+ *+ * @return Collection*/- public function transactions(array $words)+ public function searchTransactions(array $words){- $query = \TransactionJournal::withRelevantData();-- $fullCount = $query->count();-- $query->where(+ return \Auth::user()->transactionjournals()->withRelevantData()->where(function ($q) use ($words) {foreach ($words as $word) {$q->orWhere('description', 'LIKE', '%' . e($word) . '%');}}+ )->get();+ }++ /**+ * @param array $words+ *+ * @return Collection+ */+ public function searchAccounts(array $words)+ {+ return \Auth::user()->accounts()->with('accounttype')->where(+ function ($q) use ($words) {+ foreach ($words as $word) {+ $q->orWhere('name', 'LIKE', '%' . e($word) . '%');+ }+ }+ )->get();+ }++ /**+ * @param array $words+ *+ * @return Collection+ */+ public function searchCategories(array $words)+ {+ /** @var Collection $set */+ $set = \Auth::user()->categories()->get();+ $newSet = $set->filter(+ function (\Category $c) use ($words) {+ $found = 0;+ foreach ($words as $word) {+ if (!(strpos(strtolower($c->name), strtolower($word)) === false)) {+ $found++;+ }+ }+ return $found > 0;+ }+ );+ return $newSet;+ }++ /**+ * @param array $words+ *+ * @return Collection+ */+ public function searchBudgets(array $words)+ {+ /** @var Collection $set */+ $set = \Auth::user()->budgets()->get();+ $newSet = $set->filter(+ function (\Budget $b) use ($words) {+ $found = 0;+ foreach ($words as $word) {+ if (!(strpos(strtolower($b->name), strtolower($word)) === false)) {+ $found++;+ }+ }+ return $found > 0;+ });- $count = $query->count();- $set = $query->get();- /*- * Build something with JSON?- */- return $set;+ return $newSet;}-}\ No newline at end of file+ /**+ * @param array $words+ *+ * @return Collection+ */+ public function searchTags(array $words)+ {+ return new Collection;+ }+}\ No newline at end of filediff --git a/app/lib/Firefly/Helper/Controllers/SearchInterface.php b/app/lib/Firefly/Helper/Controllers/SearchInterface.phpindex 3c0e5b78f2..51b925d146 100644--- a/app/lib/Firefly/Helper/Controllers/SearchInterface.php+++ b/app/lib/Firefly/Helper/Controllers/SearchInterface.php@@ -18,5 +18,26 @@ interface SearchInterface/*** @param array $words*/- public function transactions(array $words);-}\ No newline at end of file+ public function searchTransactions(array $words);++ /**+ * @param array $words+ */+ public function searchAccounts(array $words);++ /**+ * @param array $words+ */+ public function searchCategories(array $words);++ /**+ * @param array $words+ */+ public function searchBudgets(array $words);++ /**+ * @param array $words+ */+ public function searchTags(array $words);++}\ No newline at end of filediff --git a/app/models/LimitRepetition.php b/app/models/LimitRepetition.phpindex c44ec99b06..943512aed4 100644--- a/app/models/LimitRepetition.php+++ b/app/models/LimitRepetition.php@@ -42,7 +42,7 @@ class LimitRepetition extends Ardent/*** How much money is left in this?*/- public function left()+ public function leftInRepetition(){$left = floatval($this->amount);diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.phpindex 9bd8ec33b7..3a6e000df9 100644--- a/app/models/TransactionJournal.php+++ b/app/models/TransactionJournal.php@@ -211,6 +211,10 @@ use LaravelBook\Ardent\Builder;* 'Budget[] $budgets* @property-read \Illuminate\Database\Eloquent\Collection|\* 'Category[] $categories+ * @property-read \Illuminate\Database\Eloquent\Collection|\+ * 'Budget[] $budgets+ * @property-read \Illuminate\Database\Eloquent\Collection|\+ * 'Category[] $categories*/class TransactionJournal extends Ardent{diff --git a/app/views/budgets/indexByBudget.blade.php b/app/views/budgets/indexByBudget.blade.phpindex 96bd10c9f8..c4596e92a6 100644--- a/app/views/budgets/indexByBudget.blade.php+++ b/app/views/budgets/indexByBudget.blade.php@@ -58,14 +58,14 @@{{mf($rep->amount,false)}}</span></div><div class="col-sm-2">- @if($rep->left < 0)+ @if($rep->leftInRepetition() < 0)<span class="label label-danger"><span class="glyphicon glyphicon-envelope"></span>- {{mf($rep->left,false)}}</span>+ {{mf($rep->leftInRepetition(),false)}}</span>@else<span class="label label-success"><span class="glyphicon glyphicon-envelope"></span>- {{mf($rep->left,false)}}</span>+ {{mf($rep->leftInRepetition(),false)}}</span>@endif</div><div class="col-sm-3">diff --git a/app/views/budgets/show.blade.php b/app/views/budgets/show.blade.phpindex 96ed5af5e6..5be4b68fa6 100644--- a/app/views/budgets/show.blade.php+++ b/app/views/budgets/show.blade.php@@ -77,7 +77,8 @@{{$repetition['date']}}</a></h4>- <small>{{mf($repetition['limit']->amount,false)}} (left: {{mf($repetition['limitrepetition']->left(),false)}})</small>+ <small>{{mf($repetition['limit']->amount,false)}}+ (left: {{mf($repetition['limitrepetition']->leftInRepetition(),false)}})</small>@endif</h4>@if($repetition['paginated'] == true)diff --git a/app/views/search/index.blade.php b/app/views/search/index.blade.phpindex 282e6418d8..5ac821defb 100644--- a/app/views/search/index.blade.php+++ b/app/views/search/index.blade.php@@ -1,49 +1,87 @@@extends('layouts.default')@section('content')+@if(!is_null($query))<div class="row">+ @if(isset($result['transactions']) && $result['transactions']->count() > 0)<div class="col-lg-6 col-md-12 col-sm-12"><div class="panel panel-default"><div class="panel-heading">- <i class="fa fa-repeat"></i> Transactions+ <i class="fa fa-repeat"></i> Transactions ({{$result['transactions']->count()}})</div><div class="panel-body">- <p>Bla bla</p>+ @include('transactions.journals-small-noaccount',['transactions' => $result['transactions']])</div></div>+ </div>+ @endif+ @if(isset($result['categories']) && $result['categories']->count() > 0)+ <div class="col-lg-6 col-md-12 col-sm-12"><div class="panel panel-default"><div class="panel-heading">- <i class="fa fa-bar-chart"></i> Categories+ <i class="fa fa-bar-chart"></i> Categories ({{$result['categories']->count()}})</div><div class="panel-body">- <p>Bla bla</p>+ <div class="list-group">+ @foreach($result['categories'] as $category)+ <a class="list-group-item" title="{{$category->name}}" href="{{route('categories.show',$category->id)}}">+ {{{$category->name}}}+ </a>+ @endforeach+ </div></div></div>+ </div>+ @endif+ @if(isset($result['tags']) && $result['tags']->count() > 0)+ <div class="col-lg-6 col-md-12 col-sm-12"><div class="panel panel-default"><div class="panel-heading">- <i class="fa fa-bar-chart"></i> Tags+ <i class="fa fa-bar-chart"></i> Tags ({{$result['tags']->count()}})</div><div class="panel-body"><p>Bla bla</p></div></div></div>+ @endif+ @if(isset($result['accounts']) && $result['accounts']->count() > 0)<div class="col-lg-6 col-md-12 col-sm-12"><div class="panel panel-default"><div class="panel-heading">- <i class="fa fa-credit-card"></i> Accounts+ <i class="fa fa-credit-card"></i> Accounts ({{$result['accounts']->count()}})</div><div class="panel-body">- <p>Bla bla</p>+ <div class="list-group">+ @foreach($result['accounts'] as $account)+ <a class="list-group-item" title="{{$account->name}}" href="{{route('accounts.show',$account->id)}}">+ {{{$account->name}}}+ </a>+ @endforeach+ </div></div></div>+ </div>+ @endif+ @if(isset($result['budgets']) && $result['budgets']->count() > 0)+ <div class="col-lg-6 col-md-12 col-sm-12"><div class="panel panel-default"><div class="panel-heading">- <i class="fa fa-tasks"></i> Budgets+ <i class="fa fa-tasks"></i> Budgets ({{$result['budgets']->count()}})</div><div class="panel-body">- <p>Bla bla</p>+ <div class="list-group">+ @foreach($result['budgets'] as $budget)+ <a class="list-group-item" title="{{$budget->name}}" href="{{route('budgets.show',$budget->id)}}">+ {{{$budget->name}}}+ </a>+ @endforeach+ </div></div></div>+ </div>+ @endif+ <!--+ <div class="col-lg-6 col-md-12 col-sm-12"><div class="panel panel-default"><div class="panel-heading"><i class="fa fa-search-plus"></i> Other results@@ -53,8 +91,15 @@</div></div></div>+ --></div>+@endif+@stop+@section('scripts')+<script type="text/javascript">+ var query = '{{{$query}}}';+</script>@stop\ No newline at end of filediff --git a/app/views/transactions/journals-small-index.blade.php b/app/views/transactions/journals-small-index.blade.phpindex ece329cca1..e8e5be5a4f 100644--- a/app/views/transactions/journals-small-index.blade.php+++ b/app/views/transactions/journals-small-index.blade.php@@ -16,10 +16,10 @@<span class="pull-right small">@foreach($journal->transactions as $t)- @if($t->account_id == $account->id)- {{mf($t->amount)}}- @endif- @endforeach+ @if($t->account_id == $account->id)+ {{mf($t->amount)}}+ @endif+ @endforeach</span></a>diff --git a/app/views/transactions/journals-small-noaccount.blade.php b/app/views/transactions/journals-small-noaccount.blade.phpindex 39786eb10a..0cb8c04855 100644--- a/app/views/transactions/journals-small-noaccount.blade.php+++ b/app/views/transactions/journals-small-noaccount.blade.php@@ -1,35 +1,33 @@-<table class="table table-bordered table-striped table-condensed">- <tr>- <th><small> </small></th>- <th><small>Description</small></th>- <th style="min-width:100px;"><small>Date</small></th>- <th style="min-width:80px;"><small>Amount</small></th>- </tr>+<div class="list-group">@foreach($transactions as $journal)- <tr>+<a class="list-group-item" title="{{$journal->date->format('jS M Y')}}" href="{{route('transactions.show',$journal->id)}}">- <td>- @if($journal->transactiontype->type == 'Withdrawal')- <span class="glyphicon glyphicon-arrow-left" title="Withdrawal"></span>- @endif- @if($journal->transactiontype->type == 'Deposit')- <span class="glyphicon glyphicon-arrow-right" title="Deposit"></span>- @endif- @if($journal->transactiontype->type == 'Transfer')- <span class="glyphicon glyphicon-resize-full" title="Transfer"></span>- @endif+ @if($journal->transactiontype->type == 'Withdrawal')+ <i class="fa fa-long-arrow-left fa-fw" title="Withdrawal"></i>+ @endif+ @if($journal->transactiontype->type == 'Deposit')+ <i class="fa fa-long-arrow-right fa-fw" title="Deposit"></i>+ @endif+ @if($journal->transactiontype->type == 'Transfer')+ <i class="fa fa-arrows-h fa-fw" title="Transfer"></i>+ @endif- </td>- <td><small><a href="{{route('transactions.show',$journal->id)}}">{{{$journal->description}}}</a></small></td>- <td><small>{{$journal->date->format('jS M Y')}}</small></td>- <td><small>- @foreach($journal->transactions as $t)- @if($t->account_id == $account->id)- {{mf($t->amount)}}- @endif- @endforeach- </small>- </td>- </tr>+ {{{$journal->description}}}++<span class="pull-right small">+ @foreach($journal->transactions as $t)+ @if($journal->transactiontype->type == 'Withdrawal' && $t->amount < 0)+ {{mf($t->amount)}}+ @endif+ @if($journal->transactiontype->type == 'Deposit' && $t->amount > 0)+ {{mf($t->amount)}}+ @endif+ @if($journal->transactiontype->type == 'Transfer' && $t->amount > 0)+ {{mf($t->amount)}}+ @endif+ @endforeach+</span>++</a>@endforeach-</table>\ No newline at end of file+</div>\ No newline at end of filediff --git a/public/assets/javascript/firefly/index.js b/public/assets/javascript/firefly/index.jsindex 6cf42b88a5..26e245a0e9 100644--- a/public/assets/javascript/firefly/index.js+++ b/public/assets/javascript/firefly/index.js@@ -188,7 +188,9 @@ $(function () {cursor: 'pointer',events: {click: function (e) {- alert('klik!!');+ if(e.point.url != null) {+ window.location = e.point.url;+ }}},dataLabels: {