diff --git a/server/budgeting.go b/server/budgeting.go index 05020f6..2ef968d 100644 --- a/server/budgeting.go +++ b/server/budgeting.go @@ -79,8 +79,7 @@ func (h *Handler) prepareBudgeting(ctx context.Context, budget postgres.Budget, return BudgetingForMonthResponse{}, fmt.Errorf("error loading balances: %w", err) } - categoriesWithBalance, moneyUsed := h.calculateBalances( - budget, firstOfNextMonth, firstOfMonth, categories, cumultativeBalances) + categoriesWithBalance, moneyUsed := h.calculateBalances(firstOfNextMonth, firstOfMonth, categories, cumultativeBalances) availableBalance := h.getAvailableBalance(budget, moneyUsed, cumultativeBalances, categoriesWithBalance, firstOfNextMonth) data := BudgetingForMonthResponse{categoriesWithBalance, availableBalance} @@ -156,9 +155,8 @@ func (h *Handler) returnBudgetingData(c *gin.Context, budgetUUID uuid.UUID) { c.JSON(http.StatusOK, data) } -func (h *Handler) calculateBalances(budget postgres.Budget, - firstOfNextMonth time.Time, firstOfMonth time.Time, categories []postgres.GetCategoriesRow, - cumultativeBalances []postgres.GetCumultativeBalancesRow, +func (h *Handler) calculateBalances(firstOfNextMonth time.Time, firstOfMonth time.Time, + categories []postgres.GetCategoriesRow, cumultativeBalances []postgres.GetCumultativeBalancesRow, ) ([]CategoryWithBalance, numeric.Numeric) { categoriesWithBalance := []CategoryWithBalance{} diff --git a/server/main_test.go b/server/main_test.go index 7b2eae7..d140f23 100644 --- a/server/main_test.go +++ b/server/main_test.go @@ -96,7 +96,7 @@ func (h Handler) CheckAvailableBalance(ctx context.Context, t *testing.T, budget } // 2022-01 assert_equal(t, -115170.56, data.AvailableBalance.GetFloat64(), "available balance") - assert_equal(t, -110181.600, data.AvailableBalance.GetFloat64(), "available balance") + assertEqual(t, -110181.600, data.AvailableBalance.GetFloat64(), "available balance") categoryTestDataFile, err := os.Open("../testdata/production-export/results/categories-2021-12.json") if err != nil { @@ -118,9 +118,9 @@ func (h Handler) CheckAvailableBalance(ctx context.Context, t *testing.T, budget name := category.Group + " : " + category.Name if name == categoryName { - assert_equal(t, categoryTestData.Available, category.Available.GetFloat64(), "available for "+categoryName) - assert_equal(t, categoryTestData.Activity, category.Activity.GetFloat64(), "activity for "+categoryName) - assert_equal(t, categoryTestData.Assigned, category.Assigned.GetFloat64(), "assigned for "+categoryName) + assertEqual(t, categoryTestData.Available, category.Available.GetFloat64(), "available for "+categoryName) + assertEqual(t, categoryTestData.Activity, category.Activity.GetFloat64(), "activity for "+categoryName) + assertEqual(t, categoryTestData.Assigned, category.Assigned.GetFloat64(), "assigned for "+categoryName) found = true } } @@ -131,7 +131,7 @@ func (h Handler) CheckAvailableBalance(ctx context.Context, t *testing.T, budget } } -func assert_equal(t *testing.T, expected, actual float64, message string) { +func assertEqual(t *testing.T, expected, actual float64, message string) { if expected == actual { return }