Add page for all accounts
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { POST } from "../api";
|
||||
import { GET, POST } from "../api";
|
||||
import { formatDate, groupBy } from "../date";
|
||||
import { useBudgetsStore } from "./budget";
|
||||
import { useAccountStore } from "./budget-account";
|
||||
|
||||
interface State {
|
||||
Transactions: Map<string, Transaction>;
|
||||
Reconciling: boolean;
|
||||
ProblematicTransactions: Array<string>;
|
||||
}
|
||||
|
||||
export interface Transaction {
|
||||
@ -29,6 +31,7 @@ export const useTransactionsStore = defineStore("budget/transactions", {
|
||||
state: (): State => ({
|
||||
Transactions: new Map<string, Transaction>(),
|
||||
Reconciling: false,
|
||||
ProblematicTransactions: new Array<string>(),
|
||||
}),
|
||||
getters: {
|
||||
ReconcilingBalance(state): number {
|
||||
@ -43,9 +46,8 @@ export const useTransactionsStore = defineStore("budget/transactions", {
|
||||
},
|
||||
TransactionsByDate(state) : Record<string, Transaction[]> {
|
||||
const accountsStore = useAccountStore();
|
||||
const accountID = accountsStore.CurrentAccountID;
|
||||
const allTransactions = [...this.Transactions.values()];
|
||||
return groupBy(allTransactions.filter(x => x.AccountID == accountID), x => formatDate(x.Date));
|
||||
return groupBy(allTransactions, x => formatDate(x.Date));
|
||||
},
|
||||
TransactionsList(state) : Transaction[] {
|
||||
const accountsStore = useAccountStore();
|
||||
@ -53,6 +55,9 @@ export const useTransactionsStore = defineStore("budget/transactions", {
|
||||
const allTransactions = [...this.Transactions.values()];
|
||||
return allTransactions.filter(x => x.AccountID == accountID);
|
||||
},
|
||||
ProblematicTransactionsList(state) : Transaction[] {
|
||||
return [...state.ProblematicTransactions.map(x => state.Transactions!.get(x)!)];
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
AddTransactions(transactions: Array<Transaction>) {
|
||||
@ -70,6 +75,13 @@ export const useTransactionsStore = defineStore("budget/transactions", {
|
||||
transaction.Reconciled = value;
|
||||
}
|
||||
},
|
||||
async GetProblematicTransactions() {
|
||||
const budgetStore = useBudgetsStore();
|
||||
const result = await GET("/budget/" + budgetStore.CurrentBudgetID + "/problematic-transactions");
|
||||
const response = await result.json();
|
||||
this.AddTransactions(response.Transactions);
|
||||
this.ProblematicTransactions = [...response.Transactions.map((x : Transaction) => x.ID)];
|
||||
},
|
||||
async SubmitReconcilation(reconciliationTransactionAmount: number) {
|
||||
const accountsStore = useAccountStore();
|
||||
const account = accountsStore.CurrentAccount!;
|
||||
|
Reference in New Issue
Block a user