Set Available balance of income category

This commit is contained in:
Jan Bader 2022-03-04 21:18:44 +00:00
parent 0dde94f855
commit caf39fe5ea

View File

@ -98,6 +98,15 @@ func (h *Handler) budgetingForMonth(c *gin.Context) {
categoriesWithBalance, moneyUsed := h.calculateBalances(
budget, firstOfNextMonth, firstOfMonth, categories, cumultativeBalances)
availableBalance := h.getAvailableBalance(budget, moneyUsed, cumultativeBalances, firstOfNextMonth)
for i := range categoriesWithBalance {
cat := &categoriesWithBalance[i]
if cat.ID != budget.IncomeCategoryID {
continue
}
cat.Available = availableBalance
cat.AvailableLastMonth = availableBalance
}
data := struct {
Categories []CategoryWithBalance