Add ability to select month for budget
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user