mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix charts for #595, account overview.
This commit is contained in:
parent
de9ef20014
commit
2e637031ac
@ -295,103 +295,6 @@ class AccountController extends Controller
|
|||||||
return view('accounts.show', compact('account', 'accountType', 'periods', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri'));
|
return view('accounts.show', compact('account', 'accountType', 'periods', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @param Request $request
|
|
||||||
// * @param JournalCollectorInterface $collector
|
|
||||||
// * @param Account $account
|
|
||||||
// *
|
|
||||||
// * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
|
|
||||||
// */
|
|
||||||
// public function show(Request $request, JournalCollectorInterface $collector, Account $account)
|
|
||||||
// {
|
|
||||||
// if ($account->accountType->type === AccountType::INITIAL_BALANCE) {
|
|
||||||
// return $this->redirectToOriginalAccount($account);
|
|
||||||
// }
|
|
||||||
// // show journals from current period only:
|
|
||||||
// $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
|
||||||
// $subTitle = $account->name;
|
|
||||||
// $range = Preferences::get('viewRange', '1M')->data;
|
|
||||||
// $start = session('start', Navigation::startOfPeriod(new Carbon, $range));
|
|
||||||
// $end = session('end', Navigation::endOfPeriod(new Carbon, $range));
|
|
||||||
// $page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
|
||||||
// $pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
|
||||||
// $chartUri = route('chart.account.single', [$account->id]);
|
|
||||||
// $accountType = $account->accountType->type;
|
|
||||||
//
|
|
||||||
// // grab those journals:
|
|
||||||
// $collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit($pageSize)->setPage($page);
|
|
||||||
// $journals = $collector->getPaginatedJournals();
|
|
||||||
// $journals->setPath('accounts/show/' . $account->id);
|
|
||||||
//
|
|
||||||
// // generate entries for each period (and cache those)
|
|
||||||
// $entries = $this->periodEntries($account);
|
|
||||||
//
|
|
||||||
// return view('accounts.show', compact('account', 'accountType', 'entries', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri'));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * @param Request $request
|
|
||||||
// * @param AccountRepositoryInterface $repository
|
|
||||||
// * @param Account $account
|
|
||||||
// *
|
|
||||||
// * @return View
|
|
||||||
// */
|
|
||||||
// public function showAll(Request $request, AccountRepositoryInterface $repository, Account $account)
|
|
||||||
// {
|
|
||||||
// $subTitle = sprintf('%s (%s)', $account->name, strtolower(trans('firefly.everything')));
|
|
||||||
// $page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
|
||||||
// $pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
|
||||||
// $chartUri = route('chart.account.all', [$account->id]);
|
|
||||||
//
|
|
||||||
// // replace with journal collector:
|
|
||||||
// /** @var JournalCollectorInterface $collector */
|
|
||||||
// $collector = app(JournalCollectorInterface::class);
|
|
||||||
// $collector->setUser(auth()->user());
|
|
||||||
// $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
|
|
||||||
// $journals = $collector->getPaginatedJournals();
|
|
||||||
// $journals->setPath('accounts/show/' . $account->id . '/all');
|
|
||||||
//
|
|
||||||
// // get oldest and newest journal for account:
|
|
||||||
// $start = $repository->oldestJournalDate($account);
|
|
||||||
// $end = $repository->newestJournalDate($account);
|
|
||||||
//
|
|
||||||
// // same call, except "entries".
|
|
||||||
// return view('accounts.show', compact('account', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri'));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * @param Request $request
|
|
||||||
// * @param Account $account
|
|
||||||
// * @param string $date
|
|
||||||
// *
|
|
||||||
// * @return View
|
|
||||||
// */
|
|
||||||
// public function showByDate(Request $request, Account $account, string $date)
|
|
||||||
// {
|
|
||||||
// $carbon = new Carbon($date);
|
|
||||||
// $range = Preferences::get('viewRange', '1M')->data;
|
|
||||||
// $start = Navigation::startOfPeriod($carbon, $range);
|
|
||||||
// $end = Navigation::endOfPeriod($carbon, $range);
|
|
||||||
// $subTitle = $account->name . ' (' . Navigation::periodShow($start, $range) . ')';
|
|
||||||
// $page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
|
||||||
// $pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
|
||||||
// $chartUri = route('chart.account.period', [$account->id, $carbon->format('Y-m-d')]);
|
|
||||||
// $accountType = $account->accountType->type;
|
|
||||||
//
|
|
||||||
// // replace with journal collector:
|
|
||||||
// /** @var JournalCollectorInterface $collector */
|
|
||||||
// $collector = app(JournalCollectorInterface::class);
|
|
||||||
// $collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit($pageSize)->setPage($page);
|
|
||||||
// $journals = $collector->getPaginatedJournals();
|
|
||||||
// $journals->setPath('accounts/show/' . $account->id . '/' . $date);
|
|
||||||
//
|
|
||||||
// // generate entries for each period (and cache those)
|
|
||||||
// $entries = $this->periodEntries($account);
|
|
||||||
//
|
|
||||||
// // same call, except "entries".
|
|
||||||
// return view('accounts.show', compact('account', 'accountType', 'entries', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri'));
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountFormRequest $request
|
* @param AccountFormRequest $request
|
||||||
* @param AccountRepositoryInterface $repository
|
* @param AccountRepositoryInterface $repository
|
||||||
|
@ -139,14 +139,13 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param JournalCollectorInterface $collector
|
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function expenseBudget(JournalCollectorInterface $collector, Account $account, Carbon $start, Carbon $end)
|
public function expenseBudget(Account $account, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
@ -156,10 +155,8 @@ class AccountController extends Controller
|
|||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return Response::json($cache->get());
|
return Response::json($cache->get());
|
||||||
}
|
}
|
||||||
$collector->setAccounts(new Collection([$account]))
|
$collector = app(JournalCollectorInterface::class);
|
||||||
->setRange($start, $end)
|
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withBudgetInformation()->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
->withBudgetInformation()
|
|
||||||
->setTypes([TransactionType::WITHDRAWAL]);
|
|
||||||
$transactions = $collector->getJournals();
|
$transactions = $collector->getJournals();
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
$result = [];
|
$result = [];
|
||||||
@ -185,14 +182,27 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param JournalCollectorInterface $collector
|
* @param AccountRepositoryInterface $repository
|
||||||
|
* @param Account $account
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function expenseBudgetAll(AccountRepositoryInterface $repository, Account $account)
|
||||||
|
{
|
||||||
|
$start = $repository->oldestJournalDate($account);
|
||||||
|
$end = Carbon::now();
|
||||||
|
|
||||||
|
return $this->expenseBudget($account, $start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function expenseCategory(JournalCollectorInterface $collector, Account $account, Carbon $start, Carbon $end)
|
public function expenseCategory(Account $account, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
@ -203,6 +213,7 @@ class AccountController extends Controller
|
|||||||
return Response::json($cache->get());
|
return Response::json($cache->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::WITHDRAWAL]);
|
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
$transactions = $collector->getJournals();
|
$transactions = $collector->getJournals();
|
||||||
$result = [];
|
$result = [];
|
||||||
@ -228,6 +239,20 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AccountRepositoryInterface $repository
|
||||||
|
* @param Account $account
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function expenseCategoryAll(AccountRepositoryInterface $repository, Account $account)
|
||||||
|
{
|
||||||
|
$start = $repository->oldestJournalDate($account);
|
||||||
|
$end = Carbon::now();
|
||||||
|
|
||||||
|
return $this->expenseCategory($account, $start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the balances for all the user's frontpage accounts.
|
* Shows the balances for all the user's frontpage accounts.
|
||||||
*
|
*
|
||||||
@ -254,14 +279,13 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param JournalCollectorInterface $collector
|
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function incomeCategory(JournalCollectorInterface $collector, Account $account, Carbon $start, Carbon $end)
|
public function incomeCategory(Account $account, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
@ -273,6 +297,7 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// grab all journals:
|
// grab all journals:
|
||||||
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::DEPOSIT]);
|
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::DEPOSIT]);
|
||||||
$transactions = $collector->getJournals();
|
$transactions = $collector->getJournals();
|
||||||
$result = [];
|
$result = [];
|
||||||
@ -297,6 +322,20 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AccountRepositoryInterface $repository
|
||||||
|
* @param Account $account
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function incomeCategoryAll(AccountRepositoryInterface $repository, Account $account)
|
||||||
|
{
|
||||||
|
$start = $repository->oldestJournalDate($account);
|
||||||
|
$end = Carbon::now();
|
||||||
|
|
||||||
|
return $this->incomeCategory($account, $start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
* @param string $date
|
* @param string $date
|
||||||
|
@ -221,11 +221,13 @@ Route::group(
|
|||||||
Route::get('single/{account}', ['uses' => 'AccountController@single', 'as' => 'single']);
|
Route::get('single/{account}', ['uses' => 'AccountController@single', 'as' => 'single']);
|
||||||
Route::get('period/{account}/{date}', ['uses' => 'AccountController@period', 'as' => 'period']);
|
Route::get('period/{account}/{date}', ['uses' => 'AccountController@period', 'as' => 'period']);
|
||||||
|
|
||||||
|
Route::get('income-category/{account}/all/all', ['uses' => 'AccountController@incomeCategoryAll', 'as' => 'income-category-all']);
|
||||||
|
Route::get('expense-category/{account}/all/all', ['uses' => 'AccountController@expenseCategoryAll', 'as' => 'expense-category-all']);
|
||||||
|
Route::get('expense-budget/{account}/all/all', ['uses' => 'AccountController@expenseBudgetAll', 'as' => 'expense-budget-all']);
|
||||||
|
|
||||||
Route::get('income-category/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@incomeCategory', 'as' => 'income-category']);
|
Route::get('income-category/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@incomeCategory', 'as' => 'income-category']);
|
||||||
Route::get('expense-category/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@expenseCategory', 'as' => 'expense-category']);
|
Route::get('expense-category/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@expenseCategory', 'as' => 'expense-category']);
|
||||||
Route::get('expense-budget/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@expenseBudget', 'as' => 'expense-budget']);
|
Route::get('expense-budget/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@expenseBudget', 'as' => 'expense-budget']);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user