Add assigned, deassigned and activity to budgeting screen

This commit is contained in:
Jan Bader 2022-04-05 15:08:33 +00:00
parent ae529665a3
commit cef62574bb
2 changed files with 43 additions and 1 deletions

View File

@ -79,7 +79,23 @@ function assignedChanged(e : Event, category : Category){
<span>Available balance: <span>Available balance:
<Currency <Currency
:value="accountStore.GetIncomeAvailable(selected.Year, selected.Month)" :value="accountStore.GetIncomeAvailable(selected.Year, selected.Month)"
/></span> />
</span><br />
<span>Budgeted this month:
<Currency
:value="accountStore.GetBudgeted(selected.Year, selected.Month).assigned"
/>
</span><br />
<span>Budgeted this month:
<Currency
:value="accountStore.GetBudgeted(selected.Year, selected.Month).deassigned"
/>
</span><br />
<span>Budgeted this month:
<Currency
:value="accountStore.GetBudgeted(selected.Year, selected.Month).activity"
/>
</span><br />
<div> <div>
<router-link <router-link
:to="'/budget/' + CurrentBudgetID + '/budgeting/' + previous.Year + '/' + previous.Month" :to="'/budget/' + CurrentBudgetID + '/budgeting/' + previous.Year + '/' + previous.Month"

View File

@ -68,6 +68,32 @@ export const useAccountStore = defineStore("budget/account", {
const budget = useBudgetsStore(); const budget = useBudgetsStore();
return budget.CurrentBudget?.IncomeCategoryID; return budget.CurrentBudget?.IncomeCategoryID;
}, },
GetBudgeted(state) {
return (year: number, month: number) => {
const IncomeCategoryID = this.GetIncomeCategoryID;
if (IncomeCategoryID == null) return 0;
const categories = this.AllCategoriesForMonth(year, month);
let assigned = 0, deassigned = 0;
let activity = 0;
for (const category of categories) {
if (category.ID == IncomeCategoryID)
continue;
activity += category.Activity;
if(category.Assigned > 0)
assigned += category.Assigned;
else
deassigned += category.Assigned;
}
return {
assigned,
deassigned,
activity
};
};
},
GetIncomeAvailable(state) { GetIncomeAvailable(state) {
return (year: number, month: number) => { return (year: number, month: number) => {
const IncomeCategoryID = this.GetIncomeCategoryID; const IncomeCategoryID = this.GetIncomeCategoryID;