Fixed some basic tests.

This commit is contained in:
James Cole
2015-03-13 08:44:07 +01:00
parent 3f89057528
commit 3b11bd0593
7 changed files with 154 additions and 27 deletions

View File

@@ -3,6 +3,7 @@
use Auth;
use Cache;
use Carbon\Carbon;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Input;
use Preferences;
use Redirect;
@@ -51,9 +52,10 @@ class HomeController extends Controller
/**
* @return \Illuminate\View\View
*/
public function index()
public function index(AccountRepositoryInterface $repository)
{
$count = Auth::user()->accounts()->accountTypeIn(['Asset account', 'Default account'])->count();
$count = $repository->countAssetAccounts();
$title = 'Firefly';
$subTitle = 'What\'s playing?';
$mainTitleIcon = 'fa-fire';
@@ -61,26 +63,10 @@ class HomeController extends Controller
$frontPage = Preferences::get('frontPageAccounts', []);
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
if ($frontPage->data == []) {
$accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
} else {
$accounts = Auth::user()->accounts()->whereIn('id', $frontPage->data)->get(['accounts.*']);
}
$accounts = $repository->getFrontpageAccounts($frontPage);
foreach ($accounts as $account) {
$set = Auth::user()
->transactionjournals()
->with(['transactions', 'transactioncurrency', 'transactiontype'])
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')->where('accounts.id', $account->id)
->before($end)
->after($start)
->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.id', 'DESC')
->take(10)
->get(['transaction_journals.*']);
$set = $repository->getFrontpageTransactions($account, $start, $end);
if (count($set) > 0) {
$transactions[] = [$set, $account];
}