Minor improvements
This commit is contained in:
parent
3cb39d978a
commit
19d2ddbd65
@ -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 {
|
||||
|
@ -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(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user