mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-05 21:53:08 -06:00
Fixed the tables (again) for account and for index.
This commit is contained in:
parent
96ab112b22
commit
a58a560bbb
@ -172,6 +172,9 @@ class AccountController extends BaseController
|
||||
*/
|
||||
public function index($what = 'default')
|
||||
{
|
||||
/** @var \FireflyIII\Database\Account $acct */
|
||||
$acct = App::make('FireflyIII\Database\Account');
|
||||
|
||||
switch ($what) {
|
||||
default:
|
||||
throw new FireflyException('Cannot handle account type "' . e($what) . '".');
|
||||
@ -179,18 +182,21 @@ class AccountController extends BaseController
|
||||
case 'asset':
|
||||
$subTitleIcon = 'fa-money';
|
||||
$subTitle = 'Asset accounts';
|
||||
$accounts = $acct->getAssetAccounts();
|
||||
break;
|
||||
case 'expense':
|
||||
$subTitleIcon = 'fa-shopping-cart';
|
||||
$subTitle = 'Expense accounts';
|
||||
$accounts = $acct->getExpenseAccounts();
|
||||
break;
|
||||
case 'revenue':
|
||||
$subTitleIcon = 'fa-download';
|
||||
$subTitle = 'Revenue accounts';
|
||||
$accounts = $acct->getRevenueAccounts();
|
||||
break;
|
||||
}
|
||||
|
||||
return View::make('accounts.index')->with('what', $what)->with(compact('subTitleIcon'))->with(compact('subTitle'));
|
||||
return View::make('accounts.index',compact('what','subTitleIcon','subTitle','accounts'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use LaravelBook\Ardent\Ardent as Ardent;
|
||||
use LaravelBook\Ardent\Builder;
|
||||
|
||||
@ -34,7 +35,7 @@ class Account extends Ardent
|
||||
* @var array
|
||||
*/
|
||||
public static $rules
|
||||
= ['name' => ['required', 'between:1,100', 'alphabasic'], 'user_id' => 'required|exists:users,id',
|
||||
= ['name' => ['required', 'between:1,100', 'alphabasic'], 'user_id' => 'required|exists:users,id',
|
||||
'account_type_id' => 'required|exists:account_types,id', 'active' => 'required|boolean'
|
||||
|
||||
];
|
||||
@ -64,21 +65,11 @@ class Account extends Ardent
|
||||
|
||||
return floatval(
|
||||
$this->transactions()->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transactions.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasMany('Transaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
@ -88,13 +79,36 @@ class Account extends Ardent
|
||||
{
|
||||
return floatval(
|
||||
$this->transactions()->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)->where('transaction_journals.date', '<=', $journal->date->format('Y-m-d'))->where(
|
||||
'transaction_journals.created_at', '<=', $journal->created_at->format('Y-m-d H:i:s')
|
||||
)->where('transaction_journals.id', '!=', $journal->id)->sum('transactions.amount')
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)->where('transaction_journals.date', '<=', $journal->date->format('Y-m-d'))->where(
|
||||
'transaction_journals.created_at', '<=', $journal->created_at->format('Y-m-d H:i:s')
|
||||
)->where('transaction_journals.id', '!=', $journal->id)->sum('transactions.amount')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Carbon
|
||||
*/
|
||||
public function lastActionDate()
|
||||
{
|
||||
$transaction = $this->transactions()->orderBy('updated_at', 'DESC')->first();
|
||||
if(is_null($transaction)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $transaction->updated_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transactions.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasMany('Transaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div id="account-list"></div>
|
||||
@include('list.accounts')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -101,7 +101,7 @@
|
||||
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
@include('lists.old.journals-small-index',['transactions' => $data[0],'account' => $data[1]])
|
||||
@include('list.journals-tiny',['transactions' => $data[0],'account' => $data[1]])
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
37
app/views/list/accounts.blade.php
Normal file
37
app/views/list/accounts.blade.php
Normal file
@ -0,0 +1,37 @@
|
||||
<table class="table table-bordered table-striped">
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Name</th>
|
||||
<th>Current balance</th>
|
||||
<th>Active</th>
|
||||
<th>Last activity</th>
|
||||
</tr>
|
||||
@foreach($accounts as $account)
|
||||
<tr>
|
||||
<td>
|
||||
<div class="btn-group btn-group-xs">
|
||||
<a class="btn btn-default btn-xs" href="{{route('accounts.edit',$account->id)}}"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
<a class="btn btn-danger btn-xs" href="{{route('accounts.delete',$account->id)}}"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
</div>
|
||||
</td>
|
||||
<td><a href="{{route('accounts.show',$account->id)}}">{{{$account->name}}}</a></td>
|
||||
<td>{{mf($account->balance())}}</td>
|
||||
<td>
|
||||
@if($account->active)
|
||||
<i class="fa fa-fw fa-check"></i>
|
||||
@else
|
||||
<i class="fa fa-fw fa-ban"></i>
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<?php $active = $account->lastActionDate(); ?>
|
||||
@if($active)
|
||||
{{{$active->format('j F Y @ H:i')}}}
|
||||
@else
|
||||
<em>Never</em>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@endforeach
|
||||
</table>
|
35
app/views/list/journals-tiny.blade.php
Normal file
35
app/views/list/journals-tiny.blade.php
Normal file
@ -0,0 +1,35 @@
|
||||
<div class="list-group">
|
||||
@foreach($transactions as $journal)
|
||||
<a class="list-group-item" title="{{$journal->date->format('jS M Y')}}" href="{{route('transactions.show',$journal->id)}}">
|
||||
|
||||
@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
|
||||
|
||||
{{{$journal->description}}}
|
||||
|
||||
<span class="pull-right small">
|
||||
@if(isset($account))
|
||||
@foreach($journal->transactions as $index => $t)
|
||||
@if($t->account_id == $account->id)
|
||||
{{mf($t->amount)}}
|
||||
@endif
|
||||
@endforeach
|
||||
@else
|
||||
@foreach($journal->transactions as $index => $t)
|
||||
@if($index == 0)
|
||||
{{mf($t->amount)}}
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
</span>
|
||||
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user