From 244333adbce84ece2e71af6e2a228a1dbe51e497 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Sat, 5 Mar 2022 20:48:36 +0000 Subject: [PATCH] Fix null reference in GetIncomeAvailable --- web/src/stores/budget-account.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/src/stores/budget-account.ts b/web/src/stores/budget-account.ts index 1de29ba..becea06 100644 --- a/web/src/stores/budget-account.ts +++ b/web/src/stores/budget-account.ts @@ -61,8 +61,15 @@ export const useAccountStore = defineStore("budget/account", { }, GetIncomeAvailable(state) { return (year: number, month: number) => { + const IncomeCategoryID = this.GetIncomeCategoryID; + if(IncomeCategoryID == null) + return 0; + const categories = this.AllCategoriesForMonth(year, month); - return categories.filter(x => x.ID == this.GetIncomeCategoryID)[0].AvailableLastMonth; + const category = categories.filter(x => x.ID == IncomeCategoryID)[0]; + if (category == null) + return 0; + return category.AvailableLastMonth; } }, CategoryGroupsForMonth(state) {