- Budget model with Weekly/Monthly/Yearly periods - BudgetService for CRUD and spending calculations - New /Budgets page for managing budgets - Dashboard integration with progress bars - Support for category-specific or total spending budgets - Period boundaries calculated from budget start date 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
63 lines
1.6 KiB
C#
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";
|
|
}
|