30 Commits

Author SHA1 Message Date
45af54d995 Add bass.build
Some checks failed
continuous-integration/drone/push Build is failing
2024-08-21 20:42:14 +00:00
a241298170 Merge pull request 'Use accounts transactions instead of global (Fixes #65)' (#78) from add-new-to-top into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #78
2022-09-10 23:26:13 +02:00
9248c12aab Use accounts transactions instead of global
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-09-10 21:24:02 +00:00
8817e665e9 Merge pull request 'Migrate from gin to echo framework' (#77) from migrate-to-echo into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #77
2022-08-21 22:04:28 +02:00
0b36048f47 use null instead of undefined
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-08-21 20:03:04 +00:00
0c2438373d js lint
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2022-08-21 20:00:13 +00:00
2f636b5f9c Wrap some errors
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2022-08-21 19:56:55 +00:00
4ef0b759ef Fix linter errors
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2022-08-21 19:51:56 +00:00
08fbacc7e6 Set Content-Type in test and handle error earlier
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2022-08-21 19:41:04 +00:00
1c003486ca Fix linter issues
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2022-08-21 19:35:51 +00:00
71be1ac49f Send Content-Type on POST 2022-08-21 19:33:12 +00:00
d258ab63e4 Finish migration 2022-08-21 19:33:12 +00:00
9da4a6f03e Continue migration to echo 2022-08-21 19:33:12 +00:00
1a11555075 Continue migration to echo 2022-08-21 19:33:12 +00:00
b573553424 Start migration to echo 2022-08-21 19:33:12 +00:00
dd0f620b7a Merge pull request 'Add abilty to filter transactions by account, payee and category' (#55) from filtered-transactions into master
Some checks failed
continuous-integration/drone/push Build is failing
Reviewed-on: #55
2022-08-21 21:32:49 +02:00
42b732eedc Fix filters 2022-08-21 21:32:49 +02:00
f437491823 Implement filtering on frontend 2022-08-21 21:32:49 +02:00
dc15ae307b Remove old logging 2022-08-21 21:32:49 +02:00
f8a8a6fc0c Add date filtering to backend 2022-08-21 21:32:49 +02:00
a031dd5bb1 Add date filters to UI 2022-08-21 21:32:49 +02:00
d3ca3c87bf Make menu entry generic 2022-08-21 21:32:49 +02:00
77c1a6dd18 Make UI work for problematic and filtered transactions 2022-08-21 21:32:49 +02:00
a7e1826f52 Implement UI 2022-08-21 21:32:49 +02:00
94b5c4bbd3 Improve Backend 2022-08-21 21:32:49 +02:00
fdb64b2000 Add filters to UI 2022-08-21 21:32:49 +02:00
2ca3328f0f Implement backend 2022-08-21 21:32:49 +02:00
bd026732c8 Add 'Contributing' to README
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2022-07-26 00:02:22 +02:00
6032f6f526 „README.md“ ändern
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2022-07-25 23:42:34 +02:00
e1c6bd22d5 Merge pull request 'Improve available balance and show overspent last month' (#54) from available-balance into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #54
2022-04-24 21:23:17 +02:00
13 changed files with 87 additions and 50 deletions

View File

@ -14,6 +14,7 @@ linters:
- gci # not working, shows errors on freshly formatted file - gci # not working, shows errors on freshly formatted file
- varnamelen - varnamelen
- lll - lll
linters-settings: linters-settings:
errcheck: errcheck:
exclude-functions: exclude-functions:
@ -25,3 +26,18 @@ linters-settings:
varnamelen: varnamelen:
ignore-decls: ignore-decls:
- c *gin.Context - c *gin.Context
wrapcheck:
ignoreSigs:
- .JSON(
- .Redirect(
- .String(
- .Errorf(
- errors.New(
- errors.Unwrap(
- .Wrap(
- .Wrapf(
- .WithMessage(
- .WithMessagef(
- .WithStack(
ignorePackageGlobs:
- git.javil.eu/jacob1123/budgeteer/postgres

View File

@ -1,20 +1,18 @@
# Budgeteer # Budgeteer
Budgeting Web-Application Budgeting Web-Application written in Go and inspired by [YNAB](https://youneedabudget.com).
## Data structure ## Getting started
1 User The fastest way to get up and running quickly, is using docker-compose. Just download the [docker-compose.yml](https://git.javil.eu/jacob1123/budgeteer/src/branch/master/docker/docker-compose.yml) to some empty directory and run `docker-compose up -d`. This starts budgeteer, a postgres database and an adminer instance. The latter is optional and can be removed from the docker-compose.yml.
N Budgets
AccountID[]
CategoryID[]
PayeeID[]
N Accounts ## Known issues
TransactionID[]
N Categories
AssignmentID[]
N Payees
N Transactions Currently the application is usable when importing from YNAB via their CSV export. All balances should match the balances from YNAB. There are even unit-tests that confirm that using my personal budget.
N Assignments
For people wishing to start fresh in Budgeteer, there currently are some blockers though:
- The ability to create new accounts and categories is missing (#59)
## Contributing
If you're willing to help, please check the issues for [help-wanted labels](https://git.javil.eu/jacob1123/budgeteer/issues?labels=4). Just using Budgeteer and reporting any issues is although very helpful.

12
bass.build Normal file
View File

@ -0,0 +1,12 @@
(def go
(from (linux/alpine)
($ apk add go)))
(-> ($ go mod download)
(with-image go)
(with-mount *dir*/go.mod ./go.mod)
(with-mount *dir*/go.sum ./go.sum))
(def go-mods
(from go
($ go mod download)))

View File

@ -10,11 +10,11 @@ import (
) )
type FilterTransactionsRequest struct { type FilterTransactionsRequest struct {
CategoryID string `json:"category_id"` CategoryID string `json:"categoryId"`
PayeeID string `json:"payee_id"` PayeeID string `json:"payeeId"`
AccountID string `json:"account_id"` AccountID string `json:"accountId"`
FromDate time.Time `json:"from_date"` FromDate time.Time `json:"fromDate"`
ToDate time.Time `json:"to_date"` ToDate time.Time `json:"toDate"`
} }
func (h *Handler) filteredTransactions(c echo.Context) error { func (h *Handler) filteredTransactions(c echo.Context) error {
@ -58,7 +58,7 @@ func parseEmptyUUID(value string) (uuid.NullUUID, bool) {
return uuid.NullUUID{}, false return uuid.NullUUID{}, false
} }
return uuid.NullUUID{val, true}, true return uuid.NullUUID{UUID: val, Valid: true}, true
} }
func (h *Handler) problematicTransactions(c echo.Context) error { func (h *Handler) problematicTransactions(c echo.Context) error {

View File

@ -1,6 +1,7 @@
package server package server
import ( import (
"context"
"encoding/json" "encoding/json"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
@ -35,17 +36,23 @@ func TestRegisterUser(t *testing.T) {
t.Run("RegisterUser", func(t *testing.T) { t.Run("RegisterUser", func(t *testing.T) {
t.Parallel() t.Parallel()
request, err := http.NewRequest( request, err := http.NewRequestWithContext(context.Background(),
http.MethodPost, http.MethodPost,
"/api/v1/user/register", "/api/v1/user/register",
strings.NewReader(`{"password":"pass","email":"info@example.com","name":"Test"}`)) strings.NewReader(`{"password":"pass","email":"info@example.com","name":"Test"}`))
request.Header.Set("Content-Type", "application/json")
context := engine.NewContext(request, recorder) context := engine.NewContext(request, recorder)
if err != nil { if err != nil {
t.Errorf("error creating request: %s", err) t.Errorf("error creating request: %s", err)
return return
} }
h.registerPost(context) err = h.registerPost(context)
if err != nil {
t.Error(err.Error())
t.Error("Error registering")
return
}
if recorder.Code != http.StatusOK { if recorder.Code != http.StatusOK {
t.Errorf("handler returned wrong status code: got %v want %v", recorder.Code, http.StatusOK) t.Errorf("handler returned wrong status code: got %v want %v", recorder.Code, http.StatusOK)

View File

@ -41,7 +41,7 @@ func (h *Handler) budgetingForMonth(c echo.Context) error {
month, err := getDate(c) month, err := getDate(c)
if err != nil { if err != nil {
c.Redirect(http.StatusTemporaryRedirect, "/budget/"+budget.ID.String()) return c.Redirect(http.StatusTemporaryRedirect, "/budget/"+budget.ID.String())
} }
data, err := h.getBudgetingViewForMonth(c.Request().Context(), budget, month) data, err := h.getBudgetingViewForMonth(c.Request().Context(), budget, month)

View File

@ -35,7 +35,7 @@ func (h *Handler) verifyLogin(c echo.Context) (budgeteer.Token, error) { //nolin
tokenString = tokenString[7:] tokenString = tokenString[7:]
token, err := h.TokenVerifier.VerifyToken(tokenString) token, err := h.TokenVerifier.VerifyToken(tokenString)
if err != nil { if err != nil {
return nil, fmt.Errorf("verify token '%s': %s", tokenString, err) return nil, fmt.Errorf("verify token '%s': %w", tokenString, err)
} }
return token, nil return token, nil
@ -63,7 +63,7 @@ func (h *Handler) loginPost(c echo.Context) error {
var login loginInformation var login loginInformation
err := c.Bind(&login) err := c.Bind(&login)
if err != nil { if err != nil {
return err return fmt.Errorf("parse payload: %w", err)
} }
user, err := h.Service.GetUserByUsername(c.Request().Context(), login.User) user, err := h.Service.GetUserByUsername(c.Request().Context(), login.User)
@ -72,12 +72,12 @@ func (h *Handler) loginPost(c echo.Context) error {
} }
if err = h.CredentialsVerifier.Verify(login.Password, user.Password); err != nil { if err = h.CredentialsVerifier.Verify(login.Password, user.Password); err != nil {
return err return fmt.Errorf("verify password: %w", err)
} }
token, err := h.TokenVerifier.CreateToken(&user) token, err := h.TokenVerifier.CreateToken(&user)
if err != nil { if err != nil {
return err return fmt.Errorf("create token: %w", err)
} }
go h.UpdateLastLogin(user.ID) go h.UpdateLastLogin(user.ID)
@ -120,7 +120,7 @@ func (h *Handler) registerPost(c echo.Context) error {
hash, err := h.CredentialsVerifier.Hash(register.Password) hash, err := h.CredentialsVerifier.Hash(register.Password)
if err != nil { if err != nil {
return err return fmt.Errorf("hash password: %w", err)
} }
createUser := postgres.CreateUserParams{ createUser := postgres.CreateUserParams{
@ -135,7 +135,7 @@ func (h *Handler) registerPost(c echo.Context) error {
token, err := h.TokenVerifier.CreateToken(&user) token, err := h.TokenVerifier.CreateToken(&user)
if err != nil { if err != nil {
return err return fmt.Errorf("create token: %w", err)
} }
go h.UpdateLastLogin(user.ID) go h.UpdateLastLogin(user.ID)

View File

@ -1,6 +1,7 @@
package server package server
import ( import (
"fmt"
"net/http" "net/http"
"git.javil.eu/jacob1123/budgeteer/postgres" "git.javil.eu/jacob1123/budgeteer/postgres"
@ -26,12 +27,12 @@ func (h *Handler) importYNAB(c echo.Context) error {
transactionsFile, err := c.FormFile("transactions") transactionsFile, err := c.FormFile("transactions")
if err != nil { if err != nil {
return err return fmt.Errorf("get transactions: %w", err)
} }
transactions, err := transactionsFile.Open() transactions, err := transactionsFile.Open()
if err != nil { if err != nil {
return err return fmt.Errorf("open transactions: %w", err)
} }
err = ynab.ImportTransactions(c.Request().Context(), transactions) err = ynab.ImportTransactions(c.Request().Context(), transactions)
@ -41,12 +42,12 @@ func (h *Handler) importYNAB(c echo.Context) error {
assignmentsFile, err := c.FormFile("assignments") assignmentsFile, err := c.FormFile("assignments")
if err != nil { if err != nil {
return err return fmt.Errorf("get assignments: %w", err)
} }
assignments, err := assignmentsFile.Open() assignments, err := assignmentsFile.Open()
if err != nil { if err != nil {
return err return fmt.Errorf("open assignments: %w", err)
} }
err = ynab.ImportAssignments(c.Request().Context(), assignments) err = ynab.ImportAssignments(c.Request().Context(), assignments)

View File

@ -11,10 +11,10 @@ export interface Suggestion {
} }
const props = defineProps<{ const props = defineProps<{
text: string, text: string | null,
id: string | undefined, id: string | null,
model: string, model: string,
type?: string | undefined, type?: string | null,
}>(); }>();
const SearchQuery = ref(props.text || ""); const SearchQuery = ref(props.text || "");

View File

@ -16,9 +16,9 @@ const TX = ref<Transaction>({
Memo: "", Memo: "",
Amount: 0, Amount: 0,
Payee: "", Payee: "",
PayeeID: undefined, PayeeID: null,
Category: "", Category: "",
CategoryID: undefined, CategoryID: null,
CategoryGroup: "", CategoryGroup: "",
GroupID: "", GroupID: "",
ID: "", ID: "",

View File

@ -42,7 +42,7 @@ const filters = ref({
ToDate: new Date(2999,11,32), ToDate: new Date(2999,11,32),
}); });
watch(() => filters.value.AccountID watch(() => (filters.value.AccountID ?? "")
+ filters.value.PayeeID + filters.value.PayeeID
+ filters.value.CategoryID + filters.value.CategoryID
+ filters.value.FromDate?.toISOString() + filters.value.FromDate?.toISOString()

View File

@ -2,7 +2,7 @@ import { defineStore } from "pinia";
import { GET, POST } from "../api"; import { GET, POST } from "../api";
import { useBudgetsStore } from "./budget"; import { useBudgetsStore } from "./budget";
import { useSessionStore } from "./session"; import { useSessionStore } from "./session";
import { useTransactionsStore } from "./transactions"; import { Transaction, useTransactionsStore } from "./transactions";
interface State { interface State {
Accounts: Map<string, Account>; Accounts: Map<string, Account>;
@ -200,6 +200,7 @@ export const useAccountStore = defineStore("budget/account", {
transactionsStore.AddTransactions( transactionsStore.AddTransactions(
response.Transactions response.Transactions
); );
account.Transactions = response.Transactions.map((x : Transaction) =>x.ID);
}, },
async FetchMonthBudget(budgetid: string, year: number, month: number) { async FetchMonthBudget(budgetid: string, year: number, month: number) {
const result = await GET( const result = await GET(

View File

@ -17,12 +17,12 @@ export interface Transaction {
TransferAccount: string; TransferAccount: string;
CategoryGroup: string; CategoryGroup: string;
Category: string; Category: string;
CategoryID: string | undefined; CategoryID: string | null;
Memo: string; Memo: string;
Status: string; Status: string;
GroupID: string; GroupID: string;
Payee: string; Payee: string;
PayeeID: string | undefined; PayeeID: string | null;
Amount: number; Amount: number;
Reconciled: boolean; Reconciled: boolean;
Account: string; Account: string;
@ -47,10 +47,12 @@ export const useTransactionsStore = defineStore("budget/transactions", {
} }
return reconciledBalance; return reconciledBalance;
}, },
TransactionsByDate(state) : Record<string, Transaction[]> { TransactionsByDate(state) : Record<string, Transaction[]>|undefined{
const accountsStore = useAccountStore(); const accountsStore = useAccountStore();
const accountID = accountsStore.CurrentAccountID; const account = accountsStore.CurrentAccount;
const allTransactions = [...this.Transactions.values()].filter(x => x.AccountID == accountID); if(account === undefined)
return undefined;
const allTransactions = account!.Transactions.map(x => this.Transactions.get(x) ?? {} as Transaction);
return groupBy(allTransactions, x => formatDate(x.Date)); return groupBy(allTransactions, x => formatDate(x.Date));
}, },
TransactionsList(state) : Transaction[] { TransactionsList(state) : Transaction[] {
@ -93,11 +95,11 @@ export const useTransactionsStore = defineStore("budget/transactions", {
async GetFilteredTransactions(accountID : string | null, categoryID : string | null, payeeID : string | null, fromDate : string, toDate : string) { async GetFilteredTransactions(accountID : string | null, categoryID : string | null, payeeID : string | null, fromDate : string, toDate : string) {
const budgetStore = useBudgetsStore(); const budgetStore = useBudgetsStore();
const payload = JSON.stringify({ const payload = JSON.stringify({
category_id: categoryID, categoryId: categoryID,
payee_id: payeeID, payeeId: payeeID,
account_id: accountID, accountId: accountID,
from_date: fromDate, fromDate: fromDate,
to_date: toDate, toDate: toDate,
}); });
const result = await POST("/budget/" + budgetStore.CurrentBudgetID + "/filtered-transactions", payload); const result = await POST("/budget/" + budgetStore.CurrentBudgetID + "/filtered-transactions", payload);
const response = await result.json(); const response = await result.json();