This commit is contained in:
rossmill76 committed 2026-04-02 19:28:18 +01:00
1 parent 4281924ee5
commit fc702adfcd
13 files changed
+69 -22

No files matched your search

+2 -1
View File
@@ -6,5 +6,6 @@ public enum RecurrenceType
Daily,
Weekly,
Monthly,
Yearly
Yearly,
FourWeekly
}
+5 -4
View File
@@ -27,10 +27,11 @@ public class Salary
public string GetPaydaySummary() => RecurrenceType switch
{
RecurrenceType.Weekly => $"Every week on {StartDate:dddd}",
RecurrenceType.Monthly => $"Monthly on the {GetOrdinal(StartDate.Day)}",
RecurrenceType.Yearly => $"Annually on {StartDate:MMMM d}",
_ => RecurrenceType.ToString()
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
@@ -129,9 +129,10 @@ public class SalaryRepository(ApplicationDbContext db) : ISalaryRepository
private static DateTime GetNextDate(DateTime from, Salary salary) => salary.RecurrenceType switch
{
RecurrenceType.Weekly => from.AddDays(7),
RecurrenceType.Monthly => from.AddMonths(1),
RecurrenceType.Yearly => from.AddYears(1),
_ => from.AddMonths(1)
RecurrenceType.Weekly => from.AddDays(7),
RecurrenceType.FourWeekly => from.AddDays(28),
RecurrenceType.Monthly => from.AddMonths(1),
RecurrenceType.Yearly => from.AddYears(1),
_ => from.AddMonths(1)
};
}
@@ -278,10 +278,11 @@ public class TransactionRepository(ApplicationDbContext db) : ITransactionReposi
internal static DateTime GetNextOccurrence(DateTime current, RecurrenceType recurrence) => recurrence switch
{
RecurrenceType.Daily => current.AddDays(1),
RecurrenceType.Weekly => current.AddDays(7),
RecurrenceType.Monthly => current.AddMonths(1),
RecurrenceType.Yearly => current.AddYears(1),
_ => DateTime.MaxValue
RecurrenceType.Daily => current.AddDays(1),
RecurrenceType.Weekly => current.AddDays(7),
RecurrenceType.FourWeekly => current.AddDays(28),
RecurrenceType.Monthly => current.AddMonths(1),
RecurrenceType.Yearly => current.AddYears(1),
_ => DateTime.MaxValue
};
}