using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace MoneyMap.Models; public enum BudgetPeriod { Weekly = 0, Monthly = 1, Yearly = 2 } /// /// Represents a spending budget for a category or total spending. /// When Category is null, this is a "Total" budget that tracks all spending. /// public class Budget { [Key] public int Id { get; set; } /// /// The category this budget applies to. /// Null means this is a total spending budget (all categories combined). /// [MaxLength(100)] public string? Category { get; set; } /// /// The budget limit amount (positive value). /// [Column(TypeName = "decimal(18,2)")] public decimal Amount { get; set; } /// /// The time period for this budget (Weekly, Monthly, Yearly). /// public BudgetPeriod Period { get; set; } = BudgetPeriod.Monthly; /// /// When the budget becomes effective. Used to calculate period boundaries. /// public DateTime StartDate { get; set; } = DateTime.Today; /// /// Whether this budget is currently active. /// public bool IsActive { get; set; } = true; /// /// Optional notes about this budget. /// [MaxLength(500)] public string? Notes { get; set; } // Computed properties [NotMapped] public bool IsTotalBudget => Category == null; [NotMapped] public string DisplayName => Category ?? "Total Spending"; }