Styleguide

This commit is contained in:
Jan Bader 2022-04-05 19:34:45 +00:00
parent 684efffbdf
commit ce466e0031
2 changed files with 8 additions and 10 deletions

View File

@ -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{}

View File

@ -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
}