Fix date range filtering to show all transactions from bill date

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 <noreply@anthropic.com>
This commit is contained in:
AJ
2025-10-12 19:15:09 -04:00
parent d5852f2bb3
commit 047f1e49b1

View File

@@ -250,11 +250,8 @@ namespace MoneyMap.Pages
query = query.Where(t => t.Date >= minDate && t.Date <= maxDate); 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 var candidates = await query
.OrderByDescending(t => t.Date)
.ThenByDescending(t => t.Id)
.Take(100) // Get more candidates for sorting
.ToListAsync(); .ToListAsync();
// If receipt has merchant, sort matches by relevance (but don't exclude) // If receipt has merchant, sort matches by relevance (but don't exclude)
@@ -285,13 +282,16 @@ namespace MoneyMap.Pages
return 0; return 0;
}) })
.ThenByDescending(t => t.Date) .ThenByDescending(t => t.Date)
.Take(50) .ThenByDescending(t => t.Id)
.ToList(); .ToList();
} }
else else
{ {
// No merchant filter, just take top 50 by date // No merchant filter, just sort by date
candidates = candidates.Take(50).ToList(); candidates = candidates
.OrderByDescending(t => t.Date)
.ThenByDescending(t => t.Id)
.ToList();
} }
// Calculate match scores and mark close amount matches // Calculate match scores and mark close amount matches