More extensions and views. First home view is semi-complete, time to write some tests again.

This commit is contained in:
James Cole
2014-07-06 21:07:52 +02:00
parent 4192f2bc8f
commit 2f5afc80a3
14 changed files with 206 additions and 51 deletions

View File

@@ -5,28 +5,31 @@ use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
class AccountController extends \BaseController
{
public function __construct(ARI $accounts) {
public function __construct(ARI $accounts)
{
$this->accounts = $accounts;
View::share('menu', 'accounts');
}
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$all = $this->accounts->get();
$list = [
'personal' => [],
'personal' => [],
'beneficiaries' => [],
'initial' => [],
'cash' => []
'initial' => [],
'cash' => []
];
foreach($all as $account) {
switch($account->accounttype->description) {
foreach ($all as $account) {
// @codeCoverageIgnoreStart
switch ($account->accounttype->description) {
case 'Default account':
$list['personal'][] = $account;
break;
@@ -41,10 +44,11 @@ class AccountController extends \BaseController
break;
}
// @codeCoverageIgnoreEnd
}
return View::make('accounts.index')->with('accounts',$list);
}
return View::make('accounts.index')->with('accounts', $list);
}
//
//
/**
@@ -73,16 +77,17 @@ class AccountController extends \BaseController
// }
//
//
/**
* Display the specified resource.
*
* @param Account $account
* @return Response
*/
public function show(Account $account)
{
/**
* Display the specified resource.
*
* @param int $id
*
* @return Response
*/
public function show($id)
{
}
}
//
//
// /**

View File

@@ -6,6 +6,8 @@ use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
class ChartController extends BaseController
{
protected $accounts;
public function __construct(ARI $accounts)
{
$this->accounts = $accounts;
@@ -14,7 +16,7 @@ class ChartController extends BaseController
/**
* Show home charts.
*/
public function home(Account $account = null)
public function home($account = null)
{
// chart
$chart = App::make('gchart');
@@ -45,9 +47,13 @@ class ChartController extends BaseController
$chart->addRowArray($row);
}
} else {
$account = $this->accounts->find($account);
if (is_null($account)) {
return View::make('error')->with('message', 'No account found.');
}
$chart->addColumn($account->name, 'number');
while ($current <= $today) {
$row = [clone $current,$account->balance(clone $current)];
$row = [clone $current, $account->balance(clone $current)];
$current->addDay();
$chart->addRowArray($row);
}

View File

@@ -1,17 +1,20 @@
<?php
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;
class HomeController extends BaseController
{
protected $accounts;
protected $preferences;
protected $tj;
public function __construct(ARI $accounts, PHI $preferences)
public function __construct(ARI $accounts, PHI $preferences, TJRI $tj)
{
$this->accounts = $accounts;
$this->preferences = $preferences;
$this->tj = $tj;
View::share('menu', 'home');
}
@@ -28,6 +31,11 @@ class HomeController extends BaseController
$list = $this->accounts->getByIds($pref->data);
}
// get transactions for each account:
foreach ($list as $account) {
$account->transactionList = $this->tj->getByAccount($account,10);
}
// build the home screen:
return View::make('index')->with('count', $count)->with('accounts', $list);