- @if (!string.IsNullOrWhiteSpace(r.Merchant) || r.ReceiptDate.HasValue || r.Total.HasValue)
+ @if (!string.IsNullOrWhiteSpace(r.Merchant) || r.ReceiptDate.HasValue || r.DueDate.HasValue || r.Total.HasValue)
{
@if (!string.IsNullOrWhiteSpace(r.Merchant))
@@ -277,6 +281,10 @@
{
Date: @r.ReceiptDate.Value.ToString("yyyy-MM-dd")
}
+ @if (r.DueDate.HasValue)
+ {
+
Due Date: @r.DueDate.Value.ToString("yyyy-MM-dd")
+ }
@if (r.Total.HasValue)
{
Total: @r.Total.Value.ToString("C")
@@ -294,7 +302,11 @@
@if (matches.Any())
{
- @if (r.ReceiptDate.HasValue)
+ @if (r.ReceiptDate.HasValue && r.DueDate.HasValue)
+ {
+
Showing transactions between bill date (@r.ReceiptDate.Value.ToString("yyyy-MM-dd")) and due date (@r.DueDate.Value.ToString("yyyy-MM-dd")).
+ }
+ else if (r.ReceiptDate.HasValue)
{
Showing transactions within ±3 days of receipt date (@r.ReceiptDate.Value.ToString("yyyy-MM-dd")).
}
@@ -345,7 +357,11 @@
{
No matching transactions found.
- @if (r.ReceiptDate.HasValue)
+ @if (r.ReceiptDate.HasValue && r.DueDate.HasValue)
+ {
+ Try searching between @r.ReceiptDate.Value.ToString("yyyy-MM-dd") and @r.DueDate.Value.ToString("yyyy-MM-dd").
+ }
+ else if (r.ReceiptDate.HasValue)
{
Try searching within ±3 days of @r.ReceiptDate.Value.ToString("yyyy-MM-dd").
}
diff --git a/MoneyMap/Pages/Receipts.cshtml.cs b/MoneyMap/Pages/Receipts.cshtml.cs
index 89f0ee3..c397426 100644
--- a/MoneyMap/Pages/Receipts.cshtml.cs
+++ b/MoneyMap/Pages/Receipts.cshtml.cs
@@ -202,6 +202,7 @@ namespace MoneyMap.Pages
TransactionAmount = r.Transaction?.Amount,
Merchant = r.Merchant,
ReceiptDate = r.ReceiptDate,
+ DueDate = r.DueDate,
Total = r.Total,
StoragePath = r.StoragePath
}).ToList();
@@ -232,9 +233,17 @@ namespace MoneyMap.Pages
.Where(t => !transactionsWithReceipts.Contains(t.Id))
.AsQueryable();
- // If receipt has a date, filter by +/- 3 days (this is the primary filter)
- if (receipt.ReceiptDate.HasValue)
+ // If receipt has a date, filter by date range
+ if (receipt.ReceiptDate.HasValue && receipt.DueDate.HasValue)
{
+ // For bills with due dates: use range from bill date to due date
+ var minDate = receipt.ReceiptDate.Value;
+ var maxDate = receipt.DueDate.Value;
+ query = query.Where(t => t.Date >= minDate && t.Date <= maxDate);
+ }
+ else if (receipt.ReceiptDate.HasValue)
+ {
+ // For regular receipts: use +/- 3 days (this is the primary filter)
var minDate = receipt.ReceiptDate.Value.AddDays(-3);
var maxDate = receipt.ReceiptDate.Value.AddDays(3);
query = query.Where(t => t.Date >= minDate && t.Date <= maxDate);
@@ -350,6 +359,7 @@ namespace MoneyMap.Pages
public decimal? TransactionAmount { get; set; }
public string? Merchant { get; set; }
public DateTime? ReceiptDate { get; set; }
+ public DateTime? DueDate { get; set; }
public decimal? Total { get; set; }
public string StoragePath { get; set; } = "";
}
diff --git a/MoneyMap/Services/OpenAIReceiptParser.cs b/MoneyMap/Services/OpenAIReceiptParser.cs
index 50d09e6..6b247dc 100644
--- a/MoneyMap/Services/OpenAIReceiptParser.cs
+++ b/MoneyMap/Services/OpenAIReceiptParser.cs
@@ -104,6 +104,7 @@ namespace MoneyMap.Services
receipt.Subtotal = parseData.Subtotal;
receipt.Tax = parseData.Tax;
receipt.ReceiptDate = parseData.ReceiptDate;
+ receipt.DueDate = parseData.DueDate;
// Update transaction merchant if we extracted one and transaction doesn't have one yet
if (receipt.Transaction != null &&
@@ -211,6 +212,7 @@ namespace MoneyMap.Services
{
""merchant"": ""store name"",
""receiptDate"": ""YYYY-MM-DD"" (or null if not found),
+ ""dueDate"": ""YYYY-MM-DD"" (or null if not found - for bills only),
""subtotal"": 0.00 (or null if not found),
""tax"": 0.00 (or null if not found),
""total"": 0.00,
@@ -231,7 +233,9 @@ Extract all line items you can see on the receipt. For each item:
- unitPrice: Price per unit if quantity applies, otherwise null
- lineTotal: The total amount for this line (required)
-For utility bills, service charges, fees, and taxes - these are NOT products with quantities, so set quantity and unitPrice to null.";
+For utility bills, service charges, fees, and taxes - these are NOT products with quantities, so set quantity and unitPrice to null.
+
+If this is a bill (utility, credit card, etc.), look for a due date, payment due date, or deadline and extract it as dueDate. For regular receipts, dueDate should be null.";
if (!string.IsNullOrWhiteSpace(transactionName))
{
@@ -313,6 +317,7 @@ For utility bills, service charges, fees, and taxes - these are NOT products wit
{
public string? Merchant { get; set; }
public DateTime? ReceiptDate { get; set; }
+ public DateTime? DueDate { get; set; }
public decimal? Subtotal { get; set; }
public decimal? Tax { get; set; }
public decimal? Total { get; set; }
diff --git a/MoneyMap/Services/ReceiptAutoMapper.cs b/MoneyMap/Services/ReceiptAutoMapper.cs
index 23c96d7..1d1aaeb 100644
--- a/MoneyMap/Services/ReceiptAutoMapper.cs
+++ b/MoneyMap/Services/ReceiptAutoMapper.cs
@@ -96,10 +96,17 @@ namespace MoneyMap.Services
.Include(t => t.Merchant)
.AsQueryable();
- // Start with date range filter (if we have a receipt date)
- if (receipt.ReceiptDate.HasValue)
+ // Start with date range filter
+ if (receipt.ReceiptDate.HasValue && receipt.DueDate.HasValue)
{
- // Allow +/- 3 days for transaction date to account for processing delays
+ // For bills with due dates: use range from bill date to due date
+ var minDate = receipt.ReceiptDate.Value;
+ var maxDate = receipt.DueDate.Value;
+ query = query.Where(t => t.Date >= minDate && t.Date <= maxDate);
+ }
+ else if (receipt.ReceiptDate.HasValue)
+ {
+ // For regular receipts: allow +/- 3 days for transaction date to account for processing delays
var minDate = receipt.ReceiptDate.Value.AddDays(-3);
var maxDate = receipt.ReceiptDate.Value.AddDays(3);
query = query.Where(t => t.Date >= minDate && t.Date <= maxDate);