From c4fc80e47d5a18afefe1cdaf3d5e232e740912fc Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Fri, 8 Apr 2022 18:28:52 +0000 Subject: [PATCH] Add type-information to GetBudgeted --- web/src/components/TransactionRow.vue | 1 - web/src/pages/Budgeting.vue | 6 +++--- web/src/stores/budget-account.ts | 16 +++++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/web/src/components/TransactionRow.vue b/web/src/components/TransactionRow.vue index 5f6f561..82320e4 100644 --- a/web/src/components/TransactionRow.vue +++ b/web/src/components/TransactionRow.vue @@ -6,7 +6,6 @@ import Currency from "./Currency.vue"; import TransactionEditRow from "./TransactionEditRow.vue"; import { formatDate } from "../date"; import { useAccountStore } from "../stores/budget-account"; -import Input from "./Input.vue"; import Checkbox from "./Checkbox.vue"; const props = defineProps<{ diff --git a/web/src/pages/Budgeting.vue b/web/src/pages/Budgeting.vue index 8b4dd8a..d0328f6 100644 --- a/web/src/pages/Budgeting.vue +++ b/web/src/pages/Budgeting.vue @@ -83,17 +83,17 @@ function assignedChanged(e : Event, category : Category){
Budgeted this month:
Deassigned this month:
Spent this month:
diff --git a/web/src/stores/budget-account.ts b/web/src/stores/budget-account.ts index 1a69526..7b08cb9 100644 --- a/web/src/stores/budget-account.ts +++ b/web/src/stores/budget-account.ts @@ -39,6 +39,12 @@ export interface Category { Activity: number; } +interface BudgetedAmounts { + Assigned: number, + Deassigned: number, + Activity: number, +} + export const useAccountStore = defineStore("budget/account", { state: (): State => ({ Accounts: new Map(), @@ -71,9 +77,9 @@ export const useAccountStore = defineStore("budget/account", { return budget.CurrentBudget?.IncomeCategoryID; }, GetBudgeted(state) { - return (year: number, month: number) => { + return (year: number, month: number) : BudgetedAmounts => { const IncomeCategoryID = this.GetIncomeCategoryID; - if (IncomeCategoryID == null) return 0; + if (IncomeCategoryID == null) return {Activity: 0, Assigned: 0, Deassigned: 0}; const categories = this.AllCategoriesForMonth(year, month); @@ -90,9 +96,9 @@ export const useAccountStore = defineStore("budget/account", { deassigned += category.Assigned; } return { - assigned, - deassigned, - activity + Assigned: assigned, + Deassigned: deassigned, + Activity: activity }; }; },