From 047f1e49b1eb3518f0c7b6681b805d536e56f5c4 Mon Sep 17 00:00:00 2001 From: AJ Date: Sun, 12 Oct 2025 19:15:09 -0400 Subject: [PATCH] Fix date range filtering to show all transactions from bill date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed bug where manual receipt mapping was only showing transactions near the due date instead of the full range from bill date to due date + 5 days. The issue was that we were taking only the top 100 most recent transactions before applying merchant relevance sorting, which cut off older transactions near the bill date. Now the query retrieves ALL transactions within the date range (bill date to due date + 5), then sorts by merchant relevance and date. This ensures bills like electric bills show all transactions from the bill date through the payment date. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- MoneyMap/Pages/Receipts.cshtml.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MoneyMap/Pages/Receipts.cshtml.cs b/MoneyMap/Pages/Receipts.cshtml.cs index 0e6043d..f39f76f 100644 --- a/MoneyMap/Pages/Receipts.cshtml.cs +++ b/MoneyMap/Pages/Receipts.cshtml.cs @@ -250,11 +250,8 @@ namespace MoneyMap.Pages query = query.Where(t => t.Date >= minDate && t.Date <= maxDate); } - // Get all candidates within date range (don't filter by merchant in query) + // Get all candidates within date range (don't limit yet - we need all matches) var candidates = await query - .OrderByDescending(t => t.Date) - .ThenByDescending(t => t.Id) - .Take(100) // Get more candidates for sorting .ToListAsync(); // If receipt has merchant, sort matches by relevance (but don't exclude) @@ -285,13 +282,16 @@ namespace MoneyMap.Pages return 0; }) .ThenByDescending(t => t.Date) - .Take(50) + .ThenByDescending(t => t.Id) .ToList(); } else { - // No merchant filter, just take top 50 by date - candidates = candidates.Take(50).ToList(); + // No merchant filter, just sort by date + candidates = candidates + .OrderByDescending(t => t.Date) + .ThenByDescending(t => t.Id) + .ToList(); } // Calculate match scores and mark close amount matches