mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix chart for account/all overview.
This commit is contained in:
parent
6075d75ee2
commit
4a99399952
@ -22,6 +22,7 @@ use FireflyIII\Http\Requests\AccountFormRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
@ -240,7 +241,7 @@ class AccountController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function showAll(Account $account)
|
||||
public function showAll(AccountRepositoryInterface $repository, Account $account)
|
||||
{
|
||||
$subTitle = sprintf('%s (%s)', $account->name, strtolower(trans('firefly.everything')));
|
||||
$page = intval(Input::get('page')) === 0 ? 1 : intval(Input::get('page'));
|
||||
@ -252,7 +253,11 @@ class AccountController extends Controller
|
||||
$journals = $collector->getPaginatedJournals();
|
||||
$journals->setPath('accounts/show/' . $account->id . '/all');
|
||||
|
||||
return view('accounts.show_with_date', compact('category', 'date', 'account', 'journals', 'subTitle', 'carbon'));
|
||||
// get oldest and newest journal for account:
|
||||
$start = $repository->oldestJournalDate($account);
|
||||
$end = $repository->newestJournalDate($account);
|
||||
|
||||
return view('accounts.show_with_date', compact('account', 'journals', 'subTitle', 'start', 'end'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -260,6 +260,29 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date of the very last transaction in this account.
|
||||
*
|
||||
* @param Account $account
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function newestJournalDate(Account $account): Carbon
|
||||
{
|
||||
$last = new Carbon;
|
||||
$date = $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->first(['transaction_journals.date']);
|
||||
if (!is_null($date)) {
|
||||
$last = new Carbon($date->date);
|
||||
}
|
||||
|
||||
return $last;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date of the very first transaction in this account.
|
||||
*
|
||||
@ -270,14 +293,12 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
public function oldestJournalDate(Account $account): Carbon
|
||||
{
|
||||
$first = new Carbon;
|
||||
|
||||
/** @var Transaction $first */
|
||||
$date = $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->orderBy('transaction_journals.date', 'ASC')
|
||||
->orderBy('transaction_journals.order', 'DESC')
|
||||
->orderBy('transaction_journals.id', 'ASC')
|
||||
->first(['transaction_journals.date']);
|
||||
$date = $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->orderBy('transaction_journals.date', 'ASC')
|
||||
->orderBy('transaction_journals.order', 'DESC')
|
||||
->orderBy('transaction_journals.id', 'ASC')
|
||||
->first(['transaction_journals.date']);
|
||||
if (!is_null($date)) {
|
||||
$first = new Carbon($date->date);
|
||||
}
|
||||
@ -602,5 +623,4 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -96,6 +96,15 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function getActiveAccountsByType(array $types): Collection;
|
||||
|
||||
/**
|
||||
* Returns the date of the very last transaction in this account.
|
||||
*
|
||||
* @param Account $account
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function newestJournalDate(Account $account): Carbon;
|
||||
|
||||
/**
|
||||
* Returns the date of the very first transaction in this account.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user