From d5c90a9197ac3cb4406c3a69d9b4b9ac8b6b83a0 Mon Sep 17 00:00:00 2001 From: Catherine Renelle <32781029+catrenelle@users.noreply.github.com> Date: Sun, 15 Feb 2026 15:42:04 -0500 Subject: [PATCH] Include uncategorized spending and show all categories on dashboard Remove CategoryId.HasValue filter so uncategorized transactions appear in the spending breakdown. Remove Take(N) limit to show all categories. Co-Authored-By: Claude Opus 4.6 --- src/Purrse.Api/Services/DashboardService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Purrse.Api/Services/DashboardService.cs b/src/Purrse.Api/Services/DashboardService.cs index 07e8d0a..8594bec 100644 --- a/src/Purrse.Api/Services/DashboardService.cs +++ b/src/Purrse.Api/Services/DashboardService.cs @@ -52,20 +52,20 @@ public class DashboardService : IDashboardService var changePercent = lastMonthSpending == 0 ? 0 : ((thisMonthSpending - lastMonthSpending) / lastMonthSpending) * 100; var spendingByCategory = await _db.Transactions - .Where(t => t.Account.UserId == userId && t.Date >= startOfMonth && t.Amount < 0 && !t.IsVoid && t.CategoryId.HasValue) + .Where(t => t.Account.UserId == userId && t.Date >= startOfMonth && t.Amount < 0 && !t.IsVoid) .GroupBy(t => t.CategoryId) .Select(g => new { CategoryId = g.Key, Total = -g.Sum(t => t.Amount) }) .OrderByDescending(x => x.Total) - .Take(5) .ToListAsync(); + var categoryIds = spendingByCategory.Where(x => x.CategoryId.HasValue).Select(x => x.CategoryId!.Value); var categoryNames = await _db.Categories - .Where(c => spendingByCategory.Select(x => x.CategoryId).Contains(c.Id)) + .Where(c => categoryIds.Contains(c.Id)) .ToDictionaryAsync(c => c.Id, c => c.Name); var totalSpending = spendingByCategory.Sum(x => x.Total); var topCategories = spendingByCategory.Select(x => new CategorySpending( - categoryNames.GetValueOrDefault(x.CategoryId!.Value, "Unknown"), + x.CategoryId.HasValue ? categoryNames.GetValueOrDefault(x.CategoryId.Value, "Unknown") : "Uncategorized", x.Total, totalSpending > 0 ? (x.Total / totalSpending) * 100 : 0, null)).ToList();