_journals = $journals; $this->_repository = $repository; /** @var \FireflyIII\Database\Budget\Budget _budgets */ $this->_budgets = App::make('FireflyIII\Database\Budget\Budget'); View::share('title', 'Reports'); View::share('mainTitleIcon', 'fa-line-chart'); } /** * @param string $year * @param string $month * * @return \Illuminate\View\View */ public function budget($year = '2014', $month = '1') { try { new Carbon($year . '-' . $month . '-01'); } catch (Exception $e) { return View::make('error')->with('message', 'Invalid date'); } $date = new Carbon($year . '-' . $month . '-01'); $dayEarly = clone $date; $subTitle = 'Budget report for ' . $date->format('F Y'); $subTitleIcon = 'fa-calendar'; $dayEarly = $dayEarly->subDay(); $accounts = $this->_repository->getAccountListBudgetOverview($date); $budgets = $this->_repository->getBudgetsForMonth($date); return View::make('reports.budget', compact('subTitle', 'subTitleIcon', 'date', 'accounts', 'budgets', 'dayEarly')); } /** * */ public function index() { $start = $this->_journals->firstDate(); $months = $this->_repository->listOfMonths(clone $start); $years = $this->_repository->listOfYears(clone $start); $title = 'Reports'; $mainTitleIcon = 'fa-line-chart'; return View::make('reports.index', compact('years', 'months', 'title', 'mainTitleIcon')); } /** * @param string $year * @param string $month * * @return \Illuminate\View\View */ public function month($year = '2014', $month = '1') { try { new Carbon($year . '-' . $month . '-01'); } catch (Exception $e) { return View::make('error')->with('message', 'Invalid date.'); } $date = new Carbon($year . '-' . $month . '-01'); $subTitle = 'Report for ' . $date->format('F Y'); $subTitleIcon = 'fa-calendar'; $displaySum = true; // to show sums in report. $income = $this->_repository->getIncomeForMonth($date); $expenses = $this->_repository->getExpenseGroupedForMonth($date, 10); $budgets = $this->_repository->getBudgetsForMonth($date); $categories = $this->_repository->getCategoriesForMonth($date, 10); $accounts = $this->_repository->getAccountsForMonth($date); return View::make( 'reports.month', compact('date', 'accounts', 'categories', 'budgets', 'expenses', 'subTitle', 'displaySum', 'subTitleIcon', 'income') ); } /** * @param $year * * @return $this */ public function year($year) { try { new Carbon('01-01-' . $year); } catch (Exception $e) { return View::make('error')->with('message', 'Invalid date.'); } $date = new Carbon('01-01-' . $year); $end = clone $date; $end->endOfYear(); $title = 'Reports'; $subTitle = $year; $subTitleIcon = 'fa-bar-chart'; $mainTitleIcon = 'fa-line-chart'; $balances = $this->_repository->yearBalanceReport($date); $groupedIncomes = $this->_repository->revenueGroupedByAccount($date, $end, 15); $groupedExpenses = $this->_repository->expensesGroupedByAccount($date, $end, 15); return View::make( 'reports.year', compact('date', 'groupedIncomes', 'groupedExpenses', 'year', 'balances', 'title', 'subTitle', 'subTitleIcon', 'mainTitleIcon') ); } }