This commit is contained in:
2022-02-10 16:07:29 +00:00
parent c693625e34
commit 21dcd7837b
8 changed files with 46 additions and 38 deletions

View File

@ -1,5 +1,4 @@
import { defineStore } from "pinia"
import { FETCH_ACCOUNT } from "../store/action-types";
import { useAPI } from "./api";
import { useSessionStore } from "./session";
@ -42,7 +41,8 @@ export const useAccountStore = defineStore("budget/account", {
AccountsList(state) {
return state.Accounts.values();
},
Categories: (state) => (year : number, month : number) => {
CategoriesForMonth: (state) => (year : number, month : number) => {
console.log("MTH", state.Months)
const yearMap = state.Months.get(year);
return yearMap?.get(month)?.values();
},
@ -64,7 +64,7 @@ export const useAccountStore = defineStore("budget/account", {
OffBudgetAccountsBalance(state) : Number {
return this.OffBudgetAccounts.reduce((prev, curr) => prev + Number(curr.Balance), 0);
},
Transactions(state) {
TransactionsList(state) {
return (state.Transactions || []);
}
},
@ -82,11 +82,11 @@ export const useAccountStore = defineStore("budget/account", {
},
async FetchAccount(accountid : string) {
const api = useAPI();
const result = await api.GET("/api/v1/account/" + accountid + "/transactions");
const result = await api.GET("/account/" + accountid + "/transactions");
const response = await result.json();
this.Transactions = response.Transactions;
},
async FetchMonthBudget(budgetid : string, month : number, year : number) {
async FetchMonthBudget(budgetid : string, year : number, month : number) {
const api = useAPI();
const result = await api.GET("/budget/" + budgetid + "/" + year + "/" + month);
const response = await result.json();