Files
MoneyMap/MoneyMap.Core/Models/Budget.cs
T
2026-04-20 18:16:33 -04:00

63 lines
1.6 KiB
C#

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