diff --git a/web/src/components/Autocomplete.vue b/web/src/components/Autocomplete.vue index 22d6472..3ba1046 100644 --- a/web/src/components/Autocomplete.vue +++ b/web/src/components/Autocomplete.vue @@ -1,11 +1,11 @@ - - - {{Selected.Name}} + + {{ Selected.Name }} - - {{suggestion.Name}} - + {{ suggestion.Name }} \ No newline at end of file diff --git a/web/src/components/Card.vue b/web/src/components/Card.vue index 17a0da5..cfd4a15 100644 --- a/web/src/components/Card.vue +++ b/web/src/components/Card.vue @@ -1,9 +1,4 @@ - diff --git a/web/src/components/Currency.vue b/web/src/components/Currency.vue index d2541a5..5f09804 100644 --- a/web/src/components/Currency.vue +++ b/web/src/components/Currency.vue @@ -1,19 +1,15 @@ - - {{formattedValue}} € + {{ formattedValue }} € \ No newline at end of file diff --git a/web/src/components/TransactionRow.vue b/web/src/components/TransactionRow.vue index 00a08e5..b7c2edf 100644 --- a/web/src/components/TransactionRow.vue +++ b/web/src/components/TransactionRow.vue @@ -1,16 +1,15 @@ - diff --git a/web/src/dialogs/NewBudget.vue b/web/src/dialogs/NewBudget.vue index 85876bb..c6eecb6 100644 --- a/web/src/dialogs/NewBudget.vue +++ b/web/src/dialogs/NewBudget.vue @@ -1,26 +1,17 @@ - diff --git a/web/src/pages/Account.vue b/web/src/pages/Account.vue index 85a8d46..dcc7905 100644 --- a/web/src/pages/Account.vue +++ b/web/src/pages/Account.vue @@ -33,8 +33,8 @@ function saveTransaction(e: MouseEvent) { } const accountStore = useAccountStore(); -const CurrentAccount = accountStore.CurrentAccount; -const TransactionsList = accountStore.TransactionsList; +const CurrentAccount = computed(() => accountStore.CurrentAccount); +const TransactionsList = computed(() => accountStore.TransactionsList); diff --git a/web/src/pages/Admin.vue b/web/src/pages/Admin.vue index ec56a73..183df55 100644 --- a/web/src/pages/Admin.vue +++ b/web/src/pages/Admin.vue @@ -1,8 +1,9 @@ diff --git a/web/src/pages/BudgetSidebar.vue b/web/src/pages/BudgetSidebar.vue index ec30974..764ed67 100644 --- a/web/src/pages/BudgetSidebar.vue +++ b/web/src/pages/BudgetSidebar.vue @@ -1,4 +1,5 @@ diff --git a/web/src/pages/Budgeting.vue b/web/src/pages/Budgeting.vue index 9d8907d..cd3d7cd 100644 --- a/web/src/pages/Budgeting.vue +++ b/web/src/pages/Budgeting.vue @@ -1,13 +1,9 @@ @@ -92,4 +89,4 @@ watchEffect(() => { - \ No newline at end of file + diff --git a/web/src/pages/Login.vue b/web/src/pages/Login.vue index 5c69f61..be401cc 100644 --- a/web/src/pages/Login.vue +++ b/web/src/pages/Login.vue @@ -7,7 +7,7 @@ const error = ref(""); const login = ref({ user: "", password: "" }); onMounted(() => { - document.title = "Budgeteer - Login"; + useSessionStore().setTitle("Login"); }); function formSubmit(e: MouseEvent) { diff --git a/web/src/pages/Settings.vue b/web/src/pages/Settings.vue index 5aa2ff6..2acb8cd 100644 --- a/web/src/pages/Settings.vue +++ b/web/src/pages/Settings.vue @@ -10,7 +10,7 @@ const assignmentsFile = ref(undefined); const filesIncomplete = computed(() => transactionsFile.value == undefined || assignmentsFile.value == undefined); onMounted(() => { - document.title = "Budgeteer - Settings"; + useSessionStore().setTitle("Settings"); }); function gotAssignments(e: Event) { diff --git a/web/src/stores/budget-account.ts b/web/src/stores/budget-account.ts index c6c9278..a56f0fc 100644 --- a/web/src/stores/budget-account.ts +++ b/web/src/stores/budget-account.ts @@ -11,11 +11,24 @@ interface State { Assignments: [] } +export interface Transaction { + ID: string, + Date: string, + TransferAccount: string, + CategoryGroup: string, + Category:string, + Memo: string, + Status: string, + GroupID: string, + Payee: string, + Amount: number, +} + export interface Account { ID: string Name: string OnBudget: boolean - Balance: Number + Balance: number } export interface Category { @@ -39,29 +52,30 @@ export const useAccountStore = defineStore("budget/account", { }), getters: { AccountsList(state) { - return [ ...state.Accounts.values() ]; + return [...state.Accounts.values()]; }, - CategoriesForMonth: (state) => (year : number, month : number) => { - console.log("MTH", state.Months) + CategoriesForMonth: (state) => (year: number, month: number) => { const yearMap = state.Months.get(year); - return [ ...yearMap?.get(month)?.values() || [] ]; + const monthMap = yearMap?.get(month); + console.log("MTH", monthMap) + return [...monthMap?.values() || []]; }, - CurrentAccount(state) : Account | undefined { + CurrentAccount(state): Account | undefined { if (state.CurrentAccountID == null) return undefined; return state.Accounts.get(state.CurrentAccountID); }, OnBudgetAccounts(state) { - return [ ...state.Accounts.values() ].filter(x => x.OnBudget); + return [...state.Accounts.values()].filter(x => x.OnBudget); }, - OnBudgetAccountsBalance(state) : Number { + OnBudgetAccountsBalance(state) : number { return this.OnBudgetAccounts.reduce((prev, curr) => prev + Number(curr.Balance), 0); }, OffBudgetAccounts(state) { - return [ ...state.Accounts.values() ].filter(x => !x.OnBudget); + return [...state.Accounts.values()].filter(x => !x.OnBudget); }, - OffBudgetAccountsBalance(state) : Number { + OffBudgetAccountsBalance(state) : number { return this.OffBudgetAccounts.reduce((prev, curr) => prev + Number(curr.Balance), 0); }, TransactionsList(state) { @@ -69,7 +83,7 @@ export const useAccountStore = defineStore("budget/account", { } }, actions: { - async SetCurrentAccount(budgetid : string, accountid : string) { + async SetCurrentAccount(budgetid: string, accountid: string) { if (budgetid == null) return @@ -80,30 +94,31 @@ export const useAccountStore = defineStore("budget/account", { useSessionStore().setTitle(this.CurrentAccount.Name); await this.FetchAccount(accountid); }, - async FetchAccount(accountid : string) { + async FetchAccount(accountid: string) { const result = await GET("/account/" + accountid + "/transactions"); const response = await result.json(); this.Transactions = response.Transactions; }, - async FetchMonthBudget(budgetid : string, year : number, month : number) { + async FetchMonthBudget(budgetid: string, year: number, month: number) { const result = await GET("/budget/" + budgetid + "/" + year + "/" + month); const response = await result.json(); this.addCategoriesForMonth(year, month, response.Categories); }, - addCategoriesForMonth(year : number, month : number, categories : Category[]) : void { - const yearMap = this.Months.get(year) || new Map>(); - this.Months.set(year, yearMap); + addCategoriesForMonth(year: number, month: number, categories: Category[]): void { + this.$patch((state) => { + const yearMap = state.Months.get(year) || new Map>(); + const monthMap = yearMap.get(month) || new Map(); + for (const category of categories) { + monthMap.set(category.ID, category); + } - const monthMap = yearMap.get(month) || new Map(); - yearMap.set(month, monthMap); - - for (const category of categories){ - monthMap.set(category.ID, category); - } + yearMap.set(month, monthMap); + state.Months.set(year, yearMap); + }); }, logout() { this.$reset() }, } -}) \ No newline at end of file +})