Add available balance

This commit is contained in:
2021-12-07 20:22:40 +00:00
parent 1d4bc158a8
commit 64822912d9
7 changed files with 116 additions and 13 deletions

View File

@ -12,10 +12,11 @@ import (
type BudgetingData struct {
AlwaysNeededData
Categories []postgres.GetCategoriesWithBalanceRow
Date time.Time
Next time.Time
Previous time.Time
Categories []postgres.GetCategoriesWithBalanceRow
AvailableBalance postgres.Numeric
Date time.Time
Next time.Time
Previous time.Time
}
func (h *Handler) budgeting(c *gin.Context) {
@ -64,9 +65,16 @@ func (h *Handler) budgeting(c *gin.Context) {
return
}
availableBalance, err := h.Service.DB.GetAvailableBalance(c.Request.Context(), budgetUUID)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
d := BudgetingData{
c.MustGet("data").(AlwaysNeededData),
categories,
availableBalance,
firstOfMonth,
firstOfNextMonth,
firstOfPreviousMonth,