Files
MoneyMap/MoneyMap/Models/CategoryMapping.cs
AJ Isaacs a30e6ff089 Refactor: Extract CategoryMapping model and add caching
- Move CategoryMapping class to Models/CategoryMapping.cs
- Add IMemoryCache with 10-minute TTL for category mappings
- Add InvalidateMappingsCache() method for cache invalidation
- Reduces repeated DB queries during bulk categorization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 21:11:29 -05:00

48 lines
1.5 KiB
C#

namespace MoneyMap.Models
{
/// <summary>
/// Represents a mapping rule that associates transaction name patterns with categories.
/// Used for automatic categorization of transactions during import.
/// </summary>
public class CategoryMapping
{
public int Id { get; set; }
/// <summary>
/// The category to assign when a transaction matches the pattern.
/// </summary>
public required string Category { get; set; }
/// <summary>
/// The pattern to match against transaction names (case-insensitive contains).
/// </summary>
public required string Pattern { get; set; }
/// <summary>
/// Higher priority mappings are checked first. Default is 0.
/// </summary>
public int Priority { get; set; } = 0;
/// <summary>
/// Optional merchant to auto-assign when this pattern matches.
/// </summary>
public int? MerchantId { get; set; }
public Merchant? Merchant { get; set; }
/// <summary>
/// AI confidence score when this rule was created by AI (0.0 - 1.0).
/// </summary>
public decimal? Confidence { get; set; }
/// <summary>
/// Who created this rule: "User" or "AI".
/// </summary>
public string? CreatedBy { get; set; }
/// <summary>
/// When this rule was created.
/// </summary>
public DateTime? CreatedAt { get; set; }
}
}