diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 8544c5fc99..8efebdd130 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -220,11 +220,17 @@ class AccountController extends BaseController break; } + // get a paginated view of all transactions for this account: + /** @var \FireflyIII\Database\Account $acct */ + $acct = App::make('FireflyIII\Database\Account'); + + $journals = $acct->getTransactionJournals($account, 50); + //$data = $this->_accounts->show($account, 40); - return View::make('accounts.show')->with('account', $account)->with( + return View::make('accounts.show',compact('account','subTitleIcon','journals'))->with('account', $account)->with( 'subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"' - )->with(compact('subTitleIcon')); + ); } /** diff --git a/app/lib/FireflyIII/Database/Account.php b/app/lib/FireflyIII/Database/Account.php index 74287f07c0..9c5c7cd894 100644 --- a/app/lib/FireflyIII/Database/Account.php +++ b/app/lib/FireflyIII/Database/Account.php @@ -483,5 +483,25 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface } + public function getTransactionJournals(\Account $account, $limit = 50) + { + $start = \Session::get('start'); + $end = \Session::get('end'); + $offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0; + $set = $this->getUser()->transactionJournals()->withRelevantData()->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') + ->where('transactions.account_id', $account->id)->take($limit)->offset($offset)->before($end)->after($start)->orderBy('date', 'DESC') + ->get(['transaction_journals.*']); + $count = $this->getUser()->transactionJournals()->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') + ->before($end)->after($start)->orderBy('date', 'DESC')->where('transactions.account_id', $account->id)->count(); + $items = []; + foreach ($set as $entry) { + $items[] = $entry; + } + + return \Paginator::make($items, $count, $limit); + + + } + } \ No newline at end of file diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php index fdc0ae6dab..94eb8318e6 100644 --- a/app/models/TransactionJournal.php +++ b/app/models/TransactionJournal.php @@ -213,7 +213,7 @@ class TransactionJournal extends Ardent $q->orderBy('amount', 'ASC'); }, 'transactiontype', 'components' => function ($q) { $q->orderBy('class'); - }, 'transactions.account.accounttype', 'recurringTransaction'] + }, 'transactions.account.accounttype', 'recurringTransaction','budgets','categories'] ); } diff --git a/app/views/accounts/show.blade.php b/app/views/accounts/show.blade.php index 8d5842fd67..e96f37cd3b 100644 --- a/app/views/accounts/show.blade.php +++ b/app/views/accounts/show.blade.php @@ -48,7 +48,7 @@ Transactions
+ | + | Description | +Amount | +Date | +From | +To | ++ | + | + |
---|---|---|---|---|---|---|---|---|---|
+ + | ++ @if($journal->transactiontype->type == 'Withdrawal') + + @endif + @if($journal->transactiontype->type == 'Deposit') + + @endif + @if($journal->transactiontype->type == 'Transfer') + + @endif + @if($journal->transactiontype->type == 'Opening balance') + + @endif + | ++ {{{$journal->description}}} + | ++ @if($journal->transactiontype->type == 'Withdrawal') + {{mf($journal->transactions[1]->amount,false)}} + @endif + @if($journal->transactiontype->type == 'Deposit') + {{mf($journal->transactions[1]->amount,false)}} + @endif + @if($journal->transactiontype->type == 'Transfer') + {{mf($journal->transactions[1]->amount,false)}} + @endif + | ++ {{$journal->date->format('j F Y')}} + | ++ @if($journal->transactions[0]->account->accounttype->description == 'Cash account') + (cash) + @else + {{{$journal->transactions[0]->account->name}}} + @endif + | ++ @if($journal->transactions[1]->account->accounttype->description == 'Cash account') + (cash) + @else + {{{$journal->transactions[1]->account->name}}} + @endif + | ++ budgets[0]) ? $journal->budgets[0] : null; ?> + @if($budget) + {{{$budget->name}}} + @endif + | ++ categories[0]) ? $journal->categories[0] : null; ?> + @if($category) + {{{$category->name}}} + @endif + | ++ @if($journal->recurringTransaction) + {{{$journal->recurringTransaction->name}}} + @endif + | + + +