diff --git a/http/budgeting.go b/http/budgeting.go index 2715db2..f12f6d6 100644 --- a/http/budgeting.go +++ b/http/budgeting.go @@ -14,6 +14,9 @@ import ( type BudgetingData struct { AlwaysNeededData Categories []postgres.GetCategoriesWithBalanceRow + Date time.Time + Next time.Time + Previous time.Time } func (h *Handler) budgeting(c *gin.Context) { @@ -48,12 +51,13 @@ func (h *Handler) budgeting(c *gin.Context) { } firstOfMonth := time.Date(year, time.Month(month), 1, 0, 0, 0, 0, now.Location()) - lastOfMonth := firstOfMonth.AddDate(0, 1, -1) + firstOfNextMonth := firstOfMonth.AddDate(0, 1, 0) + firstOfPreviousMonth := firstOfMonth.AddDate(0, -1, 0) params := postgres.GetCategoriesWithBalanceParams{ BudgetID: budgetUUID, FromDate: firstOfMonth, - ToDate: lastOfMonth, + ToDate: firstOfNextMonth, } categories, err := h.Service.DB.GetCategoriesWithBalance(context.Background(), params) if err != nil { @@ -64,6 +68,9 @@ func (h *Handler) budgeting(c *gin.Context) { d := BudgetingData{ c.MustGet("data").(AlwaysNeededData), categories, + firstOfMonth, + firstOfNextMonth, + firstOfPreviousMonth, } c.HTML(http.StatusOK, "budgeting.html", d) diff --git a/web/budgeting.html b/web/budgeting.html index 5b26e3f..94249f0 100644 --- a/web/budgeting.html +++ b/web/budgeting.html @@ -1,7 +1,9 @@ {{template "base" .}} -{{define "title"}}Budget{{end}} +{{define "title"}} + {{printf "Budget for %s %d" .Date.Month .Date.Year}} +{{end}} {{define "new"}} {{template "transaction-new"}} @@ -13,8 +15,8 @@
- Next Month - Previous Month + Previous Month + Next Month
{{range .Categories}}