Some more stats on the piggy banks.

This commit is contained in:
Sander Dorigo 2014-10-29 12:39:15 +01:00
parent 0707603b63
commit d5e1da5948
2 changed files with 29 additions and 15 deletions

View File

@ -62,7 +62,7 @@ class PiggybankController extends BaseController
View::share('mainTitleIcon', 'fa-sort-amount-asc'); View::share('mainTitleIcon', 'fa-sort-amount-asc');
return View::make('piggybanks.create-piggybank')->with('accounts', $accounts) return View::make('piggybanks.create-piggybank')->with('accounts', $accounts)
->with('periods', $periods); ->with('periods', $periods);
} }
/** /**
@ -148,14 +148,14 @@ class PiggybankController extends BaseController
View::share('mainTitleIcon', 'fa-rotate-left'); View::share('mainTitleIcon', 'fa-rotate-left');
return View::make('piggybanks.edit-repeated')->with('piggybank', $piggyBank)->with('accounts', $accounts) return View::make('piggybanks.edit-repeated')->with('piggybank', $piggyBank)->with('accounts', $accounts)
->with('periods', $periods); ->with('periods', $periods);
} else { } else {
// piggy bank. // piggy bank.
View::share('title', 'Piggy banks'); View::share('title', 'Piggy banks');
View::share('mainTitleIcon', 'fa-sort-amount-asc'); View::share('mainTitleIcon', 'fa-sort-amount-asc');
return View::make('piggybanks.edit-piggybank')->with('piggybank', $piggyBank)->with('accounts', $accounts) return View::make('piggybanks.edit-piggybank')->with('piggybank', $piggyBank)->with('accounts', $accounts)
->with('periods', $periods); ->with('periods', $periods);
} }
@ -196,11 +196,11 @@ class PiggybankController extends BaseController
} }
break; break;
} }
if($piggyBank->repeats == 1) { if ($piggyBank->repeats == 1) {
$route = 'piggybanks.index.repeated'; $route = 'piggybanks.index.repeated';
} else { } else {
$route = 'piggybanks.index.piggybanks'; $route = 'piggybanks.index.piggybanks';
} }
return Redirect::route($route); return Redirect::route($route);
} }
@ -225,7 +225,15 @@ class PiggybankController extends BaseController
$id = $account->id; $id = $account->id;
if (!isset($accounts[$id])) { if (!isset($accounts[$id])) {
$account->leftOnAccount = $this->_repository->leftOnAccount($account); $account->leftOnAccount = $this->_repository->leftOnAccount($account);
$accounts[$id] = ['account' => $account, 'left' => $this->_repository->leftOnAccount($account)]; $accounts[$id] = [
'account' => $account,
'left' => $this->_repository->leftOnAccount($account),
'tosave' => $piggybank->targetamount,
'saved' => $piggybank->currentRelevantRep()->currentamount
];
} else {
$accounts[$id]['tosave'] += $piggybank->targetamount;
$accounts[$id]['saved'] += $piggybank->currentRelevantRep()->currentamount;
} }
} }
@ -234,9 +242,9 @@ class PiggybankController extends BaseController
View::share('mainTitleIcon', 'fa-sort-amount-asc'); View::share('mainTitleIcon', 'fa-sort-amount-asc');
return View::make('piggybanks.index')->with('piggybanks', $piggybanks) return View::make('piggybanks.index')->with('piggybanks', $piggybanks)
->with('countRepeating', $countRepeating) ->with('countRepeating', $countRepeating)
->with('countNonRepeating', $countNonRepeating) ->with('countNonRepeating', $countNonRepeating)
->with('accounts', $accounts); ->with('accounts', $accounts);
} }
/** /**
@ -285,9 +293,9 @@ class PiggybankController extends BaseController
return View::make('piggybanks.index')->with('piggybanks', $piggybanks) return View::make('piggybanks.index')->with('piggybanks', $piggybanks)
->with('countRepeating', $countRepeating) ->with('countRepeating', $countRepeating)
->with('countNonRepeating', $countNonRepeating) ->with('countNonRepeating', $countNonRepeating)
->with('accounts', $accounts); ->with('accounts', $accounts);
} }
/** /**
@ -311,7 +319,7 @@ class PiggybankController extends BaseController
} }
return View::make('piggybanks.show')->with('piggyBank', $piggyBank)->with('leftOnAccount', $leftOnAccount) return View::make('piggybanks.show')->with('piggyBank', $piggyBank)->with('leftOnAccount', $leftOnAccount)
->with('balance', $balance); ->with('balance', $balance);
} }
/** /**

View File

@ -186,17 +186,23 @@
--}} --}}
<div class="row"> <div class="row">
<div class="col-lg-6"> <div class="col-lg-12">
<h4>Account information</h4> <h4>Account information</h4>
<table class="table"> <table class="table">
<tr> <tr>
<th>Account</th> <th>Account</th>
<th>Left for piggy banks</th> <th>Left for piggy banks</th>
<th>Total planned savings</th>
<th>Saved so far</th>
<th>Left to save</th>
</tr> </tr>
@foreach($accounts as $account) @foreach($accounts as $account)
<tr> <tr>
<td>{{{$account['account']->name}}}</td> <td>{{{$account['account']->name}}}</td>
<td>{{mf($account['left'])}}</td> <td>{{mf($account['left'])}}</td>
<td>{{mf($account['tosave'])}}</td>
<td>{{mf($account['saved'])}}</td>
<td>{{mf($account['tosave']-$account['saved'])}}</td>
</tr> </tr>
@endforeach @endforeach
</table> </table>