Use accounts transactions instead of global
This commit is contained in:
parent
8817e665e9
commit
9248c12aab
@ -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<string, Account>;
|
||||
@ -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(
|
||||
|
@ -47,10 +47,12 @@ export const useTransactionsStore = defineStore("budget/transactions", {
|
||||
}
|
||||
return reconciledBalance;
|
||||
},
|
||||
TransactionsByDate(state) : Record<string, Transaction[]> {
|
||||
TransactionsByDate(state) : Record<string, Transaction[]>|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[] {
|
||||
|
Loading…
x
Reference in New Issue
Block a user