diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 4bc3698507..36f5470003 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -1,5 +1,6 @@ accountType->type); + $what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type); + $journals = $repository->getJournals($account, $range); + $subTitle = 'Details for ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"'; + + return View::make('accounts.show', compact('account', 'what', 'range', 'subTitleIcon', 'journals', 'subTitle')); + } + /** * @param AccountFormRequest $request * @param AccountRepositoryInterface $repository diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 976a7bf73b..1b89f3d8a9 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -3,6 +3,8 @@ namespace FireflyIII\Repositories\Account; use App; +use Auth; +use Carbon\Carbon; use Config; use FireflyIII\Models\Account; use FireflyIII\Models\AccountMeta; @@ -10,7 +12,10 @@ use FireflyIII\Models\AccountType; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; +use Illuminate\Pagination\LengthAwarePaginator; +use Illuminate\Pagination\Paginator; use Log; +use Session; /** * Class AccountRepository @@ -32,6 +37,43 @@ class AccountRepository implements AccountRepositoryInterface return true; } + /** + * @param Account $account + * @param int $page + * @param string $range + * + * @return mixed + */ + public function getJournals(Account $account, $page, $range = 'session') + { + $offset = $page * 50; + $items = []; + $query = Auth::user() + ->transactionJournals() + //->withRelevantData() + ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') + ->where('transactions.account_id', $account->id) + ->orderBy('date', 'DESC'); + + if ($range == 'session') { + $query->before(Session::get('end', Carbon::now()->startOfMonth())); + $query->after(Session::get('start', Carbon::now()->startOfMonth())); + } + $count = $query->count(); + $set = $query->take(50)->offset($offset)->get(['transaction_journals.*']); + + foreach ($set as $entry) { + $items[] = $entry; + } + + $paginator = new LengthAwarePaginator($items, $count, 50, $page); + return $paginator; + + //return Paginator::make($items, $count, 50); + + + } + /** * @param Account $account * diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php index 6e2e7897db..322a9f39af 100644 --- a/app/Repositories/Account/AccountRepositoryInterface.php +++ b/app/Repositories/Account/AccountRepositoryInterface.php @@ -4,6 +4,7 @@ namespace FireflyIII\Repositories\Account; use FireflyIII\Models\Account; use FireflyIII\Models\TransactionJournal; + /** * Interface AccountRepositoryInterface * @@ -11,13 +12,6 @@ use FireflyIII\Models\TransactionJournal; */ interface AccountRepositoryInterface { - /** - * @param array $data - * - * @return Account - */ - public function store(array $data); - /** * @param Account $account * @@ -27,11 +21,12 @@ interface AccountRepositoryInterface /** * @param Account $account - * @param array $data + * @param int $page + * @param string $range * - * @return Account + * @return mixed */ - public function update(Account $account, array $data); + public function getJournals(Account $account, $page, $range = 'session'); /** * @param Account $account @@ -40,5 +35,18 @@ interface AccountRepositoryInterface */ public function openingBalanceTransaction(Account $account); + /** + * @param array $data + * + * @return Account + */ + public function store(array $data); + /** + * @param Account $account + * @param array $data + * + * @return Account + */ + public function update(Account $account, array $data); } \ No newline at end of file diff --git a/public/js/accounts.js b/public/js/accounts.js new file mode 100644 index 0000000000..d0830eecef --- /dev/null +++ b/public/js/accounts.js @@ -0,0 +1,7 @@ +$(function () { + + if (typeof(googleLineChart) === "function" && typeof accountID !== 'undefined' && typeof view !== 'undefined') { + googleLineChart('chart/account/' + accountID + '/' + view, 'overview-chart'); + } + +}); \ No newline at end of file diff --git a/resources/views/accounts/show.blade.php b/resources/views/accounts/show.blade.php new file mode 100644 index 0000000000..0ace1f4916 --- /dev/null +++ b/resources/views/accounts/show.blade.php @@ -0,0 +1,77 @@ +@extends('layouts.default') +@section('content') +{{-- Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) --}} +
+
+
+
+ {{{$account->name}}} + + + +
+
+ + +
+
+
+
+
+
+
+
+
+ + @include('partials.date_nav') +
+
+ View options for {{{$account->name}}} +
+
+

+ @if($range == 'all') + Stick to date-range + @else + Show all transactions + @endif +

+
+
+
+
+ + +
+
+
+
+ Transactions +
+
+ @include('list.journals-full') +
+
+
+ + + +@stop +@section('scripts') + + + + + + +@stop diff --git a/resources/views/list/journals-full.blade.php b/resources/views/list/journals-full.blade.php new file mode 100644 index 0000000000..4979b6a428 --- /dev/null +++ b/resources/views/list/journals-full.blade.php @@ -0,0 +1,120 @@ +@if(is_object($journals) && method_exists($journals, 'links')) +{{$journals->links()}} +@endif + + + + + + + + + @if(!isset($hideBudget) || (isset($hideBudget) && $hideBudget=== false)) + + @endif + @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false)) + + @endif + @if(!isset($hideBill) || (isset($hideBill) && $hideBill=== false)) + + @endif + + @foreach($journals as $journal) + @if(!isset($journal->transactions[1]) || !isset($journal->transactions[0])) + + + + + + + @else + + + + + + + + + @if(!isset($hideBudget) || (isset($hideBudget) && $hideBudget=== false)) + + @endif + @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false)) + + @endif + @if(!isset($hideBill) || (isset($hideBill) && $hideBill=== false)) + + @endif + + + + @endif + + @endforeach +
 DescriptionAmountDateFromTo
+
+ +
+
 {{{$journal->description}}}Invalid journal: Found {{$journal->transactions()->count()}} transaction(s)
+
+ + +
+
+ @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') + {{Amount::formatTransaction($journal->transactions[1],false)}} + @endif + @if($journal->transactiontype->type == 'Deposit') + {{Amount::formatTransaction($journal->transactions[1],false)}} + @endif + @if($journal->transactiontype->type == 'Transfer') + {{Amount::formatTransaction($journal->transactions[1],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->bill) + {{{$journal->bill->name}}} + @endif +
+ +@if(is_object($journals) && method_exists($journals, 'links')) +{{$journals->links()}} +@endif