Split activity into income and spending
This commit is contained in:
@ -42,7 +42,8 @@ export interface Category {
|
||||
interface BudgetedAmounts {
|
||||
Assigned: number,
|
||||
Deassigned: number,
|
||||
Activity: number,
|
||||
Spent: number,
|
||||
Income: number,
|
||||
}
|
||||
|
||||
export const useAccountStore = defineStore("budget/account", {
|
||||
@ -79,17 +80,20 @@ export const useAccountStore = defineStore("budget/account", {
|
||||
GetBudgeted(state) {
|
||||
return (year: number, month: number) : BudgetedAmounts => {
|
||||
const IncomeCategoryID = this.GetIncomeCategoryID;
|
||||
if (IncomeCategoryID == null) return {Activity: 0, Assigned: 0, Deassigned: 0};
|
||||
if (IncomeCategoryID == null) return {Spent: 0, Income: 0, Assigned: 0, Deassigned: 0};
|
||||
|
||||
const categories = this.AllCategoriesForMonth(year, month);
|
||||
|
||||
let assigned = 0, deassigned = 0;
|
||||
let activity = 0;
|
||||
let spent = 0, income = 0;
|
||||
for (const category of categories) {
|
||||
if (category.ID == IncomeCategoryID)
|
||||
continue;
|
||||
|
||||
activity += category.Activity;
|
||||
if(category.Activity > 0)
|
||||
income += category.Activity;
|
||||
else
|
||||
spent += category.Activity;
|
||||
if(category.Assigned > 0)
|
||||
assigned += category.Assigned;
|
||||
else
|
||||
@ -98,7 +102,8 @@ export const useAccountStore = defineStore("budget/account", {
|
||||
return {
|
||||
Assigned: assigned,
|
||||
Deassigned: deassigned,
|
||||
Activity: activity
|
||||
Spent: spent,
|
||||
Income: income
|
||||
};
|
||||
};
|
||||
},
|
||||
|
Reference in New Issue
Block a user