mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
New chart for budgets.
This commit is contained in:
parent
4bd38f97a2
commit
9adbbd872c
@ -445,6 +445,32 @@ class GoogleChartController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function budgetLimitSpending(\Budget $budget, \LimitRepetition $repetition) {
|
||||
$start = clone $repetition->startdate;
|
||||
$end = $repetition->enddate;
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Day', 'date');
|
||||
$chart->addColumn('Left', 'number');
|
||||
|
||||
|
||||
$amount = $repetition->amount;
|
||||
|
||||
while($start <= $end) {
|
||||
/*
|
||||
* Sum of expenses on this day:
|
||||
*/
|
||||
$sum = floatval($budget->transactionjournals()->lessThan(0)->transactionTypes(['Withdrawal'])->onDate($start)->sum('amount'));
|
||||
$amount += $sum;
|
||||
$chart->addRow(clone $start, $amount);
|
||||
$start->addDay();
|
||||
}
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \FireflyIII\Exception\FireflyException
|
||||
@ -525,7 +551,6 @@ class GoogleChartController extends BaseController
|
||||
$chart->addRow('Paid: ' . join(', ', $paid['items']), $paid['amount']);
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
@ -155,21 +155,11 @@ Route::group(
|
||||
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/budgets/{year}', ['uses' => 'GoogleChartController@budgetsReportChart']);
|
||||
Route::get('/chart/budget/{budget}/{limitrepetition}', ['uses' => 'GoogleChartController@budgetLimitSpending']);
|
||||
|
||||
// google chart for components (categories + budgets combined)
|
||||
Route::get('/chart/component/{component}/spending/{year}', ['uses' => 'GoogleChartController@componentsAndSpending']);
|
||||
|
||||
// google table controller
|
||||
#Route::get('/table/account/{account}/transactions', ['uses' => 'GoogleTableController@transactionsByAccount']);
|
||||
#Route::get('/table/accounts/{what}', ['uses' => 'GoogleTableController@accountList']);
|
||||
#Route::get('/table/categories', ['uses' => 'GoogleTableController@categoryList']);
|
||||
#Route::get('/table/recurring', ['uses' => 'GoogleTableController@recurringList']);
|
||||
#Route::get('/table/recurring/{recurring}/transactions', ['uses' => 'GoogleTableController@transactionsByRecurring']);
|
||||
#Route::get('/table/transactions/{what}', ['uses' => 'GoogleTableController@transactionsList'])->where(['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']);
|
||||
// google table for components (categories + budgets)
|
||||
#Route::get('/table/component/{component}/{limitrepetition}/transactions', ['uses' => 'GoogleTableController@transactionsByComponent']);
|
||||
|
||||
|
||||
// home controller
|
||||
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
|
||||
Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']); # even though nothing is cached.
|
||||
|
@ -10,6 +10,9 @@ $(function () {
|
||||
if (typeof componentID != 'undefined' && typeof repetitionID == 'undefined') {
|
||||
googleColumnChart('chart/component/' + componentID + '/spending/' + year, 'componentOverview');
|
||||
}
|
||||
if (typeof componentID != 'undefined' && typeof repetitionID != 'undefined') {
|
||||
googleLineChart('chart/budget/' + componentID + '/' + repetitionID, 'componentOverview');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user