diff --git a/MoneyMap/Pages/Receipts.cshtml b/MoneyMap/Pages/Receipts.cshtml
index 41e9e6a..64921b6 100644
--- a/MoneyMap/Pages/Receipts.cshtml
+++ b/MoneyMap/Pages/Receipts.cshtml
@@ -334,11 +334,11 @@
@{
- var firstMatchId = matches.FirstOrDefault(t => t.IsAmountMatch)?.Id;
+ var firstMatchId = matches.FirstOrDefault(t => t.IsExactAmount)?.Id ?? matches.FirstOrDefault(t => t.IsCloseAmount)?.Id;
}
@foreach (var txn in matches)
{
- var rowClass = txn.IsAmountMatch ? "table-success" : "";
+ var rowClass = txn.IsExactAmount ? "table-success" : (txn.IsCloseAmount ? "table-warning" : "");
var isFirstMatch = txn.Id == firstMatchId;
{
- var transactionAmount = Math.Abs(t.Amount);
+ var transactionAmount = Math.Round(Math.Abs(t.Amount), 2);
return transactionAmount >= minAmount && transactionAmount <= maxAmount;
})
.ToList();
@@ -355,16 +355,18 @@ namespace MoneyMap.Pages
Amount = t.Amount,
MerchantName = t.Merchant?.Name,
PaymentMethod = t.PaymentMethodLabel,
- IsAmountMatch = false
+ IsExactAmount = false,
+ IsCloseAmount = false
};
- // Check if amount matches within tighter tolerance for highlighting (±2%)
+ // Amount matching flags
if (receipt.Total.HasValue)
{
- var receiptTotal = Math.Abs(receipt.Total.Value);
- var transactionAmount = Math.Abs(t.Amount);
- var tightTolerance = receiptTotal * 0.02m; // 2% for green highlighting
- option.IsAmountMatch = Math.Abs(transactionAmount - receiptTotal) <= tightTolerance;
+ var receiptTotal = Math.Round(Math.Abs(receipt.Total.Value), 2);
+ var transactionAmount = Math.Round(Math.Abs(t.Amount), 2);
+ option.IsExactAmount = transactionAmount == receiptTotal;
+ var tolerance = receiptTotal * 0.10m;
+ option.IsCloseAmount = !option.IsExactAmount && Math.Abs(transactionAmount - receiptTotal) <= tolerance;
}
return option;
@@ -424,8 +426,12 @@ namespace MoneyMap.Pages
public decimal Amount { get; set; }
public string? MerchantName { get; set; }
public string PaymentMethod { get; set; } = "";
- public bool IsAmountMatch { get; set; }
+ public bool IsExactAmount { get; set; }
+ public bool IsCloseAmount { get; set; }
}
}
}
+
+
+