Files
2026-04-02 19:28:18 +01:00

45 lines
1.4 KiB
C#

using System.ComponentModel.DataAnnotations;
namespace BudgetApp.Data.Entities;
public class Salary
{
public int Id { get; set; }
[Required, MaxLength(200)]
public string Name { get; set; } = string.Empty;
public decimal Amount { get; set; }
public RecurrenceType RecurrenceType { get; set; } = RecurrenceType.Monthly;
public DateTime StartDate { get; set; } = DateTime.Today;
public int AccountId { get; set; }
public Account Account { get; set; } = default!;
public int? CategoryId { get; set; }
public Category? Category { get; set; }
[Required]
public string UserId { get; set; } = string.Empty;
public ApplicationUser User { get; set; } = default!;
public string GetPaydaySummary() => RecurrenceType switch
{
RecurrenceType.Weekly => $"Every week on {StartDate:dddd}",
RecurrenceType.FourWeekly => $"Every 4 weeks on {StartDate:dddd}",
RecurrenceType.Monthly => $"Monthly on the {GetOrdinal(StartDate.Day)}",
RecurrenceType.Yearly => $"Annually on {StartDate:MMMM d}",
_ => RecurrenceType.ToString()
};
private static string GetOrdinal(int day) => day switch
{
1 or 21 or 31 => $"{day}st",
2 or 22 => $"{day}nd",
3 or 23 => $"{day}rd",
_ => $"{day}th"
};
}