mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-23 09:26:29 -06:00
Fix the view for accounts.
This commit is contained in:
parent
935276af88
commit
5a920d5efd
@ -219,10 +219,11 @@ class AccountController extends BaseController
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param string $view
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function show(Account $account)
|
||||
public function show(Account $account, $view = 'session')
|
||||
{
|
||||
switch ($account->accountType->type) {
|
||||
case 'Asset account':
|
||||
@ -241,16 +242,19 @@ class AccountController extends BaseController
|
||||
// get a paginated view of all transactions for this account:
|
||||
/** @var \FireflyIII\Database\Account $acct */
|
||||
$acct = App::make('FireflyIII\Database\Account');
|
||||
if (Input::get('showAll') == 'true') {
|
||||
switch ($view) {
|
||||
default:
|
||||
case 'session':
|
||||
$journals = $acct->getTransactionJournals($account, 50);
|
||||
break;
|
||||
case 'all':
|
||||
$journals = $acct->getAllTransactionJournals($account, 50);
|
||||
|
||||
$journals = $acct->getAllTransactionJournals($account, 50);
|
||||
} else {
|
||||
$journals = $acct->getTransactionJournals($account, 50);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//$data = $this->_accounts->show($account, 40);
|
||||
return View::make('accounts.show', compact('account', 'subTitleIcon', 'journals'))->with('account', $account)->with(
|
||||
return View::make('accounts.show', compact('account', 'view', 'subTitleIcon', 'journals'))->with('account', $account)->with(
|
||||
'subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"'
|
||||
);
|
||||
}
|
||||
|
@ -10,18 +10,39 @@ class GoogleChartController extends BaseController
|
||||
/**
|
||||
* @param Account $account
|
||||
*/
|
||||
public function accountBalanceChart(Account $account)
|
||||
public function accountBalanceChart(Account $account, $view = 'session')
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
|
||||
$chart->addColumn('Day of month', 'date');
|
||||
$chart->addColumn('Balance for ' . $account->name, 'number');
|
||||
|
||||
/*
|
||||
* Loop the date, then loop the accounts, then add balance.
|
||||
*/
|
||||
$start = Session::get('start');
|
||||
$end = Session::get('end');
|
||||
switch ($view) {
|
||||
default:
|
||||
case 'session':
|
||||
$start = Session::get('start');
|
||||
$end = Session::get('end');
|
||||
break;
|
||||
case 'all':
|
||||
$first = $account->transactionjournals()->orderBy('date', 'DESC')->first();
|
||||
$last = $account->transactionjournals()->orderBy('date', 'ASC')->first();
|
||||
if (is_null($first)) {
|
||||
$start = Session::get('start');
|
||||
} else {
|
||||
$start = clone $first->date;
|
||||
}
|
||||
if (is_null($last)) {
|
||||
$end = Session::get('end');
|
||||
} else {
|
||||
$end = clone $last->date;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$current = clone $start;
|
||||
|
||||
while ($end >= $current) {
|
||||
@ -47,7 +68,7 @@ class GoogleChartController extends BaseController
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function accountSankeyInChart(Account $account)
|
||||
public function accountSankeyInChart(Account $account, $view = 'session')
|
||||
{
|
||||
// collect all relevant entries.
|
||||
$set = [];
|
||||
@ -58,13 +79,34 @@ class GoogleChartController extends BaseController
|
||||
$chart->addColumn('To', 'string', 'domain');
|
||||
$chart->addColumn('Weight', 'number');
|
||||
|
||||
switch ($view) {
|
||||
default:
|
||||
case 'session':
|
||||
$start = Session::get('start');
|
||||
$end = Session::get('end');
|
||||
break;
|
||||
case 'all':
|
||||
$first = $account->transactionjournals()->orderBy('date', 'DESC')->first();
|
||||
$last = $account->transactionjournals()->orderBy('date', 'ASC')->first();
|
||||
if (is_null($first)) {
|
||||
$start = Session::get('start');
|
||||
} else {
|
||||
$start = clone $first->date;
|
||||
}
|
||||
if (is_null($last)) {
|
||||
$end = Session::get('end');
|
||||
} else {
|
||||
$end = clone $last->date;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$transactions = $account->transactions()->with(
|
||||
['transactionjournal', 'transactionjournal.transactions' => function ($q) {
|
||||
$q->where('amount', '<', 0);
|
||||
}, 'transactionjournal.budgets', 'transactionjournal.transactiontype', 'transactionjournal.categories']
|
||||
)->before(Session::get('end'))->after(
|
||||
Session::get('start')
|
||||
)->get();
|
||||
)->before($end)->after($start)->get();
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
@ -106,7 +148,7 @@ class GoogleChartController extends BaseController
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function accountSankeyOutChart(Account $account)
|
||||
public function accountSankeyOutChart(Account $account, $view = 'session')
|
||||
{
|
||||
// collect all relevant entries.
|
||||
$set = [];
|
||||
|
@ -141,7 +141,8 @@ Route::group(
|
||||
Route::get('/accounts/create/{what}', ['uses' => 'AccountController@create', 'as' => 'accounts.create'])->where('what', 'revenue|asset|expense');
|
||||
Route::get('/accounts/edit/{account}', ['uses' => 'AccountController@edit', 'as' => 'accounts.edit']);
|
||||
Route::get('/accounts/delete/{account}', ['uses' => 'AccountController@delete', 'as' => 'accounts.delete']);
|
||||
Route::get('/accounts/show/{account}', ['uses' => 'AccountController@show', 'as' => 'accounts.show']);
|
||||
Route::get('/accounts/show/{account}/{view?}', ['uses' => 'AccountController@show', 'as' => 'accounts.show']);
|
||||
|
||||
|
||||
// budget controller:
|
||||
Route::get('/budgets', ['uses' => 'BudgetController@index', 'as' => 'budgets.index']);
|
||||
@ -163,9 +164,9 @@ Route::group(
|
||||
Route::get('/chart/home/budgets', ['uses' => 'GoogleChartController@allBudgetsHomeChart']);
|
||||
Route::get('/chart/home/categories', ['uses' => 'GoogleChartController@allCategoriesHomeChart']);
|
||||
Route::get('/chart/home/recurring', ['uses' => 'GoogleChartController@recurringTransactionsOverview']);
|
||||
Route::get('/chart/account/{account}', ['uses' => 'GoogleChartController@accountBalanceChart']);
|
||||
Route::get('/chart/sankey/{account}/out', ['uses' => 'GoogleChartController@accountSankeyOutChart']);
|
||||
Route::get('/chart/sankey/{account}/in', ['uses' => 'GoogleChartController@accountSankeyInChart']);
|
||||
Route::get('/chart/account/{account}/{view?}', ['uses' => 'GoogleChartController@accountBalanceChart']);
|
||||
Route::get('/chart/sankey/{account}/out/{view?}', ['uses' => 'GoogleChartController@accountSankeyOutChart']);
|
||||
Route::get('/chart/sankey/{account}/in/{view?}', ['uses' => 'GoogleChartController@accountSankeyInChart']);
|
||||
Route::get('/chart/reports/income-expenses/{year}', ['uses' => 'GoogleChartController@yearInExp']);
|
||||
Route::get('/chart/reports/income-expenses-sum/{year}', ['uses' => 'GoogleChartController@yearInExpSum']);
|
||||
Route::get('/chart/recurring/{recurring}', ['uses' => 'GoogleChartController@recurringOverview']);
|
||||
|
@ -21,10 +21,10 @@
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
<!-- TODO clean up these methods and everything associated with them. -->
|
||||
@if(Input::get('showAll') == 'true')
|
||||
<a href="{{route('accounts.show',$account->id)}}" class="btn btn-default">Stick to date-range</a>
|
||||
@if($view == 'all')
|
||||
<a href="{{route('accounts.show',$account->id)}}/session" class="btn btn-default">Stick to date-range</a>
|
||||
@else
|
||||
<a href="{{route('accounts.show',$account->id)}}?showAll=true" class="btn btn-default">Show all transactions</a>
|
||||
<a href="{{route('accounts.show',$account->id)}}/all" class="btn btn-default">Show all transactions</a>
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
@ -74,6 +74,7 @@
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var accountID = {{{$account->id}}};
|
||||
var view = '{{{$view}}}';
|
||||
</script>
|
||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
|
@ -1,12 +1,12 @@
|
||||
$(function () {
|
||||
|
||||
if (typeof(googleLineChart) == "function" && typeof accountID != 'undefined') {
|
||||
googleLineChart('chart/account/' + accountID, 'overview-chart');
|
||||
if (typeof(googleLineChart) == "function" && typeof accountID != 'undefined' && typeof view != 'undefined') {
|
||||
googleLineChart('chart/account/' + accountID + '/' + view, 'overview-chart');
|
||||
}
|
||||
//
|
||||
if (typeof(googleSankeyChart) == 'function' && typeof accountID != 'undefined') {
|
||||
googleSankeyChart('chart/sankey/' + accountID + '/out', 'account-out-sankey');
|
||||
googleSankeyChart('chart/sankey/' + accountID + '/in', 'account-in-sankey');
|
||||
if (typeof(googleSankeyChart) == 'function' && typeof accountID != 'undefined' && typeof view != 'undefined') {
|
||||
googleSankeyChart('chart/sankey/' + accountID + '/out' + '/' + view, 'account-out-sankey');
|
||||
googleSankeyChart('chart/sankey/' + accountID + '/in' + '/' + view, 'account-in-sankey');
|
||||
}
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user