refactor: extract Models and Data into MoneyMap.Core shared library
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
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";
|
||||
}
|
||||
Reference in New Issue
Block a user