Improve frontend

This commit is contained in:
2022-02-27 20:02:57 +00:00
parent b4321395d9
commit 52503a4c92
2 changed files with 62 additions and 17 deletions

View File

@ -74,7 +74,7 @@ export const useAccountStore = defineStore("budget/account", {
const categoryGroups = [];
let prev = undefined;
for (const category of categories) {
if(category.Group != prev)
if (category.Group != prev)
categoryGroups.push({
Name: category.Group,
Expand: category.Group != "Hidden Categories",
@ -85,7 +85,7 @@ export const useAccountStore = defineStore("budget/account", {
}
},
CategoriesForMonthAndGroup(state) {
return (year: number, month: number, group : string) => {
return (year: number, month: number, group: string) => {
const categories = this.AllCategoriesForMonth(year, month);
return categories.filter(x => x.Group == group);
}
@ -99,7 +99,7 @@ export const useAccountStore = defineStore("budget/account", {
ReconcilingBalance(state): number {
let reconciledBalance = this.CurrentAccount!.ReconciledBalance;
for (const transaction of this.TransactionsList) {
if(transaction.Reconciled)
if (transaction.Reconciled)
reconciledBalance += transaction.Amount;
}
return reconciledBalance;
@ -116,11 +116,11 @@ export const useAccountStore = defineStore("budget/account", {
OffBudgetAccountsBalance(state): number {
return this.OffBudgetAccounts.reduce((prev, curr) => prev + Number(curr.ClearedBalance), 0);
},
TransactionsList(state) : Transaction[] {
TransactionsList(state): Transaction[] {
return this.CurrentAccount!.Transactions.map(x => {
return this.Transactions.get(x)!
});
}
},
},
actions: {
async SetCurrentAccount(budgetid: string, accountid: string) {
@ -148,12 +148,12 @@ export const useAccountStore = defineStore("budget/account", {
async FetchMonthBudget(budgetid: string, year: number, month: number) {
const result = await GET("/budget/" + budgetid + "/" + year + "/" + month);
const response = await result.json();
if(response.Categories == undefined || response.Categories.length <= 0)
if (response.Categories == undefined || response.Categories.length <= 0)
return;
this.addCategoriesForMonth(year, month, response.Categories);
},
async EditAccount(accountid : string, name : string, onBudget : boolean) {
const result = await POST("/account/" + accountid, JSON.stringify({name: name, onBudget: onBudget}));
async EditAccount(accountid: string, name: string, onBudget: boolean) {
const result = await POST("/account/" + accountid, JSON.stringify({ name: name, onBudget: onBudget }));
const response = await result.json();
useBudgetsStore().MergeBudgetingData(response);
},
@ -169,6 +169,15 @@ export const useAccountStore = defineStore("budget/account", {
state.Months.set(year, yearMap);
});
},
SetReconciledForAllTransactions(value: boolean) {
for (const transaction of this.TransactionsList) {
if (transaction.Status == "Reconciled")
continue;
transaction.Reconciled = value;
}
},
logout() {
this.$reset()
},
@ -177,7 +186,7 @@ export const useAccountStore = defineStore("budget/account", {
const response = await result.json();
this.CurrentAccount?.Transactions.unshift(response);
},
async editTransaction(transactionid : string, payload: string) {
async editTransaction(transactionid: string, payload: string) {
const result = await POST("/transaction/" + transactionid, payload);
const response = await result.json();
this.CurrentAccount?.Transactions.unshift(response);