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) --}} +
+ @if($range == 'all') + Stick to date-range + @else + Show all transactions + @endif +
++ | Description | +Amount | +Date | +From | +To | + @if(!isset($hideBudget) || (isset($hideBudget) && $hideBudget=== false)) ++ @endif + @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false)) + | + @endif + @if(!isset($hideBill) || (isset($hideBill) && $hideBill=== false)) + | + @endif + | |
---|---|---|---|---|---|---|---|---|---|
+ + | ++ | {{{$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 + | + @if(!isset($hideBudget) || (isset($hideBudget) && $hideBudget=== false)) ++ budgets[0]) ? $journal->budgets[0] : null; ?> + @if($budget) + {{{$budget->name}}} + @endif + | + @endif + @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false)) ++ categories[0]) ? $journal->categories[0] : null; ?> + @if($category) + {{{$category->name}}} + @endif + | + @endif + @if(!isset($hideBill) || (isset($hideBill) && $hideBill=== false)) ++ @if($journal->bill) + {{{$journal->bill->name}}} + @endif + | + @endif + + +