mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-29 02:11:12 -06:00
Cleanup some code.
This commit is contained in:
parent
4a93bb35f8
commit
352b996ad2
@ -155,12 +155,11 @@ class BudgetController extends Controller
|
|||||||
|
|
||||||
$dateAsString = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
|
$dateAsString = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
|
||||||
$budgetIncomeTotal = Preferences::get('budgetIncomeTotal' . $dateAsString, 1000)->data;
|
$budgetIncomeTotal = Preferences::get('budgetIncomeTotal' . $dateAsString, 1000)->data;
|
||||||
$spentPercentage = ($spent > $budgeted) ? ceil($budgeted / $spent * 100) : ceil($spent / $budgeted * 100);
|
|
||||||
$budgetMaximum = Preferences::get('budgetMaximum', 1000)->data;
|
$budgetMaximum = Preferences::get('budgetMaximum', 1000)->data;
|
||||||
$defaultCurrency = Amount::getDefaultCurrency();
|
$defaultCurrency = Amount::getDefaultCurrency();
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'budgets.index', compact('budgetMaximum', 'budgetIncomeTotal', 'defaultCurrency', 'inactive', 'budgets', 'spent', 'spentPercentage', 'budgeted')
|
'budgets.index', compact('budgetMaximum', 'budgetIncomeTotal', 'defaultCurrency', 'inactive', 'budgets', 'spent', 'budgeted')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
/* globals $, budgeted, currencySymbol, overspent, budgetIncomeTotal ,budgetedMuch, budgetedPercentage, token, budgetID, repetitionID, spent, budgeted, overspent, spentPercentage */
|
/* globals $, budgeted:false, currencySymbol, budgetIncomeTotal ,budgetedMuch, budgetedPercentage, token, budgetID, repetitionID, spent, budgeted*/
|
||||||
|
|
||||||
function drawSpentBar() {
|
function drawSpentBar() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var overspent = spent > budgeted;
|
||||||
|
var pct;
|
||||||
|
|
||||||
if (overspent) {
|
if (overspent) {
|
||||||
// draw overspent bar
|
// draw overspent bar
|
||||||
$('.spentBar .progress-bar-warning').css('width', spentPercentage + '%');
|
pct = (budgeted / spent) * 100;
|
||||||
$('.spentBar .progress-bar-danger').css('width', (100 - spentPercentage) + '%');
|
$('.spentBar .progress-bar-warning').css('width', pct + '%');
|
||||||
|
$('.spentBar .progress-bar-danger').css('width', (100 - pct) + '%');
|
||||||
} else {
|
} else {
|
||||||
// draw normal bar:
|
// draw normal bar:
|
||||||
$('.spentBar .progress-bar-info').css('width', spentPercentage + '%');
|
pct = (spent / budgeted) * 100;
|
||||||
|
$('.spentBar .progress-bar-info').css('width', pct + '%');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,13 +28,11 @@ function drawBudgetedBar() {
|
|||||||
if (budgetedMuch) {
|
if (budgetedMuch) {
|
||||||
// budgeted too much.
|
// budgeted too much.
|
||||||
pct = (budgetIncomeTotal / budgeted) * 100;
|
pct = (budgetIncomeTotal / budgeted) * 100;
|
||||||
console.log('Budgeted TOO much. Pct is ' + pct)
|
|
||||||
$('.budgetedBar .progress-bar-warning').css('width', pct + '%');
|
$('.budgetedBar .progress-bar-warning').css('width', pct + '%');
|
||||||
$('.budgetedBar .progress-bar-danger').css('width', (100 - pct) + '%');
|
$('.budgetedBar .progress-bar-danger').css('width', (100 - pct) + '%');
|
||||||
$('.budgetedBar .progress-bar-info').css('width', 0);
|
$('.budgetedBar .progress-bar-info').css('width', 0);
|
||||||
} else {
|
} else {
|
||||||
pct = (budgeted / budgetIncomeTotal) * 100;
|
pct = (budgeted / budgetIncomeTotal) * 100;
|
||||||
console.log('Not budgeted too much. Pct is ' + pct)
|
|
||||||
$('.budgetedBar .progress-bar-warning').css('width', 0);
|
$('.budgetedBar .progress-bar-warning').css('width', 0);
|
||||||
$('.budgetedBar .progress-bar-danger').css('width', 0);
|
$('.budgetedBar .progress-bar-danger').css('width', 0);
|
||||||
$('.budgetedBar .progress-bar-info').css('width', pct + '%');
|
$('.budgetedBar .progress-bar-info').css('width', pct + '%');
|
||||||
|
@ -157,8 +157,6 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// actually spent bar data:
|
// actually spent bar data:
|
||||||
var spent = {{ spent }};
|
var spent = {{ spent }};
|
||||||
var overspent = {{ spent }} > {{ budgeted }};
|
|
||||||
var spentPercentage = {{ spentPercentage }};
|
|
||||||
var currencySymbol = "{{ getCurrencySymbol()|raw }}";
|
var currencySymbol = "{{ getCurrencySymbol()|raw }}";
|
||||||
|
|
||||||
// budgeted data:
|
// budgeted data:
|
||||||
|
Loading…
Reference in New Issue
Block a user