Add type-information to GetBudgeted
This commit is contained in:
parent
23bd12147c
commit
c4fc80e47d
@ -6,7 +6,6 @@ import Currency from "./Currency.vue";
|
|||||||
import TransactionEditRow from "./TransactionEditRow.vue";
|
import TransactionEditRow from "./TransactionEditRow.vue";
|
||||||
import { formatDate } from "../date";
|
import { formatDate } from "../date";
|
||||||
import { useAccountStore } from "../stores/budget-account";
|
import { useAccountStore } from "../stores/budget-account";
|
||||||
import Input from "./Input.vue";
|
|
||||||
import Checkbox from "./Checkbox.vue";
|
import Checkbox from "./Checkbox.vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
@ -83,17 +83,17 @@ function assignedChanged(e : Event, category : Category){
|
|||||||
</span><br />
|
</span><br />
|
||||||
<span>Budgeted this month:
|
<span>Budgeted this month:
|
||||||
<Currency
|
<Currency
|
||||||
:value="accountStore.GetBudgeted(selected.Year, selected.Month).assigned"
|
:value="accountStore.GetBudgeted(selected.Year, selected.Month).Assigned"
|
||||||
/>
|
/>
|
||||||
</span><br />
|
</span><br />
|
||||||
<span>Deassigned this month:
|
<span>Deassigned this month:
|
||||||
<Currency
|
<Currency
|
||||||
:value="accountStore.GetBudgeted(selected.Year, selected.Month).deassigned"
|
:value="accountStore.GetBudgeted(selected.Year, selected.Month).Deassigned"
|
||||||
/>
|
/>
|
||||||
</span><br />
|
</span><br />
|
||||||
<span>Spent this month:
|
<span>Spent this month:
|
||||||
<Currency
|
<Currency
|
||||||
:value="accountStore.GetBudgeted(selected.Year, selected.Month).activity"
|
:value="accountStore.GetBudgeted(selected.Year, selected.Month).Activity"
|
||||||
/>
|
/>
|
||||||
</span><br />
|
</span><br />
|
||||||
<div>
|
<div>
|
||||||
|
@ -39,6 +39,12 @@ export interface Category {
|
|||||||
Activity: number;
|
Activity: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface BudgetedAmounts {
|
||||||
|
Assigned: number,
|
||||||
|
Deassigned: number,
|
||||||
|
Activity: number,
|
||||||
|
}
|
||||||
|
|
||||||
export const useAccountStore = defineStore("budget/account", {
|
export const useAccountStore = defineStore("budget/account", {
|
||||||
state: (): State => ({
|
state: (): State => ({
|
||||||
Accounts: new Map<string, Account>(),
|
Accounts: new Map<string, Account>(),
|
||||||
@ -71,9 +77,9 @@ export const useAccountStore = defineStore("budget/account", {
|
|||||||
return budget.CurrentBudget?.IncomeCategoryID;
|
return budget.CurrentBudget?.IncomeCategoryID;
|
||||||
},
|
},
|
||||||
GetBudgeted(state) {
|
GetBudgeted(state) {
|
||||||
return (year: number, month: number) => {
|
return (year: number, month: number) : BudgetedAmounts => {
|
||||||
const IncomeCategoryID = this.GetIncomeCategoryID;
|
const IncomeCategoryID = this.GetIncomeCategoryID;
|
||||||
if (IncomeCategoryID == null) return 0;
|
if (IncomeCategoryID == null) return {Activity: 0, Assigned: 0, Deassigned: 0};
|
||||||
|
|
||||||
const categories = this.AllCategoriesForMonth(year, month);
|
const categories = this.AllCategoriesForMonth(year, month);
|
||||||
|
|
||||||
@ -90,9 +96,9 @@ export const useAccountStore = defineStore("budget/account", {
|
|||||||
deassigned += category.Assigned;
|
deassigned += category.Assigned;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
assigned,
|
Assigned: assigned,
|
||||||
deassigned,
|
Deassigned: deassigned,
|
||||||
activity
|
Activity: activity
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user