Calculate available balance locally
This commit is contained in:
parent
0038db90ac
commit
67c013799d
@ -4,6 +4,7 @@ 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";
|
||||||
import { useSessionStore } from "../stores/session";
|
import { useSessionStore } from "../stores/session";
|
||||||
|
import Input from "../components/Input.vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
budgetid: string,
|
budgetid: string,
|
||||||
@ -92,9 +93,9 @@ function getGroupState(group: { Name: string, Expand: boolean }): boolean {
|
|||||||
<template v-for="category in GetCategories(group.Name)" v-if="getGroupState(group)">
|
<template v-for="category in GetCategories(group.Name)" v-if="getGroupState(group)">
|
||||||
<span class="whitespace-nowrap overflow-hidden">{{ category.Name }}</span>
|
<span class="whitespace-nowrap overflow-hidden">{{ category.Name }}</span>
|
||||||
<Currency :value="category.AvailableLastMonth" class="hidden lg:block" />
|
<Currency :value="category.AvailableLastMonth" class="hidden lg:block" />
|
||||||
<Currency :value="category.Assigned" class="hidden sm:block" />
|
<Input type="number" v-model="category.Assigned" class="hidden sm:block mx-2 text-right" />
|
||||||
<Currency :value="category.Activity" class="hidden sm:block" />
|
<Currency :value="category.Activity" class="hidden sm:block" />
|
||||||
<Currency :value="category.Available" />
|
<Currency :value="accountStore.GetCategoryAvailable(category)" />
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
@ -31,7 +31,6 @@ export interface Category {
|
|||||||
AvailableLastMonth: number
|
AvailableLastMonth: number
|
||||||
Assigned: number
|
Assigned: number
|
||||||
Activity: number
|
Activity: number
|
||||||
Available: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useAccountStore = defineStore("budget/account", {
|
export const useAccountStore = defineStore("budget/account", {
|
||||||
@ -51,6 +50,11 @@ export const useAccountStore = defineStore("budget/account", {
|
|||||||
const monthMap = yearMap?.get(month);
|
const monthMap = yearMap?.get(month);
|
||||||
return [...monthMap?.values() || []];
|
return [...monthMap?.values() || []];
|
||||||
},
|
},
|
||||||
|
GetCategoryAvailable(state) {
|
||||||
|
return (category : Category) : number => {
|
||||||
|
return category.AvailableLastMonth + Number(category.Assigned) + category.Activity;
|
||||||
|
}
|
||||||
|
},
|
||||||
CategoryGroupsForMonth(state) {
|
CategoryGroupsForMonth(state) {
|
||||||
return (year: number, month: number) => {
|
return (year: number, month: number) => {
|
||||||
const categories = this.AllCategoriesForMonth(year, month);
|
const categories = this.AllCategoriesForMonth(year, month);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user