Fix the view for accounts.

This commit is contained in:
James Cole
2014-11-28 07:40:04 +01:00
parent 935276af88
commit 5a920d5efd
5 changed files with 75 additions and 27 deletions

View File

@@ -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 . '"'
);
}

View File

@@ -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 = [];