diff --git a/web/src/stores/budget-account.ts b/web/src/stores/budget-account.ts index 9d15c2e..ac5e38d 100644 --- a/web/src/stores/budget-account.ts +++ b/web/src/stores/budget-account.ts @@ -2,7 +2,7 @@ import { defineStore } from "pinia"; import { GET, POST } from "../api"; import { useBudgetsStore } from "./budget"; import { useSessionStore } from "./session"; -import { useTransactionsStore } from "./transactions"; +import { Transaction, useTransactionsStore } from "./transactions"; interface State { Accounts: Map; @@ -200,6 +200,7 @@ export const useAccountStore = defineStore("budget/account", { transactionsStore.AddTransactions( response.Transactions ); + account.Transactions = response.Transactions.map((x : Transaction) =>x.ID); }, async FetchMonthBudget(budgetid: string, year: number, month: number) { const result = await GET( diff --git a/web/src/stores/transactions.ts b/web/src/stores/transactions.ts index f2ceb7e..ff0fc7d 100644 --- a/web/src/stores/transactions.ts +++ b/web/src/stores/transactions.ts @@ -47,10 +47,12 @@ export const useTransactionsStore = defineStore("budget/transactions", { } return reconciledBalance; }, - TransactionsByDate(state) : Record { + TransactionsByDate(state) : Record|undefined{ const accountsStore = useAccountStore(); - const accountID = accountsStore.CurrentAccountID; - const allTransactions = [...this.Transactions.values()].filter(x => x.AccountID == accountID); + const account = accountsStore.CurrentAccount; + if(account === undefined) + return undefined; + const allTransactions = account!.Transactions.map(x => this.Transactions.get(x) ?? {} as Transaction); return groupBy(allTransactions, x => formatDate(x.Date)); }, TransactionsList(state) : Transaction[] {