diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.php
new file mode 100644
index 0000000000..1d139c23ca
--- /dev/null
+++ b/app/Http/Controllers/Report/BudgetController.php
@@ -0,0 +1,91 @@
+addProperty($start);
+ $cache->addProperty($end);
+ $cache->addProperty('budget-report');
+ $cache->addProperty($accounts->pluck('id')->toArray());
+ if ($cache->has()) {
+ return $cache->get();
+ }
+
+ $budgets = $helper->getBudgetReport($start, $end, $accounts);
+
+ $result = view('reports.partials.budgets', compact('budgets'))->render();
+ $cache->store($result);
+
+ return $result;
+
+ }
+
+ /**
+ * @param BudgetReportHelperInterface $helper
+ * @param Carbon $start
+ * @param Carbon $end
+ * @param Collection $accounts
+ *
+ * @return string
+ */
+ public function budgetYearOverview(BudgetReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
+ {
+
+ // chart properties for cache:
+ $cache = new CacheProperties;
+ $cache->addProperty($start);
+ $cache->addProperty($end);
+ $cache->addProperty('budget-year-overview');
+ $cache->addProperty($accounts->pluck('id')->toArray());
+ if ($cache->has()) {
+ return $cache->get();
+ }
+
+ $budgets = $helper->budgetYearOverview($start, $end, $accounts);
+
+ $result = view('reports.partials.budget-year-overview', compact('budgets'))->render();
+ $cache->store($result);
+
+ return $result;
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index ab3833555a..77a50d7218 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -15,7 +15,6 @@ namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
-use FireflyIII\Helpers\Report\BudgetReportHelperInterface;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
@@ -37,8 +36,6 @@ use View;
*/
class ReportController extends Controller
{
- /** @var BudgetReportHelperInterface */
- protected $budgetHelper;
/** @var ReportHelperInterface */
protected $helper;
@@ -55,8 +52,7 @@ class ReportController extends Controller
View::share('title', trans('firefly.reports'));
View::share('mainTitleIcon', 'fa-line-chart');
- $this->helper = app(ReportHelperInterface::class);
- $this->budgetHelper = app(BudgetReportHelperInterface::class);
+ $this->helper = app(ReportHelperInterface::class);
return $next($request);
}
@@ -219,10 +215,8 @@ class ReportController extends Controller
*/
private function defaultMonth(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
{
- // get report stuff!
- $budgets = $this->budgetHelper->getBudgetReport($start, $end, $accounts);
- $bills = $this->helper->getBillReport($start, $end, $accounts);
- $tags = $this->helper->tagReport($start, $end, $accounts);
+ $bills = $this->helper->getBillReport($start, $end, $accounts);
+ $tags = $this->helper->tagReport($start, $end, $accounts);
// and some id's, joined:
$accountIds = join(',', $accounts->pluck('id')->toArray());
@@ -233,9 +227,9 @@ class ReportController extends Controller
compact(
'start', 'end',
'tags',
- 'budgets',
'bills',
- 'accountIds', 'reportType'
+ 'accountIds',
+ 'reportType'
)
);
}
@@ -281,8 +275,7 @@ class ReportController extends Controller
*/
private function defaultYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
{
- $tags = $this->helper->tagReport($start, $end, $accounts);
- $budgets = $this->budgetHelper->budgetYearOverview($start, $end, $accounts);
+ $tags = $this->helper->tagReport($start, $end, $accounts);
Session::flash('gaEventCategory', 'report');
Session::flash('gaEventAction', 'year');
@@ -299,7 +292,8 @@ class ReportController extends Controller
return view(
'reports.default.year',
compact(
- 'start', 'reportType', 'accountIds', 'end', 'tags', 'budgets'
+ 'start', 'reportType',
+ 'accountIds', 'end', 'tags'
)
);
}
diff --git a/app/Import/Setup/CsvSetup.php b/app/Import/Setup/CsvSetup.php
index a49c5fe070..cefeebe275 100644
--- a/app/Import/Setup/CsvSetup.php
+++ b/app/Import/Setup/CsvSetup.php
@@ -323,6 +323,7 @@ class CsvSetup implements SetupInterface
foreach ($config['column-do-mapping'] as $index => $mustBeMapped) {
if ($mustBeMapped) {
+
$column = $config['column-roles'][$index] ?? '_ignore';
// is valid column?
diff --git a/public/js/ff/reports/default/month.js b/public/js/ff/reports/default/month.js
index d9f30b1f8c..7c15f922b6 100644
--- a/public/js/ff/reports/default/month.js
+++ b/public/js/ff/reports/default/month.js
@@ -1,4 +1,4 @@
-/* globals google, startDate ,reportURL, endDate , reportType ,accountIds, lineChart, categoryReportUrl, balanceReportUrl */
+/* globals google, budgetReportUrl, startDate ,reportURL, endDate , reportType ,accountIds, lineChart, categoryReportUrl, balanceReportUrl */
$(function () {
@@ -7,6 +7,7 @@ $(function () {
loadCategoryReport();
loadBalanceReport();
+ loadBudgetReport();
});
function loadCategoryReport() {
@@ -15,12 +16,26 @@ function loadCategoryReport() {
$.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);
@@ -35,6 +50,12 @@ function placeCategoryReport(data) {
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!');
diff --git a/public/js/ff/reports/default/year.js b/public/js/ff/reports/default/year.js
index 3afa11d242..e0cb494772 100644
--- a/public/js/ff/reports/default/year.js
+++ b/public/js/ff/reports/default/year.js
@@ -1,4 +1,4 @@
-/* globals google, startDate ,reportURL, endDate , reportType ,accountIds , picker:true, minDate, year, month, columnChart, lineChart, stackedColumnChart */
+/* globals google, accountIds, budgetYearOverviewUrl */
var chartDrawn;
var budgetChart;
@@ -7,8 +7,29 @@ $(function () {
chartDrawn = false;
drawChart();
+ //
+ 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() {
"use strict";
@@ -17,7 +38,7 @@ function drawChart() {
columnChart('chart/report/in-out/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds, 'income-expenses-chart');
columnChart('chart/report/in-out-sum/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds, 'income-expenses-sum-chart');
- $('.budget-chart-activate').on('click', clickBudgetChart);
+
}
function clickBudgetChart(e) {
diff --git a/resources/views/reports/default/month.twig b/resources/views/reports/default/month.twig
index 6e27d82518..bd4f6789b8 100644
--- a/resources/views/reports/default/month.twig
+++ b/resources/views/reports/default/month.twig
@@ -67,8 +67,17 @@
-
- {% include 'reports/partials/budgets.twig' %}
+
+
+
+
@@ -127,6 +136,7 @@
var inOutReportUrl = '{{ route('reports.data.inOutReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
var categoryReportUrl = '{{ route('reports.data.categoryReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
var balanceReportUrl = '{{ route('reports.data.balanceReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var budgetReportUrl = '{{ route('reports.data.budgetReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
diff --git a/resources/views/reports/default/year.twig b/resources/views/reports/default/year.twig
index 1db568296a..41e6ef0ebb 100644
--- a/resources/views/reports/default/year.twig
+++ b/resources/views/reports/default/year.twig
@@ -90,32 +90,7 @@
-
-
-
-
- | |
- {% for date, header in budgets.get('headers') %}
- {{ header }} |
- {% endfor %}
-
-
-
- {% set spentData = budgets.get('spent') %}
- {% for budgetId, budgetName in budgets.get('budgets') %}
-
- |
- {{ budgetName }}
- |
- {% for date, header in budgets.get('headers') %}
- {{ spentData[budgetId][date]|formatAmount }} |
- {% endfor %}
-
-
- {% endfor %}
-
-
-
+
@@ -150,6 +125,7 @@
var accountReportUrl = '{{ 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 budgetYearOverviewUrl = '{{ route('reports.data.budgetYearOverview', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
diff --git a/resources/views/reports/partials/budget-year-overview.twig b/resources/views/reports/partials/budget-year-overview.twig
new file mode 100644
index 0000000000..6836d0d25b
--- /dev/null
+++ b/resources/views/reports/partials/budget-year-overview.twig
@@ -0,0 +1,25 @@
+
+
+
+ | |
+ {% for date, header in budgets.get('headers') %}
+ {{ header }} |
+ {% endfor %}
+
+
+
+ {% set spentData = budgets.get('spent') %}
+ {% for budgetId, budgetName in budgets.get('budgets') %}
+
+ |
+ {{ budgetName }}
+ |
+ {% for date, header in budgets.get('headers') %}
+ {{ spentData[budgetId][date]|formatAmount }} |
+ {% endfor %}
+
+
+ {% endfor %}
+
+
+
\ No newline at end of file
diff --git a/resources/views/reports/partials/budgets.twig b/resources/views/reports/partials/budgets.twig
index c48dfc87ce..24880e9e46 100644
--- a/resources/views/reports/partials/budgets.twig
+++ b/resources/views/reports/partials/budgets.twig
@@ -1,87 +1,79 @@
-
+
+
+
+ | {{ 'budget'|_ }} |
+ {{ 'date'|_ }} |
+ {{ 'budgeted'|_ }} |
+ {{ 'spent'|_ }} |
+ {{ 'left'|_ }} |
+ {{ 'overspent'|_ }} |
+
+
+
+ {% for budgetLine in budgets.getBudgetLines %}
+
+ |
+ {% if budgetLine.getBudget.id %}
+ {{ budgetLine.getBudget.name }}
+ {% else %}
+ {{ 'no_budget'|_ }}
+ {% endif %}
+ |
+
+ {% if budgetLine.getRepetition.id %}
+
+ {{ budgetLine.getRepetition.startdate.formatLocalized(monthAndDayFormat) }}
+ —
+ {{ budgetLine.getRepetition.enddate.formatLocalized(monthAndDayFormat) }}
+
+ {% endif %}
+ |
+
+ {% if budgetLine.getRepetition.id %}
+ {{ budgetLine.getRepetition.amount|formatAmount }}
+ {% else %}
+ {{ 0|formatAmount }}
+ {% endif %}
+ |
+
+ {% if budgetLine.getSpent != 0 %}
+ {{ budgetLine.getSpent|formatAmount }}
+ {% endif %}
-
-
-
-
-
- | {{ 'budget'|_ }} |
- {{ 'date'|_ }} |
- {{ 'budgeted'|_ }} |
- {{ 'spent'|_ }} |
- {{ 'left'|_ }} |
- {{ 'overspent'|_ }} |
-
-
-
- {% for budgetLine in budgets.getBudgetLines %}
-
- |
- {% if budgetLine.getBudget.id %}
- {{ budgetLine.getBudget.name }}
- {% else %}
- {{ 'no_budget'|_ }}
- {% endif %}
- |
-
- {% if budgetLine.getRepetition.id %}
-
- {{ budgetLine.getRepetition.startdate.formatLocalized(monthAndDayFormat) }}
- —
- {{ budgetLine.getRepetition.enddate.formatLocalized(monthAndDayFormat) }}
-
- {% endif %}
- |
-
- {% if budgetLine.getRepetition.id %}
- {{ budgetLine.getRepetition.amount|formatAmount }}
- {% else %}
- {{ 0|formatAmount }}
- {% endif %}
- |
-
- {% if budgetLine.getSpent != 0 %}
- {{ budgetLine.getSpent|formatAmount }}
- {% endif %}
+ {% if budgetLine.getSpent == 0 %}
+ {{ budgetLine.getSpent|formatAmount }}
+ {% endif %}
- {% if budgetLine.getSpent == 0 %}
- {{ budgetLine.getSpent|formatAmount }}
- {% endif %}
-
- |
-
- {% if(budgetLine.getOverspent == 0) %}
- {{ budgetLine.getLeft|formatAmount }}
- {% endif %}
- |
-
- {% if budgetLine.getOverspent != 0 %}
- {{ budgetLine.getOverspent|formatAmount }}
- {% endif %}
- |
-
- {% endfor %}
-
-
-
- | {{ 'sum'|_ }} |
- {{ budgets.getBudgeted|formatAmount }} |
-
- {% if budgets.getSpent != 0 %}
- {{ budgets.getSpent|formatAmountPlain }}
- {% endif %}
- {% if budgets.getSpent == 0 %}
- {{ budgets.getSpent|formatAmount }}
- {% endif %}
- |
- {{ budgets.getLeft|formatAmount }} |
- {{ budgets.getOverspent|formatAmountPlain }} |
-
-
-
-
-
+ |
+
+ {% if(budgetLine.getOverspent == 0) %}
+ {{ budgetLine.getLeft|formatAmount }}
+ {% endif %}
+ |
+
+ {% if budgetLine.getOverspent != 0 %}
+ {{ budgetLine.getOverspent|formatAmount }}
+ {% endif %}
+ |
+
+ {% endfor %}
+
+
+
+ | {{ 'sum'|_ }} |
+ {{ budgets.getBudgeted|formatAmount }} |
+
+ {% if budgets.getSpent != 0 %}
+ {{ budgets.getSpent|formatAmountPlain }}
+ {% endif %}
+ {% if budgets.getSpent == 0 %}
+ {{ budgets.getSpent|formatAmount }}
+ {% endif %}
+ |
+ {{ budgets.getLeft|formatAmount }} |
+ {{ budgets.getOverspent|formatAmountPlain }} |
+
+
+
diff --git a/routes/web.php b/routes/web.php
index 89284d06cc..69fd01df55 100755
--- a/routes/web.php
+++ b/routes/web.php
@@ -339,6 +339,18 @@ Route::group(
['uses' => 'Report\BalanceController@balanceReport', 'as' => 'reports.data.balanceReport']
);
+ // budget report:
+ Route::get(
+ '/reports/data/budget-report/{start_date}/{end_date}/{accountList}',
+ ['uses' => 'Report\BudgetController@budgetReport', 'as' => 'reports.data.budgetReport']
+ );
+ // budget year overview
+ Route::get(
+ '/reports/data/budget-year-overview/{start_date}/{end_date}/{accountList}',
+ ['uses' => 'Report\BudgetController@budgetYearOverview', 'as' => 'reports.data.budgetYearOverview']
+ );
+
+
/**
* Rules Controller
*/
@@ -401,15 +413,21 @@ Route::group(
*/
// normal controller
- Route::get('/transactions/{what}', ['uses' => 'TransactionController@index', 'as' => 'transactions.index'])->where(['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']);
+ Route::get('/transactions/{what}', ['uses' => 'TransactionController@index', 'as' => 'transactions.index'])->where(
+ ['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']
+ );
Route::get('/transaction/show/{tj}', ['uses' => 'TransactionController@show', 'as' => 'transactions.show']);
Route::post('/transaction/reorder', ['uses' => 'TransactionController@reorder', 'as' => 'transactions.reorder']);
// single controller
- Route::get('/transactions/create/{what}', ['uses' => 'Transaction\SingleController@create', 'as' => 'transactions.create'])->where(['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']);
+ Route::get('/transactions/create/{what}', ['uses' => 'Transaction\SingleController@create', 'as' => 'transactions.create'])->where(
+ ['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']
+ );
Route::get('/transaction/edit/{tj}', ['uses' => 'Transaction\SingleController@edit', 'as' => 'transactions.edit']);
Route::get('/transaction/delete/{tj}', ['uses' => 'Transaction\SingleController@delete', 'as' => 'transactions.delete']);
- Route::post('/transactions/store/{what}', ['uses' => 'Transaction\SingleController@store', 'as' => 'transactions.store'])->where(['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']);
+ Route::post('/transactions/store/{what}', ['uses' => 'Transaction\SingleController@store', 'as' => 'transactions.store'])->where(
+ ['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']
+ );
Route::post('/transaction/update/{tj}', ['uses' => 'Transaction\SingleController@update', 'as' => 'transactions.update']);
Route::post('/transaction/destroy/{tj}', ['uses' => 'Transaction\SingleController@destroy', 'as' => 'transactions.destroy']);