Reformat
This commit is contained in:
parent
e7a085273b
commit
fe018e1953
@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, defineProps, onMounted, PropType, watch, watchEffect } from "vue";
|
import { computed, defineProps, watchEffect } from "vue";
|
||||||
import Currency from "../components/Currency.vue";
|
import Currency from "../components/Currency.vue";
|
||||||
import { useBudgetsStore } from "../stores/budget";
|
import { useBudgetsStore } from "../stores/budget";
|
||||||
import { useAccountStore } from "../stores/budget-account";
|
import { useAccountStore } from "../stores/budget-account";
|
||||||
@ -22,6 +22,7 @@ const categoriesForMonth = useAccountStore().CategoriesForMonth;
|
|||||||
const Categories = computed(() => {
|
const Categories = computed(() => {
|
||||||
return [...categoriesForMonth(selected.value.Year, selected.value.Month)];
|
return [...categoriesForMonth(selected.value.Year, selected.value.Month)];
|
||||||
});
|
});
|
||||||
|
|
||||||
const previous = computed(() => ({
|
const previous = computed(() => ({
|
||||||
Year: new Date(selected.value.Year, selected.value.Month - 1, 1).getFullYear(),
|
Year: new Date(selected.value.Year, selected.value.Month - 1, 1).getFullYear(),
|
||||||
Month: new Date(selected.value.Year, selected.value.Month - 1, 1).getMonth(),
|
Month: new Date(selected.value.Year, selected.value.Month - 1, 1).getMonth(),
|
||||||
|
@ -52,27 +52,28 @@ export const useAccountStore = defineStore("budget/account", {
|
|||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
AccountsList(state) {
|
AccountsList(state) {
|
||||||
return [ ...state.Accounts.values() ];
|
return [...state.Accounts.values()];
|
||||||
},
|
},
|
||||||
CategoriesForMonth: (state) => (year : number, month : number) => {
|
CategoriesForMonth: (state) => (year: number, month: number) => {
|
||||||
console.log("MTH", state.Months)
|
|
||||||
const yearMap = state.Months.get(year);
|
const yearMap = state.Months.get(year);
|
||||||
return [ ...yearMap?.get(month)?.values() || [] ];
|
const monthMap = yearMap?.get(month);
|
||||||
|
console.log("MTH", monthMap)
|
||||||
|
return [...monthMap?.values() || []];
|
||||||
},
|
},
|
||||||
CurrentAccount(state) : Account | undefined {
|
CurrentAccount(state): Account | undefined {
|
||||||
if (state.CurrentAccountID == null)
|
if (state.CurrentAccountID == null)
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
||||||
return state.Accounts.get(state.CurrentAccountID);
|
return state.Accounts.get(state.CurrentAccountID);
|
||||||
},
|
},
|
||||||
OnBudgetAccounts(state) {
|
OnBudgetAccounts(state) {
|
||||||
return [ ...state.Accounts.values() ].filter(x => x.OnBudget);
|
return [...state.Accounts.values()].filter(x => x.OnBudget);
|
||||||
},
|
},
|
||||||
OnBudgetAccountsBalance(state) : number {
|
OnBudgetAccountsBalance(state) : number {
|
||||||
return this.OnBudgetAccounts.reduce((prev, curr) => prev + Number(curr.Balance), 0);
|
return this.OnBudgetAccounts.reduce((prev, curr) => prev + Number(curr.Balance), 0);
|
||||||
},
|
},
|
||||||
OffBudgetAccounts(state) {
|
OffBudgetAccounts(state) {
|
||||||
return [ ...state.Accounts.values() ].filter(x => !x.OnBudget);
|
return [...state.Accounts.values()].filter(x => !x.OnBudget);
|
||||||
},
|
},
|
||||||
OffBudgetAccountsBalance(state) : number {
|
OffBudgetAccountsBalance(state) : number {
|
||||||
return this.OffBudgetAccounts.reduce((prev, curr) => prev + Number(curr.Balance), 0);
|
return this.OffBudgetAccounts.reduce((prev, curr) => prev + Number(curr.Balance), 0);
|
||||||
@ -82,7 +83,7 @@ export const useAccountStore = defineStore("budget/account", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async SetCurrentAccount(budgetid : string, accountid : string) {
|
async SetCurrentAccount(budgetid: string, accountid: string) {
|
||||||
if (budgetid == null)
|
if (budgetid == null)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -93,12 +94,12 @@ export const useAccountStore = defineStore("budget/account", {
|
|||||||
useSessionStore().setTitle(this.CurrentAccount.Name);
|
useSessionStore().setTitle(this.CurrentAccount.Name);
|
||||||
await this.FetchAccount(accountid);
|
await this.FetchAccount(accountid);
|
||||||
},
|
},
|
||||||
async FetchAccount(accountid : string) {
|
async FetchAccount(accountid: string) {
|
||||||
const result = await GET("/account/" + accountid + "/transactions");
|
const result = await GET("/account/" + accountid + "/transactions");
|
||||||
const response = await result.json();
|
const response = await result.json();
|
||||||
this.Transactions = response.Transactions;
|
this.Transactions = response.Transactions;
|
||||||
},
|
},
|
||||||
async FetchMonthBudget(budgetid : string, year : number, month : number) {
|
async FetchMonthBudget(budgetid: string, year: number, month: number) {
|
||||||
const result = await GET("/budget/" + budgetid + "/" + year + "/" + month);
|
const result = await GET("/budget/" + budgetid + "/" + year + "/" + month);
|
||||||
const response = await result.json();
|
const response = await result.json();
|
||||||
this.addCategoriesForMonth(year, month, response.Categories);
|
this.addCategoriesForMonth(year, month, response.Categories);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user