mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 22:58:09 +00:00
First reports.
This commit is contained in:
@@ -336,7 +336,8 @@ class AccountController extends BaseController
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @return $this
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function update(Account $account)
|
||||
{
|
||||
@@ -345,13 +346,16 @@ class AccountController extends BaseController
|
||||
$acct = App::make('FireflyIII\Database\Account');
|
||||
$data = Input::except('_token');
|
||||
|
||||
switch($account->accountType->type) {
|
||||
switch ($account->accountType->type) {
|
||||
default:
|
||||
throw new FireflyException('Cannot handle account type "' . e($account->accountType->type) . '"');
|
||||
break;
|
||||
case 'Default account':
|
||||
$data['what'] = 'asset';
|
||||
break;
|
||||
case 'Beneficiary account':
|
||||
$data['what'] = 'expense';
|
||||
break;
|
||||
}
|
||||
|
||||
switch (Input::get('post_submit_action')) {
|
||||
|
||||
@@ -44,9 +44,9 @@ class GoogleChartController extends BaseController
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
//if ($current > Carbon::now()) {
|
||||
// $row[] = 0;
|
||||
// $row[] = 0;
|
||||
//} else {
|
||||
$row[] = $account->balance($current);
|
||||
$row[] = $account->balance($current);
|
||||
//}
|
||||
|
||||
}
|
||||
@@ -60,6 +60,86 @@ class GoogleChartController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function yearInExp($year)
|
||||
{
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Month', 'date');
|
||||
$chart->addColumn('Income', 'number');
|
||||
$chart->addColumn('Expenses', 'number');
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionJournal $tj */
|
||||
$tj = App::make('FireflyIII\Database\TransactionJournal');
|
||||
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
while ($start < $end) {
|
||||
|
||||
// total income:
|
||||
$income = $tj->getSumOfIncomesByMonth($start);
|
||||
$expense = $tj->getSumOfExpensesByMonth($start);
|
||||
|
||||
$chart->addRow(clone $start, $income, $expense);
|
||||
$start->addMonth();
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
/**
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function yearInExpSum($year)
|
||||
{
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Month', 'string');
|
||||
$chart->addColumn('Income', 'number');
|
||||
$chart->addColumn('Expenses', 'number');
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionJournal $tj */
|
||||
$tj = App::make('FireflyIII\Database\TransactionJournal');
|
||||
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
$income = 0;
|
||||
$expense = 0;
|
||||
while ($start < $end) {
|
||||
|
||||
// total income:
|
||||
$income += $tj->getSumOfIncomesByMonth($start);
|
||||
$expense += $tj->getSumOfExpensesByMonth($start);
|
||||
|
||||
$start->addMonth();
|
||||
}
|
||||
$chart->addRow('Sum', $income, $expense);
|
||||
|
||||
|
||||
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class ReportController
|
||||
@@ -12,7 +13,55 @@ class ReportController extends BaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return View::make('reports.index')->with('title','Reports')->with('mainTitleIcon','fa-line-chart');
|
||||
/** @var \FireflyIII\Database\TransactionJournal $journals */
|
||||
$journals = App::make('FireflyIII\Database\TransactionJournal');
|
||||
$journal = $journals->first();
|
||||
|
||||
$date = $journal->date;
|
||||
$years = [];
|
||||
while ($date <= Carbon::now()) {
|
||||
$years[] = $date->format('Y');
|
||||
$date->addYear();
|
||||
}
|
||||
|
||||
|
||||
return View::make('reports.index', compact('years'))->with('title', 'Reports')->with('mainTitleIcon', 'fa-line-chart');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $year
|
||||
*/
|
||||
public function year($year)
|
||||
{
|
||||
try {
|
||||
$date = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionJournal $tj */
|
||||
$tj = App::make('FireflyIII\Database\TransactionJournal');
|
||||
|
||||
// get some sums going
|
||||
$summary = [];
|
||||
|
||||
|
||||
$end = clone $date;
|
||||
$end->endOfYear();
|
||||
while ($date < $end) {
|
||||
$summary[] = [
|
||||
'month' => $date->format('F'),
|
||||
'income' => $tj->getSumOfIncomesByMonth($date),
|
||||
'expense' => $tj->getSumOfExpensesByMonth($date),
|
||||
];
|
||||
$date->addMonth();
|
||||
}
|
||||
|
||||
|
||||
// draw some charts etc.
|
||||
return View::make('reports.year', compact('summary'))->with('title', 'Reports')->with('mainTitleIcon', 'fa-line-chart')->with('subTitle', $year)->with(
|
||||
'subTitleIcon', 'fa-bar-chart'
|
||||
)->with('year', $year);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user