mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
More routes fixed.
This commit is contained in:
parent
bebfbf0b90
commit
02257e3887
@ -332,7 +332,7 @@ class BudgetController extends Controller
|
|||||||
* @return View
|
* @return View
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function showWithRepetition(Budget $budget, LimitRepetition $repetition)
|
public function showByRepetition(Budget $budget, LimitRepetition $repetition)
|
||||||
{
|
{
|
||||||
if ($repetition->budgetLimit->budget->id != $budget->id) {
|
if ($repetition->budgetLimit->budget->id != $budget->id) {
|
||||||
throw new FireflyException('This budget limit is not part of this budget.');
|
throw new FireflyException('This budget limit is not part of this budget.');
|
||||||
|
@ -193,7 +193,7 @@ class BudgetController extends Controller
|
|||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function period(BudgetRepositoryInterface $repository, Budget $budget, Carbon $start, Carbon $end, Collection $accounts)
|
public function period(BudgetRepositoryInterface $repository, Budget $budget, Collection $accounts, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
// chart properties for cache:
|
// chart properties for cache:
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
@ -254,14 +254,13 @@ class BudgetController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param BudgetRepositoryInterface $repository
|
* @param BudgetRepositoryInterface $repository
|
||||||
* @param Budget $budget
|
* @param Collection $accounts
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function periodNoBudget(BudgetRepositoryInterface $repository, Carbon $start, Carbon $end, Collection $accounts)
|
public function periodNoBudget(BudgetRepositoryInterface $repository, Collection $accounts, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
// chart properties for cache:
|
// chart properties for cache:
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
|
@ -30,15 +30,45 @@ use Navigation;
|
|||||||
class BudgetController extends Controller
|
class BudgetController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param BudgetReportHelperInterface $helper
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
|
* @return mixed|string
|
||||||
|
*/
|
||||||
|
public function general(BudgetReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end)
|
||||||
|
{
|
||||||
|
|
||||||
|
// chart properties for cache:
|
||||||
|
$cache = new CacheProperties;
|
||||||
|
$cache->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 Collection $accounts
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return mixed|string
|
||||||
*/
|
*/
|
||||||
public function budgetPeriodReport(Carbon $start, Carbon $end, Collection $accounts)
|
public function period(Collection $accounts, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
@ -64,36 +94,6 @@ class BudgetController extends Controller
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param BudgetReportHelperInterface $helper
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function budgetReport(BudgetReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
|
|
||||||
{
|
|
||||||
|
|
||||||
// chart properties for cache:
|
|
||||||
$cache = new CacheProperties;
|
|
||||||
$cache->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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters empty results from getBudgetPeriodReport
|
* Filters empty results from getBudgetPeriodReport
|
||||||
*
|
*
|
||||||
|
@ -1,117 +1,6 @@
|
|||||||
/* globals $, budgeted:true, currencySymbol, budgetIncomeTotal, columnChart, budgetedMuch, budgetedPercentage, token, budgetID, repetitionID, spent, lineChart */
|
|
||||||
|
|
||||||
function drawSpentBar() {
|
|
||||||
"use strict";
|
|
||||||
if ($('.spentBar').length > 0) {
|
|
||||||
var overspent = spent > budgeted;
|
|
||||||
var pct;
|
|
||||||
|
|
||||||
if (overspent) {
|
|
||||||
// draw overspent bar
|
|
||||||
pct = (budgeted / spent) * 100;
|
|
||||||
$('.spentBar .progress-bar-warning').css('width', pct + '%');
|
|
||||||
$('.spentBar .progress-bar-danger').css('width', (100 - pct) + '%');
|
|
||||||
} else {
|
|
||||||
// draw normal bar:
|
|
||||||
pct = (spent / budgeted) * 100;
|
|
||||||
$('.spentBar .progress-bar-info').css('width', pct + '%');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawBudgetedBar() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
if ($('.budgetedBar').length > 0) {
|
|
||||||
var budgetedMuch = budgeted > budgetIncomeTotal;
|
|
||||||
|
|
||||||
// recalculate percentage:
|
|
||||||
|
|
||||||
var pct;
|
|
||||||
if (budgetedMuch) {
|
|
||||||
// budgeted too much.
|
|
||||||
pct = (budgetIncomeTotal / budgeted) * 100;
|
|
||||||
$('.budgetedBar .progress-bar-warning').css('width', pct + '%');
|
|
||||||
$('.budgetedBar .progress-bar-danger').css('width', (100 - pct) + '%');
|
|
||||||
$('.budgetedBar .progress-bar-info').css('width', 0);
|
|
||||||
} else {
|
|
||||||
pct = (budgeted / budgetIncomeTotal) * 100;
|
|
||||||
$('.budgetedBar .progress-bar-warning').css('width', 0);
|
|
||||||
$('.budgetedBar .progress-bar-danger').css('width', 0);
|
|
||||||
$('.budgetedBar .progress-bar-info').css('width', pct + '%');
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#budgetedAmount').html(currencySymbol + ' ' + budgeted.toFixed(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateBudgetedAmounts(e) {
|
|
||||||
"use strict";
|
|
||||||
var target = $(e.target);
|
|
||||||
var id = target.data('id');
|
|
||||||
var value = target.val();
|
|
||||||
var original = target.data('original');
|
|
||||||
var difference = value - original;
|
|
||||||
if (difference !== 0) {
|
|
||||||
// add difference to 'budgeted' var
|
|
||||||
budgeted = budgeted + difference;
|
|
||||||
|
|
||||||
// update original:
|
|
||||||
target.data('original', value);
|
|
||||||
// run drawBudgetedBar() again:
|
|
||||||
drawBudgetedBar();
|
|
||||||
|
|
||||||
// send a post to Firefly to update the amount:
|
|
||||||
$.post('budgets/amount/' + id, {amount: value, _token: token}).done(function (data) {
|
|
||||||
// update the link if relevant:
|
|
||||||
if (data.repetition > 0) {
|
|
||||||
$('.budget-link[data-id="' + id + '"]').attr('href', 'budgets/show/' + id + '/' + data.repetition);
|
|
||||||
} else {
|
|
||||||
$('.budget-link[data-id="' + id + '"]').attr('href', 'budgets/show/' + id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
console.log('Budget id is ' + id);
|
|
||||||
console.log('Difference = ' + (value - original ));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
$('.updateIncome').on('click', updateIncome);
|
columnChart(budgetChartUri, 'budgetOverview');
|
||||||
|
|
||||||
/*
|
|
||||||
On start, fill the "spent"-bar using the content from the page.
|
|
||||||
*/
|
|
||||||
drawSpentBar();
|
|
||||||
drawBudgetedBar();
|
|
||||||
|
|
||||||
/*
|
|
||||||
When the input changes, update the percentages for the budgeted bar:
|
|
||||||
*/
|
|
||||||
$('input[type="number"]').on('input', updateBudgetedAmounts);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Draw the charts, if necessary:
|
|
||||||
*/
|
|
||||||
if (typeof budgetID !== 'undefined' && typeof repetitionID === 'undefined') {
|
|
||||||
columnChart('chart/budget/' + budgetID, 'budgetOverview');
|
|
||||||
}
|
|
||||||
if (typeof budgetID !== 'undefined' && typeof repetitionID !== 'undefined') {
|
|
||||||
lineChart('chart/budget/' + budgetID + '/' + repetitionID, 'budgetOverview');
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateIncome() {
|
|
||||||
"use strict";
|
|
||||||
$('#defaultModal').empty().load('budgets/income', function () {
|
|
||||||
$('#defaultModal').modal('show');
|
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
@ -120,7 +120,7 @@ function clickBudgetChart(e) {
|
|||||||
var link = $(e.target);
|
var link = $(e.target);
|
||||||
var budgetId = link.data('budget');
|
var budgetId = link.data('budget');
|
||||||
|
|
||||||
var URL = 'chart/budget/period/' + budgetId + '/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds;
|
var URL = 'chart/budget/period/' + budgetId + '/' + accountIds + '/' + startDate + '/' + endDate;
|
||||||
var container = 'budget_chart';
|
var container = 'budget_chart';
|
||||||
columnChart(URL, container);
|
columnChart(URL, container);
|
||||||
return false;
|
return false;
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title"><a
|
<h3 class="box-title"><a
|
||||||
href="{{ route('budgets.showWithRepetition',[budget.id,limit.id]) }}">{{ limit.startdate.formatLocalized(monthFormat) }}</a>
|
href="{{ route('budgets.show.repetition',[budget.id,limit.id]) }}">{{ limit.startdate.formatLocalized(monthFormat) }}</a>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
@ -98,10 +98,12 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var budgetID = {{ budget.id }};
|
var budgetID = {{ budget.id }};
|
||||||
{% if repetition.id %}
|
{% if repetition.id %}
|
||||||
var repetitionID = {{ repetition.id }};
|
var repetitionID = {{ repetition.id }};
|
||||||
var year = {{ repetition.startdate.format('Y') }};
|
var year = {{ repetition.startdate.format('Y') }};
|
||||||
|
var budgetChartUri = '{{ route('chart.budget.budget-limit', [budget.id, repetition.id] ) }}';
|
||||||
{% else %}
|
{% else %}
|
||||||
var year = {{ Session.get('start').format('Y') }};
|
var year = {{ Session.get('start').format('Y') }};
|
||||||
|
var budgetChartUri = '{{ route('chart.budget.budget', [budget.id] ) }}';
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -170,14 +170,15 @@
|
|||||||
var reportType = '{{ reportType }}';
|
var reportType = '{{ reportType }}';
|
||||||
var accountIds = '{{ accountIds }}';
|
var accountIds = '{{ accountIds }}';
|
||||||
|
|
||||||
var accountReportUri = '{{ route('report-data.account.general', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var accountReportUri = '{{ route('report-data.account.general', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
var incomeReportUri = '{{ route('report-data.operations.income', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var incomeReportUri = '{{ route('report-data.operations.income', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
var expenseReportUri = '{{ route('report-data.operations.expenses', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var expenseReportUri = '{{ route('report-data.operations.expenses', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
var incExpReportUri = '{{ route('report-data.operations.operations', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
var incExpReportUri = '{{ route('report-data.operations.operations', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
|
|
||||||
|
var budgetPeriodReportUri = '{{ route('report-data.budget.period', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
|
var categoryExpenseUri = '{{ route('report-data.category.expenses', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
|
var categoryIncomeUri = '{{ route('report-data.category.income', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
|
|
||||||
var budgetPeriodReportUri = '{{ route('report-data.budget.period', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
|
||||||
var categoryExpenseUri = '{{ route('report-data.category.expenses', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
|
||||||
var categoryIncomeUri = '{{ route('report-data.category.income', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -253,13 +253,14 @@ Route::group(
|
|||||||
* Chart\Budget Controller
|
* Chart\Budget Controller
|
||||||
*/
|
*/
|
||||||
Route::group(
|
Route::group(
|
||||||
['middleware' => 'user-full-auth', 'namespace' => 'Chart', 'prefix' => 'chart/budget'], function () {
|
['middleware' => 'user-full-auth', 'namespace' => 'Chart', 'prefix' => 'chart/budget','as' => 'chart.budget.'], function () {
|
||||||
|
|
||||||
Route::get('frontpage', ['uses' => 'BudgetController@frontpage']);
|
Route::get('frontpage', ['uses' => 'BudgetController@frontpage']);
|
||||||
|
|
||||||
Route::get('period/0/{accountList}/{start_date}/{end_date}', ['uses' => 'BudgetController@periodNoBudget']);
|
Route::get('period/0/{accountList}/{start_date}/{end_date}', ['uses' => 'BudgetController@periodNoBudget']);
|
||||||
Route::get('period/{budget}/{accountList}/{start_date}/{end_date}', ['uses' => 'BudgetController@period']);
|
Route::get('period/{budget}/{accountList}/{start_date}/{end_date}', ['uses' => 'BudgetController@period']);
|
||||||
Route::get('budget/{budget}/{limitrepetition}', ['uses' => 'BudgetController@budgetLimit']);
|
Route::get('budget/{budget}/{limitrepetition}', ['uses' => 'BudgetController@budgetLimit', 'as' => 'budget-limit']);
|
||||||
Route::get('budget/{budget}', ['uses' => 'BudgetController@budget']);
|
Route::get('budget/{budget}', ['uses' => 'BudgetController@budget', 'as' => 'budget']);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -269,6 +270,7 @@ Route::group(
|
|||||||
*/
|
*/
|
||||||
Route::group(
|
Route::group(
|
||||||
['middleware' => 'user-full-auth', 'namespace' => 'Chart', 'prefix' => 'chart/category'], function () {
|
['middleware' => 'user-full-auth', 'namespace' => 'Chart', 'prefix' => 'chart/category'], function () {
|
||||||
|
|
||||||
Route::get('frontpage', ['uses' => 'CategoryController@frontpage']);
|
Route::get('frontpage', ['uses' => 'CategoryController@frontpage']);
|
||||||
Route::get('period/{category}', ['uses' => 'CategoryController@currentPeriod']);
|
Route::get('period/{category}', ['uses' => 'CategoryController@currentPeriod']);
|
||||||
Route::get('period/{category}/{date}', ['uses' => 'CategoryController@specificPeriod']);
|
Route::get('period/{category}/{date}', ['uses' => 'CategoryController@specificPeriod']);
|
||||||
|
Loading…
Reference in New Issue
Block a user