James Cole
2021-12-10 15:43:42 +01:00
parent b431351a22
commit 9731503826
2 changed files with 10 additions and 7 deletions

View File

@@ -31,8 +31,6 @@
<span v-if="budgetLimit.pctGreen > 35">
{{ $t('firefly.spent_x_of_y', {amount: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent), total: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount)}) }}
</span>
</div>
<div :aria-valuenow="budgetLimit.pctOrange" :style="'width: '+ budgetLimit.pctOrange + '%;'"

View File

@@ -214,26 +214,31 @@ export default {
let pctGreen = 0;
let pctOrange = 0;
let pctRed = 0;
console.log('Collected "' + period + '" budget limit #' + currentId + ' (part of budget #' + budgetId + ')');
//console.log('Collected "' + period + '" budget limit #' + currentId + ' (part of budget #' + budgetId + ')');
console.log('Spent ' + spentFloatPos + ' of ' + amount);
// remove budget info from rawBudgets if it's there:
this.filterBudgets(budgetId, currencyId);
let name = this.budgets[current.attributes.budget_id].name;
// spent within budget:
if (0.0 !== spentFloat && spentFloatPos < amount) {
console.log('Spent ' + name + ' in budget');
pctGreen = (spentFloatPos / amount) * 100;
console.log('pctGreen is ' + pctGreen);
}
// spent over budget
if (0.0 !== spentFloatPos && spentFloatPos > amount) {
pctOrange = (spentFloatPos / amount) * 100;
//console.log('Spent ' + name + ' OVER budget');
pctOrange = (amount / spentFloatPos) * 100;
pctRed = 100 - pctOrange;
//console.log('orange is ' + pctOrange);
//console.log('red is ' + pctRed);
}
// spent exactly on budget
if (0.0 !== spentFloatPos && spentFloatPos === amount) {
pctOrange = 0;
pctRed = 100;
pctOrange = 100;
pctRed = 0;
}
let obj = {