Implement UI
This commit is contained in:
@ -8,6 +8,7 @@ interface State {
|
||||
Transactions: Map<string, Transaction>;
|
||||
Reconciling: boolean;
|
||||
ProblematicTransactions: Array<string>;
|
||||
FilteredTransactions: Array<string>;
|
||||
}
|
||||
|
||||
export interface Transaction {
|
||||
@ -33,6 +34,7 @@ export const useTransactionsStore = defineStore("budget/transactions", {
|
||||
Transactions: new Map<string, Transaction>(),
|
||||
Reconciling: false,
|
||||
ProblematicTransactions: new Array<string>(),
|
||||
FilteredTransactions: new Array<string>(),
|
||||
}),
|
||||
getters: {
|
||||
ReconcilingBalance(state): number {
|
||||
@ -47,7 +49,8 @@ export const useTransactionsStore = defineStore("budget/transactions", {
|
||||
},
|
||||
TransactionsByDate(state) : Record<string, Transaction[]> {
|
||||
const accountsStore = useAccountStore();
|
||||
const allTransactions = [...this.Transactions.values()];
|
||||
const accountID = accountsStore.CurrentAccountID;
|
||||
const allTransactions = [...this.Transactions.values()].filter(x => x.AccountID == accountID);
|
||||
return groupBy(allTransactions, x => formatDate(x.Date));
|
||||
},
|
||||
TransactionsList(state) : Transaction[] {
|
||||
@ -58,6 +61,9 @@ export const useTransactionsStore = defineStore("budget/transactions", {
|
||||
},
|
||||
ProblematicTransactionsList(state) : Transaction[] {
|
||||
return [...state.ProblematicTransactions.map(x => state.Transactions!.get(x)!)];
|
||||
},
|
||||
FilteredTransactionsList(state) : Transaction[] {
|
||||
return [...state.FilteredTransactions.map(x => state.Transactions!.get(x)!)];
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@ -83,6 +89,18 @@ export const useTransactionsStore = defineStore("budget/transactions", {
|
||||
this.AddTransactions(response.Transactions);
|
||||
this.ProblematicTransactions = [...response.Transactions.map((x : Transaction) => x.ID)];
|
||||
},
|
||||
async GetFilteredTransactions(accountID : string | null, categoryID : string | null, payeeID : string | null) {
|
||||
const budgetStore = useBudgetsStore();
|
||||
const payload = JSON.stringify({
|
||||
category_id: categoryID,
|
||||
payee_id: payeeID,
|
||||
account_id: accountID,
|
||||
});
|
||||
const result = await POST("/budget/" + budgetStore.CurrentBudgetID + "/filtered-transactions", payload);
|
||||
const response = await result.json();
|
||||
this.AddTransactions(response.Transactions);
|
||||
this.FilteredTransactions = [...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