mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Clean up some report code.
Signed-off-by: James Cole <thegrumpydictator@gmail.com>
This commit is contained in:
@@ -19,7 +19,6 @@ use FireflyIII\Helpers\Report\ReportHelperInterface;
|
|||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Response;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class InOutController
|
* Class InOutController
|
||||||
@@ -37,29 +36,83 @@ class InOutController extends Controller
|
|||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function inOutReport(ReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
|
public function expenseReport(ReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
|
||||||
{
|
{
|
||||||
// chart properties for cache:
|
// chart properties for cache:
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty('in-out-report');
|
$cache->addProperty('expense-report');
|
||||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return Response::json($cache->get());
|
return $cache->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$expenses = $helper->getExpenseReport($start, $end, $accounts);
|
||||||
|
|
||||||
|
$result = view('reports.partials.expenses', compact('expenses'))->render();
|
||||||
|
$cache->store($result);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ReportHelperInterface $helper
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function incExpReport(ReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
|
||||||
|
{
|
||||||
|
// chart properties for cache:
|
||||||
|
$cache = new CacheProperties;
|
||||||
|
$cache->addProperty($start);
|
||||||
|
$cache->addProperty($end);
|
||||||
|
$cache->addProperty('inc-exp-report');
|
||||||
|
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||||
|
if ($cache->has()) {
|
||||||
|
return $cache->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
$incomes = $helper->getIncomeReport($start, $end, $accounts);
|
$incomes = $helper->getIncomeReport($start, $end, $accounts);
|
||||||
$expenses = $helper->getExpenseReport($start, $end, $accounts);
|
$expenses = $helper->getExpenseReport($start, $end, $accounts);
|
||||||
|
|
||||||
$result = [
|
$result = view('reports.partials.income-vs-expenses', compact('expenses', 'incomes'))->render();
|
||||||
'income' => view('reports.partials.income', compact('incomes'))->render(),
|
|
||||||
'expenses' => view('reports.partials.expenses', compact('expenses'))->render(),
|
|
||||||
'incomes_expenses' => view('reports.partials.income-vs-expenses', compact('expenses', 'incomes'))->render(),
|
|
||||||
];
|
|
||||||
$cache->store($result);
|
$cache->store($result);
|
||||||
|
|
||||||
return Response::json($result);
|
return $result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ReportHelperInterface $helper
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function incomeReport(ReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
|
||||||
|
{
|
||||||
|
// chart properties for cache:
|
||||||
|
$cache = new CacheProperties;
|
||||||
|
$cache->addProperty($start);
|
||||||
|
$cache->addProperty($end);
|
||||||
|
$cache->addProperty('income-report');
|
||||||
|
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||||
|
if ($cache->has()) {
|
||||||
|
return $cache->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$incomes = $helper->getIncomeReport($start, $end, $accounts);
|
||||||
|
|
||||||
|
$result = view('reports.partials.income', compact('incomes'))->render();
|
||||||
|
$cache->store($result);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* globals startDate, showOnlyTop, showFullList, endDate, reportType, accountIds, inOutReportUrl, accountReportUrl */
|
/* globals startDate, showOnlyTop, showFullList, endDate, reportType, expenseReportUri, accountIds, incExpReportUri,accountReportUri, incomeReportUri */
|
||||||
/*
|
/*
|
||||||
* all.js
|
* all.js
|
||||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
@@ -13,23 +13,19 @@ $(function () {
|
|||||||
|
|
||||||
|
|
||||||
// load the account report, which this report shows:
|
// load the account report, which this report shows:
|
||||||
loadAccountReport();
|
loadAjaxPartial('accountReport', accountReportUri);
|
||||||
|
|
||||||
// load income / expense / difference:
|
// load income and expense reports:
|
||||||
loadInOutReport();
|
loadAjaxPartial('incomeReport',incomeReportUri);
|
||||||
|
loadAjaxPartial('expenseReport',expenseReportUri);
|
||||||
// trigger info click
|
loadAjaxPartial('incomeVsExpenseReport',incExpReportUri);
|
||||||
triggerInfoClick();
|
|
||||||
|
|
||||||
// trigger list length things:
|
|
||||||
listLengthInitial();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function triggerInfoClick() {
|
function triggerInfoClick() {
|
||||||
"use strict";
|
"use strict";
|
||||||
// find the little info buttons and respond to them.
|
// find the little info buttons and respond to them.
|
||||||
$('.firefly-info-button').unbind('clicl').click(clickInfoButton);
|
$('.firefly-info-button').unbind('click').click(clickInfoButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
function listLengthInitial() {
|
function listLengthInitial() {
|
||||||
@@ -58,44 +54,6 @@ function triggerList(e) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadInOutReport() {
|
|
||||||
"use strict";
|
|
||||||
console.log('Going to grab ' + inOutReportUrl);
|
|
||||||
$.get(inOutReportUrl).done(placeInOutReport).fail(failInOutReport);
|
|
||||||
}
|
|
||||||
|
|
||||||
function placeInOutReport(data) {
|
|
||||||
"use strict";
|
|
||||||
$('#incomeReport').removeClass('loading').html(data.income);
|
|
||||||
$('#expenseReport').removeClass('loading').html(data.expenses);
|
|
||||||
$('#incomeVsExpenseReport').removeClass('loading').html(data.incomes_expenses);
|
|
||||||
listLengthInitial();
|
|
||||||
triggerInfoClick();
|
|
||||||
}
|
|
||||||
|
|
||||||
function failInOutReport() {
|
|
||||||
"use strict";
|
|
||||||
console.log('Fail in/out report data!');
|
|
||||||
$('#incomeReport').removeClass('loading').addClass('general-chart-error');
|
|
||||||
$('#expenseReport').removeClass('loading').addClass('general-chart-error');
|
|
||||||
$('#incomeVsExpenseReport').removeClass('loading').addClass('general-chart-error');
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadAccountReport() {
|
|
||||||
"use strict";
|
|
||||||
$.get(accountReportUrl).done(placeAccountReport).fail(failAccountReport);
|
|
||||||
}
|
|
||||||
|
|
||||||
function placeAccountReport(data) {
|
|
||||||
"use strict";
|
|
||||||
$('#accountReport').removeClass('loading').html(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
function failAccountReport(data) {
|
|
||||||
"use strict";
|
|
||||||
$('#accountReport').removeClass('loading').addClass('general-chart-error');
|
|
||||||
}
|
|
||||||
|
|
||||||
function clickInfoButton(e) {
|
function clickInfoButton(e) {
|
||||||
"use strict";
|
"use strict";
|
||||||
// find all data tags, regardless of what they are:
|
// find all data tags, regardless of what they are:
|
||||||
@@ -125,8 +83,7 @@ function respondInfoButton(data) {
|
|||||||
"use strict";
|
"use strict";
|
||||||
// remove wait cursor
|
// remove wait cursor
|
||||||
$('body').removeClass('waiting');
|
$('body').removeClass('waiting');
|
||||||
$('#defaultModal').empty().html(data.html);
|
$('#defaultModal').empty().html(data.html).modal('show');
|
||||||
$('#defaultModal').modal('show');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +107,12 @@ function displayAjaxPartial(data, holder) {
|
|||||||
|
|
||||||
// find a sortable table and make it sortable:
|
// find a sortable table and make it sortable:
|
||||||
$.bootstrapSortable(true);
|
$.bootstrapSortable(true);
|
||||||
|
|
||||||
|
// find the info click things and respond to them:
|
||||||
|
triggerInfoClick();
|
||||||
|
|
||||||
|
// trigger list thing
|
||||||
|
listLengthInitial();
|
||||||
}
|
}
|
||||||
|
|
||||||
function failAjaxPartial(uri, holder) {
|
function failAjaxPartial(uri, holder) {
|
||||||
|
@@ -1,74 +1,15 @@
|
|||||||
/* globals google, budgetReportUrl, startDate ,reportURL, endDate , reportType ,accountIds, lineChart, categoryReportUrl, balanceReportUrl */
|
/* globals google, categoryReportUri, budgetReportUri, balanceReportUri */
|
||||||
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
drawChart();
|
drawChart();
|
||||||
|
|
||||||
loadCategoryReport();
|
loadAjaxPartial('categoryReport', categoryReportUri);
|
||||||
loadBalanceReport();
|
loadAjaxPartial('budgetReport', budgetReportUri);
|
||||||
loadBudgetReport();
|
loadAjaxPartial('balanceReport',balanceReportUri);
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadCategoryReport() {
|
|
||||||
"use strict";
|
|
||||||
console.log('Going to grab ' + categoryReportUrl);
|
|
||||||
$.get(categoryReportUrl).done(placeCategoryReport).fail(failCategoryReport);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadBudgetReport() {
|
|
||||||
"use strict";
|
|
||||||
console.log('Going to grab ' + budgetReportUrl);
|
|
||||||
$.get(budgetReportUrl).done(placeBudgetReport).fail(failBudgetReport);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function loadBalanceReport() {
|
|
||||||
"use strict";
|
|
||||||
console.log('Going to grab ' + categoryReportUrl);
|
|
||||||
$.get(balanceReportUrl).done(placeBalanceReport).fail(failBalanceReport);
|
|
||||||
}
|
|
||||||
|
|
||||||
function placeBudgetReport(data) {
|
|
||||||
"use strict";
|
|
||||||
$('#budgetReport').removeClass('loading').html(data);
|
|
||||||
listLengthInitial();
|
|
||||||
triggerInfoClick();
|
|
||||||
}
|
|
||||||
|
|
||||||
function placeBalanceReport(data) {
|
|
||||||
"use strict";
|
|
||||||
$('#balanceReport').removeClass('loading').html(data);
|
|
||||||
listLengthInitial();
|
|
||||||
triggerInfoClick();
|
|
||||||
}
|
|
||||||
|
|
||||||
function placeCategoryReport(data) {
|
|
||||||
"use strict";
|
|
||||||
$('#categoryReport').removeClass('loading').html(data);
|
|
||||||
listLengthInitial();
|
|
||||||
triggerInfoClick();
|
|
||||||
}
|
|
||||||
|
|
||||||
function failBudgetReport() {
|
|
||||||
"use strict";
|
|
||||||
console.log('Fail budget report data!');
|
|
||||||
$('#budgetReport').removeClass('loading').addClass('general-chart-error');
|
|
||||||
}
|
|
||||||
|
|
||||||
function failBalanceReport() {
|
|
||||||
"use strict";
|
|
||||||
console.log('Fail balance report data!');
|
|
||||||
$('#balanceReport').removeClass('loading').addClass('general-chart-error');
|
|
||||||
}
|
|
||||||
|
|
||||||
function failCategoryReport() {
|
|
||||||
"use strict";
|
|
||||||
console.log('Fail category report data!');
|
|
||||||
$('#categoryReport').removeClass('loading').addClass('general-chart-error');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function drawChart() {
|
function drawChart() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* globals google, accountIds, budgetYearOverviewUrl */
|
/* globals google, accountIds, budgetYearOverviewUri */
|
||||||
|
|
||||||
var chartDrawn;
|
var chartDrawn;
|
||||||
var budgetChart;
|
var budgetChart;
|
||||||
@@ -7,30 +7,9 @@ $(function () {
|
|||||||
chartDrawn = false;
|
chartDrawn = false;
|
||||||
drawChart();
|
drawChart();
|
||||||
|
|
||||||
//
|
loadAjaxPartial('budgetOverview',budgetYearOverviewUri);
|
||||||
loadBudgetOverview();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadBudgetOverview() {
|
|
||||||
"use strict";
|
|
||||||
console.log('Going to grab ' + budgetYearOverviewUrl);
|
|
||||||
$.get(budgetYearOverviewUrl).done(placeBudgetOverview).fail(failBudgetOverview);
|
|
||||||
}
|
|
||||||
|
|
||||||
function placeBudgetOverview(data) {
|
|
||||||
"use strict";
|
|
||||||
$('#budgetOverview').removeClass('loading').html(data);
|
|
||||||
$('.budget-chart-activate').on('click', clickBudgetChart);
|
|
||||||
}
|
|
||||||
|
|
||||||
function failBudgetOverview() {
|
|
||||||
"use strict";
|
|
||||||
console.log('Fail budget overview data!');
|
|
||||||
$('#budgetOverview').removeClass('loading').addClass('general-chart-error');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function drawChart() {
|
function drawChart() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
@@ -132,11 +132,14 @@
|
|||||||
var accountIds = '{{ accountIds }}';
|
var accountIds = '{{ accountIds }}';
|
||||||
|
|
||||||
<!-- some URL's -->
|
<!-- some URL's -->
|
||||||
var accountReportUrl = '{{ route('reports.data.accountReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var accountReportUri = '{{ route('reports.data.accountReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
var inOutReportUrl = '{{ route('reports.data.inOutReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var incomeReportUri = '{{ route('reports.data.incomeReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
var categoryReportUrl = '{{ route('reports.data.categoryReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var expenseReportUri = '{{ route('reports.data.expenseReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
var balanceReportUrl = '{{ route('reports.data.balanceReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var incExpReportUri = '{{ route('reports.data.incExpReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
var budgetReportUrl = '{{ route('reports.data.budgetReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var categoryReportUri = '{{ route('reports.data.categoryReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
|
var budgetReportUri = '{{ route('reports.data.budgetReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
|
var balanceReportUri = '{{ route('reports.data.balanceReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="js/ff/reports/default/all.js"></script>
|
<script type="text/javascript" src="js/ff/reports/default/all.js"></script>
|
||||||
<script type="text/javascript" src="js/ff/reports/default/month.js"></script>
|
<script type="text/javascript" src="js/ff/reports/default/month.js"></script>
|
||||||
|
@@ -123,9 +123,12 @@
|
|||||||
var accountIds = '{{ accountIds }}';
|
var accountIds = '{{ accountIds }}';
|
||||||
|
|
||||||
<!-- some URL's -->
|
<!-- some URL's -->
|
||||||
var accountReportUrl = '{{ route('reports.data.accountReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var accountReportUri = '{{ route('reports.data.accountReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
var inOutReportUrl = '{{ route('reports.data.inOutReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var incomeReportUri = '{{ route('reports.data.incomeReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
var budgetYearOverviewUrl = '{{ route('reports.data.budgetYearOverview', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var expenseReportUri = '{{ route('reports.data.expenseReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
|
var incExpReportUri = '{{ route('reports.data.incExpReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
|
|
||||||
|
var budgetYearOverviewUri = '{{ route('reports.data.budgetYearOverview', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript" src="js/ff/reports/default/all.js"></script>
|
<script type="text/javascript" src="js/ff/reports/default/all.js"></script>
|
||||||
|
@@ -316,10 +316,20 @@ Route::group(
|
|||||||
['uses' => 'Report\AccountController@accountReport', 'as' => 'reports.data.accountReport']
|
['uses' => 'Report\AccountController@accountReport', 'as' => 'reports.data.accountReport']
|
||||||
);
|
);
|
||||||
|
|
||||||
// income report
|
// income and expenses report
|
||||||
Route::get(
|
Route::get(
|
||||||
'/reports/data/in-out-report/{start_date}/{end_date}/{accountList}',
|
'/reports/data/inc-exp-report/{start_date}/{end_date}/{accountList}',
|
||||||
['uses' => 'Report\InOutController@inOutReport', 'as' => 'reports.data.inOutReport']
|
['uses' => 'Report\InOutController@incExpReport', 'as' => 'reports.data.incExpReport']
|
||||||
|
);
|
||||||
|
// (income report):
|
||||||
|
Route::get(
|
||||||
|
'/reports/data/income-report/{start_date}/{end_date}/{accountList}',
|
||||||
|
['uses' => 'Report\InOutController@incomeReport', 'as' => 'reports.data.incomeReport']
|
||||||
|
);
|
||||||
|
// (expense report):
|
||||||
|
Route::get(
|
||||||
|
'/reports/data/expense-report/{start_date}/{end_date}/{accountList}',
|
||||||
|
['uses' => 'Report\InOutController@expenseReport', 'as' => 'reports.data.expenseReport']
|
||||||
);
|
);
|
||||||
|
|
||||||
// category report:
|
// category report:
|
||||||
|
Reference in New Issue
Block a user