mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-21 19:47:48 +00:00
New chart for budget-overview.
This commit is contained in:
@@ -200,6 +200,47 @@ class GoogleChartController extends BaseController
|
|||||||
return Response::json($chart->getData());
|
return Response::json($chart->getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function budgetsAndSpending(Budget $budget, $year) {
|
||||||
|
try {
|
||||||
|
$start = new Carbon('01-01-' . $year);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
App::abort(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var \FireflyIII\Database\Budget $bdt */
|
||||||
|
$bdt = App::make('FireflyIII\Database\Budget');
|
||||||
|
|
||||||
|
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||||
|
$chart = App::make('gchart');
|
||||||
|
$chart->addColumn('Month', 'date');
|
||||||
|
$chart->addColumn('Budgeted', 'number');
|
||||||
|
$chart->addColumn('Spent', 'number');
|
||||||
|
|
||||||
|
$end = clone $start;
|
||||||
|
$end->endOfYear();
|
||||||
|
while($start <= $end) {
|
||||||
|
|
||||||
|
$spent = $bdt->spentInMonth($budget, $start);
|
||||||
|
$repetition = $bdt->repetitionOnStartingOnDate($budget, $start);
|
||||||
|
if($repetition) {
|
||||||
|
$budgeted = floatval($repetition->amount);
|
||||||
|
} else {
|
||||||
|
$budgeted = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$chart->addRow(clone $start, $budgeted, $spent);
|
||||||
|
|
||||||
|
$start->addMonth();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$chart->generate();
|
||||||
|
return Response::json($chart->getData());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
|
@@ -169,6 +169,7 @@ Route::group(
|
|||||||
Route::get('/chart/reports/income-expenses/{year}', ['uses' => 'GoogleChartController@yearInExp']);
|
Route::get('/chart/reports/income-expenses/{year}', ['uses' => 'GoogleChartController@yearInExp']);
|
||||||
Route::get('/chart/reports/income-expenses-sum/{year}', ['uses' => 'GoogleChartController@yearInExpSum']);
|
Route::get('/chart/reports/income-expenses-sum/{year}', ['uses' => 'GoogleChartController@yearInExpSum']);
|
||||||
Route::get('/chart/reports/budgets/{year}', ['uses' => 'GoogleChartController@budgetsReportChart']);
|
Route::get('/chart/reports/budgets/{year}', ['uses' => 'GoogleChartController@budgetsReportChart']);
|
||||||
|
Route::get('/chart/budgets/{budget}/spending/{year}', ['uses' => 'GoogleChartController@budgetsAndSpending']);
|
||||||
|
|
||||||
// google table controller
|
// google table controller
|
||||||
Route::get('/table/account/{account}/transactions', ['uses' => 'GoogleTableController@transactionsByAccount']);
|
Route::get('/table/account/{account}/transactions', ['uses' => 'GoogleTableController@transactionsByAccount']);
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
Some stuff?
|
Some stuff?
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
Some stuff?
|
<div id="budgetOverview"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -76,7 +76,11 @@
|
|||||||
var budgetID = {{$budget->id}};
|
var budgetID = {{$budget->id}};
|
||||||
@if(!is_null($repetition))
|
@if(!is_null($repetition))
|
||||||
var repetitionID = {{$repetition->id}};
|
var repetitionID = {{$repetition->id}};
|
||||||
|
var year = {{$repetition->startdate->format('Y')}};
|
||||||
|
@else
|
||||||
|
var year = {{Session::get('start')->format('Y')}};
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||||
|
@@ -10,6 +10,8 @@ $(function () {
|
|||||||
if (typeof(googleTable) == 'function') {
|
if (typeof(googleTable) == 'function') {
|
||||||
if (typeof budgetID != 'undefined' && typeof repetitionID == 'undefined') {
|
if (typeof budgetID != 'undefined' && typeof repetitionID == 'undefined') {
|
||||||
googleTable('table/budget/' + budgetID + '/0/transactions', 'transactions');
|
googleTable('table/budget/' + budgetID + '/0/transactions', 'transactions');
|
||||||
|
googleColumnChart('chart/budgets/'+budgetID+'/spending/2014','budgetOverview');
|
||||||
|
|
||||||
} else if (typeof budgetID != 'undefined' && typeof repetitionID != 'undefined') {
|
} else if (typeof budgetID != 'undefined' && typeof repetitionID != 'undefined') {
|
||||||
googleTable('table/budget/' + budgetID + '/' + repetitionID + '/transactions', 'transactions');
|
googleTable('table/budget/' + budgetID + '/' + repetitionID + '/transactions', 'transactions');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user