From 19d2ddbd65d7dfa0b380aca360da2938df40e0a0 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Sun, 20 Feb 2022 22:37:34 +0000 Subject: [PATCH] Minor improvements --- server/account_test.go | 2 +- server/budgeting.go | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/server/account_test.go b/server/account_test.go index cd4efcb..742b314 100644 --- a/server/account_test.go +++ b/server/account_test.go @@ -18,7 +18,7 @@ func init() { //nolint:gochecknoinits txdb.Register("pgtx", "pgx", "postgres://budgeteer_test:budgeteer_test@localhost:5432/budgeteer_test") } -func TestListTimezonesHandler(t *testing.T) { +func TestRegisterUser(t *testing.T) { //nolint:funlen t.Parallel() database, err := postgres.Connect("pgtx", "example") if err != nil { diff --git a/server/budgeting.go b/server/budgeting.go index da7204a..6f57302 100644 --- a/server/budgeting.go +++ b/server/budgeting.go @@ -85,11 +85,8 @@ func (h *Handler) budgetingForMonth(c *gin.Context) { } // skip everything in the future - categoriesWithBalance, moneyUsed, err := h.calculateBalances( - c, budget, firstOfNextMonth, firstOfMonth, categories, cumultativeBalances) - if err != nil { - return - } + categoriesWithBalance, moneyUsed := h.calculateBalances( + budget, firstOfNextMonth, firstOfMonth, categories, cumultativeBalances) availableBalance := h.getAvailableBalance(categories, budget, moneyUsed, cumultativeBalances, firstOfNextMonth) @@ -153,9 +150,9 @@ func (h *Handler) budgeting(c *gin.Context) { c.JSON(http.StatusOK, data) } -func (h *Handler) calculateBalances(c *gin.Context, budget postgres.Budget, +func (h *Handler) calculateBalances(budget postgres.Budget, firstOfNextMonth time.Time, firstOfMonth time.Time, categories []postgres.GetCategoriesRow, - cumultativeBalances []postgres.GetCumultativeBalancesRow) ([]CategoryWithBalance, postgres.Numeric, error) { + cumultativeBalances []postgres.GetCumultativeBalancesRow) ([]CategoryWithBalance, postgres.Numeric) { categoriesWithBalance := []CategoryWithBalance{} hiddenCategory := CategoryWithBalance{ GetCategoriesRow: &postgres.GetCategoriesRow{ @@ -191,10 +188,13 @@ func (h *Handler) calculateBalances(c *gin.Context, budget postgres.Budget, categoriesWithBalance = append(categoriesWithBalance, hiddenCategory) - return categoriesWithBalance, moneyUsed, nil + return categoriesWithBalance, moneyUsed } -func (*Handler) CalculateCategoryBalances(cat *postgres.GetCategoriesRow, cumultativeBalances []postgres.GetCumultativeBalancesRow, firstOfNextMonth time.Time, moneyUsed *postgres.Numeric, firstOfMonth time.Time, hiddenCategory CategoryWithBalance, budget postgres.Budget) CategoryWithBalance { +func (*Handler) CalculateCategoryBalances(cat *postgres.GetCategoriesRow, + cumultativeBalances []postgres.GetCumultativeBalancesRow, firstOfNextMonth time.Time, + moneyUsed *postgres.Numeric, firstOfMonth time.Time, hiddenCategory CategoryWithBalance, + budget postgres.Budget) CategoryWithBalance { categoryWithBalance := CategoryWithBalance{ GetCategoriesRow: cat, Available: postgres.NewZeroNumeric(),