This commit is contained in:
rossmill76 committed 2026-03-23 15:05:57 +00:00
1 parent 2bfe914c8f
commit 4281924ee5
16 files changed
+369 -76

No files matched your search

@@ -29,6 +29,27 @@ public class SalaryRepository(ApplicationDbContext db) : ISalaryRepository
await MaterializeSalaryTransactionsAsync(salary.UserId, windowEnd);
}
public async Task UpdateSalaryAsync(Salary salary, DateTime windowEnd, string userId)
{
var existing = await db.Salaries
.FirstOrDefaultAsync(s => s.Id == salary.Id && s.UserId == userId);
if (existing is null) return;
existing.Name = salary.Name;
existing.Amount = salary.Amount;
existing.AccountId = salary.AccountId;
existing.RecurrenceType = salary.RecurrenceType;
existing.StartDate = salary.StartDate;
await db.SaveChangesAsync();
// Delete future unpaid transactions and re-materialise with the updated settings
await db.Transactions
.Where(t => t.SalaryId == salary.Id && t.Date.Date > DateTime.Today && !t.IsPaid)
.ExecuteDeleteAsync();
await MaterializeSalaryTransactionsAsync(userId, windowEnd);
}
public async Task DeleteSalaryAsync(int id, string userId)
{
var exists = await db.Salaries.AnyAsync(s => s.Id == id && s.UserId == userId);