diff --git a/web/src/components/BudgetingCategory.vue b/web/src/components/BudgetingCategory.vue index fab9b84..8bd1233 100644 --- a/web/src/components/BudgetingCategory.vue +++ b/web/src/components/BudgetingCategory.vue @@ -1,24 +1,20 @@ diff --git a/web/src/components/BudgetingCategoryGroup.vue b/web/src/components/BudgetingCategoryGroup.vue index 2995897..1898d8b 100644 --- a/web/src/components/BudgetingCategoryGroup.vue +++ b/web/src/components/BudgetingCategoryGroup.vue @@ -9,16 +9,16 @@ import CreateCategory from '../dialogs/CreateCategory.vue'; const props = defineProps<{group: CategoryGroup, year: number, month: number}>(); const categoryStore = useCategoryStore(); -const categoriesForGroup = categoryStore.GetCategoriesForGroup(props.group); +const categoriesForGroup = computed(() => categoryStore.GetCategoriesForGroup(props.group)); const expanded = ref(true) function toggleGroup() { expanded.value = !expanded.value; } -const availableLastMonth = computed(() => categoriesForGroup.reduce((prev, current) => prev + current.AvailableLastMonth, 0)) -const assigned = computed(() => categoriesForGroup.reduce((prev, current) => prev + current.Assigned, 0)) -const activity = computed(() => categoriesForGroup.reduce((prev, current) => prev + current.Activity, 0)) +const availableLastMonth = computed(() => categoriesForGroup.value.reduce((prev, current) => prev + current.AvailableLastMonth, 0)) +const assigned = computed(() => categoriesForGroup.value.reduce((prev, current) => prev + current.Assigned, 0)) +const activity = computed(() => categoriesForGroup.value.reduce((prev, current) => prev + current.Activity, 0)) const available = computed(() => activity.value+assigned.value+availableLastMonth.value); diff --git a/web/src/stores/budget.ts b/web/src/stores/budget.ts index a1b9019..1f84a75 100644 --- a/web/src/stores/budget.ts +++ b/web/src/stores/budget.ts @@ -41,9 +41,13 @@ export const useBudgetsStore = defineStore("budget", { sessionStore.Budgets.set(response.ID, response); }, async SetCurrentBudget(budgetid: string): Promise { + if(this.CurrentBudgetID == budgetid) + return; + this.CurrentBudgetID = budgetid; - if (budgetid == null) return; + if (budgetid == null) + return; await this.FetchBudget(budgetid); }, diff --git a/web/src/stores/category.ts b/web/src/stores/category.ts index 2cbe74b..4d0dbc8 100644 --- a/web/src/stores/category.ts +++ b/web/src/stores/category.ts @@ -49,5 +49,11 @@ export const useCategoryStore = defineStore("category", { this.Categories.set(category.ID, category); } }, + async SetAssigned(category : Category, year : number, month : number, assigned : number){ + this.Categories.get(category.ID)!.Assigned = assigned; + const currentBudgetID = useBudgetsStore().CurrentBudgetID; + await POST("/budget/"+currentBudgetID+"/category/" + category.ID + "/" + year + "/" + (month+1), + JSON.stringify({Assigned: assigned})); + } }, }); \ No newline at end of file diff --git a/web/src/stores/transactions.ts b/web/src/stores/transactions.ts index ab4ddf9..733777a 100644 --- a/web/src/stores/transactions.ts +++ b/web/src/stores/transactions.ts @@ -130,18 +130,15 @@ export const useTransactionsStore = defineStore("budget/transactions", { const recTrans = response.ReconciliationTransaction; if (recTrans) { this.AddTransactions([recTrans]); - account.Transactions.unshift(recTrans.ID); } }, logout() { this.$reset(); }, async saveTransaction(payload: string) { - const accountsStore = useAccountStore(); const result = await POST("/transaction/new", payload); const response = (await result.json()) as Transaction; this.AddTransactions([response]); - accountsStore.CurrentAccount?.Transactions.unshift(response.ID); }, async editTransaction(transactionid: string, payload: string) { const result = await POST("/transaction/" + transactionid, payload);