diff --git a/apps/finance/services/api/main/handler.go b/apps/finance/services/api/main/handler.go index b513101..f809c22 100644 --- a/apps/finance/services/api/main/handler.go +++ b/apps/finance/services/api/main/handler.go @@ -324,7 +324,7 @@ func (h *Handler) Dashboard(w http.ResponseWriter, r *http.Request) { // disposable income = income - fixed recurring disposableIncome := thisMonthIncome - totalFixedCents - // deduct committed goal contributions from disposable + // deduct committed goal contributions from disposable and add to fixed costs list committedGoalsCents := int64(0) if goals, err := h.store.getGoals(ctx, a.UserID); err == nil { now2 := time.Now() @@ -340,10 +340,17 @@ func (h *Handler) Dashboard(w http.ResponseWriter, r *http.Request) { if ml < 1 { ml = 1 } - committedGoalsCents += remaining / ml + monthly := remaining / ml + committedGoalsCents += monthly + recurringExpenses = append(recurringExpenses, RecurringExpense{ + Category: g.Name, + MonthlyCents: monthly, + IsGoal: true, + }) } } disposableIncome -= committedGoalsCents + totalCommittedCents := totalFixedCents + committedGoalsCents // variable spend so far this month (non-fixed categories, expenses only) variableSpent := int64(0) @@ -450,6 +457,7 @@ func (h *Handler) Dashboard(w http.ResponseWriter, r *http.Request) { RecurringExpenses: recurringExpenses, BankShouldBe: bankShouldBe, SafetyBufferCents: safetyBuffer, + TotalCommittedCents: totalCommittedCents, SavingsRatePct: savingsRatePct, LastMonthSavingsRatePct: lastMonthSavingsRatePct, PortfolioValueCents: portfolioValueCents, diff --git a/apps/finance/services/api/main/models.go b/apps/finance/services/api/main/models.go index 6000ee7..4ff6969 100644 --- a/apps/finance/services/api/main/models.go +++ b/apps/finance/services/api/main/models.go @@ -113,8 +113,9 @@ var FixedCategories = map[string]bool{ } type RecurringExpense struct { - Category string + Category string MonthlyCents int64 + IsGoal bool // true when this entry comes from a committed goal } type DashboardData struct { @@ -140,8 +141,9 @@ type DashboardData struct { MonthSpentPct int // % of disposable already spent RecurringExpenses []RecurringExpense - BankShouldBe int64 // sum of upcoming fixed costs + safety buffer - SafetyBufferCents int64 + BankShouldBe int64 + SafetyBufferCents int64 + TotalCommittedCents int64 // sum of all fixed costs + committed goals SavingsRatePct int // savings / income * 100 this month LastMonthSavingsRatePct int diff --git a/apps/finance/services/api/main/templates/dashboard.html b/apps/finance/services/api/main/templates/dashboard.html index 48fc4de..ff41a45 100644 --- a/apps/finance/services/api/main/templates/dashboard.html +++ b/apps/finance/services/api/main/templates/dashboard.html @@ -236,10 +236,14 @@ {{$color := index $d.CategoryColors .Category}}