Bugfixes
This commit is contained in:
parent
c693625e34
commit
21dcd7837b
@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { mapState } from "pinia";
|
||||
import { defineComponent } from "vue";
|
||||
import { LOGOUT } from "./store/mutation-types";
|
||||
import { useBudgetsStore } from "./stores/budget";
|
||||
import { useAccountStore } from "./stores/budget-account";
|
||||
import { useSessionStore } from "./stores/session";
|
||||
@ -38,7 +37,6 @@ export default defineComponent({
|
||||
sessionStore.User = restoredState.Session.User;
|
||||
sessionStore.Token = restoredState.Session.Token;
|
||||
for (const budget of restoredState.Budgets || []) {
|
||||
console.log("UIAE", sessionStore.Budgets, budget)
|
||||
sessionStore.Budgets.set(budget[0], budget[1]);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent, PropType } from "vue"
|
||||
import { useAPI } from "../stores/api";
|
||||
import { useBudgetsStore } from "../stores/budget";
|
||||
|
||||
export interface Suggestion {
|
||||
ID : string
|
||||
@ -40,16 +42,17 @@ export default defineComponent({
|
||||
return;
|
||||
}
|
||||
|
||||
fetch("/api/v1/budget/" + this.$store.getters.CurrentBudget.ID + "/autocomplete/" + this.type + "?s=" + text, {
|
||||
headers: this.$store.getters.AuthHeaders
|
||||
}) .then(x=>x.json())
|
||||
.then(x => {
|
||||
let suggestions = x || [];
|
||||
if(suggestions.length > 10){
|
||||
suggestions = suggestions.slice(0, 10);
|
||||
}
|
||||
this.$data.Suggestions = suggestions;
|
||||
});
|
||||
const api = useAPI();
|
||||
const budgetStore = useBudgetsStore();
|
||||
api.GET("/budget/" + budgetStore.CurrentBudgetID + "/autocomplete/" + this.type + "?s=" + text)
|
||||
.then(x=>x.json())
|
||||
.then(x => {
|
||||
let suggestions = x || [];
|
||||
if(suggestions.length > 10){
|
||||
suggestions = suggestions.slice(0, 10);
|
||||
}
|
||||
this.$data.Suggestions = suggestions;
|
||||
});
|
||||
},
|
||||
keypress(e : KeyboardEvent) {
|
||||
console.log(e.key);
|
||||
|
@ -1,10 +1,15 @@
|
||||
<script lang="ts">
|
||||
import { mapState } from "pinia";
|
||||
import { defineComponent } from "vue";
|
||||
import { useBudgetsStore } from "../stores/budget";
|
||||
import Currency from "./Currency.vue";
|
||||
|
||||
export default defineComponent({
|
||||
props: [ "transaction", "index" ],
|
||||
components: { Currency }
|
||||
components: { Currency },
|
||||
computed: {
|
||||
...mapState(useBudgetsStore, ["CurrentBudgetID"])
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -18,7 +23,7 @@ export default defineComponent({
|
||||
{{ transaction.CategoryGroup ? transaction.CategoryGroup + " : " + transaction.Category : "" }}
|
||||
</td>
|
||||
<td>
|
||||
<a :href="'/budget/' + $store.getters.CurrentBudgetID + '/transaction/' + transaction.ID">
|
||||
<a :href="'/budget/' + CurrentBudgetID + '/transaction/' + transaction.ID">
|
||||
{{ transaction.Memo }}
|
||||
</a>
|
||||
</td>
|
||||
|
@ -4,6 +4,7 @@ import { defineComponent } from "vue"
|
||||
import Autocomplete, { Suggestion } from '../components/Autocomplete.vue'
|
||||
import Currency from "../components/Currency.vue";
|
||||
import TransactionRow from "../components/TransactionRow.vue";
|
||||
import { useAPI } from "../stores/api";
|
||||
import { useAccountStore } from "../stores/budget-account";
|
||||
import { useSessionStore } from "../stores/session";
|
||||
|
||||
@ -25,9 +26,8 @@ export default defineComponent({
|
||||
methods: {
|
||||
saveTransaction(e : MouseEvent) {
|
||||
e.preventDefault();
|
||||
fetch("/api/v1/transaction/new", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
const api = useAPI();
|
||||
api.POST("/transaction/new", JSON.stringify({
|
||||
budget_id: this.budgetid,
|
||||
account_id: this.accountid,
|
||||
date: this.$data.TransactionDate,
|
||||
@ -36,9 +36,7 @@ export default defineComponent({
|
||||
memo: this.$data.Memo,
|
||||
amount: this.$data.Amount,
|
||||
state: "Uncleared"
|
||||
}),
|
||||
headers: useSessionStore().AuthHeaders,
|
||||
})
|
||||
}))
|
||||
.then(x => x.json());
|
||||
},
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ interface Date {
|
||||
|
||||
export default defineComponent({
|
||||
mounted() {
|
||||
document.title = "Budgeteer - Budget for " + this.month + " " + this.year;
|
||||
document.title = "Budgeteer - Budget for " + this.selected.Month + "/" + this.selected.Year;
|
||||
return useAccountStore().FetchMonthBudget(this.budgetid, this.year, this.month);
|
||||
},
|
||||
watch: {
|
||||
@ -27,7 +27,9 @@ export default defineComponent({
|
||||
computed: {
|
||||
...mapState(useBudgetsStore, ["CurrentBudgetID"]),
|
||||
Categories() : IterableIterator<Category> | undefined {
|
||||
return useAccountStore().Categories(this.year, this.month);
|
||||
const accountStore = useAccountStore();
|
||||
console.log(accountStore.CategoriesForMonth(this.year, this.month));
|
||||
return accountStore.CategoriesForMonth(this.year, this.month);
|
||||
},
|
||||
previous(): Date {
|
||||
return {
|
||||
|
@ -36,7 +36,7 @@ export default defineComponent({
|
||||
return;
|
||||
|
||||
const api = useAPI();
|
||||
api.DELETE("/api/v1/budget/" + currentBudgetID);
|
||||
api.DELETE("/budget/" + currentBudgetID);
|
||||
|
||||
const budgetStore = useSessionStore();
|
||||
budgetStore.Budgets.delete(currentBudgetID);
|
||||
@ -45,7 +45,7 @@ export default defineComponent({
|
||||
clearBudget() {
|
||||
const currentBudgetID = useBudgetsStore().CurrentBudgetID;
|
||||
const api = useAPI();
|
||||
api.POST("/api/v1/budget/" + currentBudgetID + "/settings/clear", null)
|
||||
api.POST("/budget/" + currentBudgetID + "/settings/clear", null)
|
||||
},
|
||||
cleanNegative() {
|
||||
// <a href="/budget/{{.Budget.ID}}/settings/clean-negative">Fix all historic negative category-balances</a>
|
||||
|
@ -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();
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { useAPI } from './api';
|
||||
|
||||
interface State {
|
||||
Token: string | null
|
||||
@ -33,17 +34,18 @@ export const useSessionStore = defineStore('session', {
|
||||
this.Token = x.Token;
|
||||
this.Budgets = x.Budgets;
|
||||
},
|
||||
login(login: any) {
|
||||
return fetch("/api/v1/user/login", { method: "POST", body: JSON.stringify(login) })
|
||||
.then(x => x.json())
|
||||
.then(x => this.loginSuccess(x));
|
||||
async login(login: any) {
|
||||
const api = useAPI();
|
||||
const response = await api.POST("/user/login", JSON.stringify(login));
|
||||
const result = await response.json();
|
||||
return this.loginSuccess(result);
|
||||
},
|
||||
register(login : any) {
|
||||
return fetch("/api/v1/user/register", { method: "POST", body: JSON.stringify(login) })
|
||||
.then(x => x.json())
|
||||
.then(x => this.loginSuccess(x))
|
||||
async register(login : any) {
|
||||
const api = useAPI();
|
||||
const response = await api.POST("/user/register", JSON.stringify(login));
|
||||
const result = await response.json();
|
||||
return this.loginSuccess(result);
|
||||
},
|
||||
// easily reset state using `$reset`
|
||||
logout() {
|
||||
this.$reset()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user