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 { GET, POST } from "../api";
|
||||||
import { useBudgetsStore } from "./budget";
|
import { useBudgetsStore } from "./budget";
|
||||||
import { useSessionStore } from "./session";
|
import { useSessionStore } from "./session";
|
||||||
import { useTransactionsStore } from "./transactions";
|
import { Transaction, useTransactionsStore } from "./transactions";
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
Accounts: Map<string, Account>;
|
Accounts: Map<string, Account>;
|
||||||
@ -200,6 +200,7 @@ export const useAccountStore = defineStore("budget/account", {
|
|||||||
transactionsStore.AddTransactions(
|
transactionsStore.AddTransactions(
|
||||||
response.Transactions
|
response.Transactions
|
||||||
);
|
);
|
||||||
|
account.Transactions = response.Transactions.map((x : Transaction) =>x.ID);
|
||||||
},
|
},
|
||||||
async FetchMonthBudget(budgetid: string, year: number, month: number) {
|
async FetchMonthBudget(budgetid: string, year: number, month: number) {
|
||||||
const result = await GET(
|
const result = await GET(
|
||||||
|
@ -47,10 +47,12 @@ export const useTransactionsStore = defineStore("budget/transactions", {
|
|||||||
}
|
}
|
||||||
return reconciledBalance;
|
return reconciledBalance;
|
||||||
},
|
},
|
||||||
TransactionsByDate(state) : Record<string, Transaction[]> {
|
TransactionsByDate(state) : Record<string, Transaction[]>|undefined{
|
||||||
const accountsStore = useAccountStore();
|
const accountsStore = useAccountStore();
|
||||||
const accountID = accountsStore.CurrentAccountID;
|
const account = accountsStore.CurrentAccount;
|
||||||
const allTransactions = [...this.Transactions.values()].filter(x => x.AccountID == accountID);
|
if(account === undefined)
|
||||||
|
return undefined;
|
||||||
|
const allTransactions = account!.Transactions.map(x => this.Transactions.get(x) ?? {} as Transaction);
|
||||||
return groupBy(allTransactions, x => formatDate(x.Date));
|
return groupBy(allTransactions, x => formatDate(x.Date));
|
||||||
},
|
},
|
||||||
TransactionsList(state) : Transaction[] {
|
TransactionsList(state) : Transaction[] {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user