Updates
This commit is contained in:
1 parent
9faa49daa1
commit
08eefe2973
20 files changed
+572
-142
No files matched your search
@@ -0,0 +1,8 @@
|
||||
namespace BudgetApp.Services;
|
||||
|
||||
public sealed class ToastService
|
||||
{
|
||||
public event Action<string>? OnShow;
|
||||
|
||||
public void Show(string message) => OnShow?.Invoke(message);
|
||||
}
|
||||
@@ -116,14 +116,43 @@ public class TransactionService(ApplicationDbContext db)
|
||||
|
||||
if (transaction is null) return;
|
||||
|
||||
var isPartOfSeries = transaction.RecurrenceType != RecurrenceType.None
|
||||
|| transaction.ParentTransactionId is not null;
|
||||
|
||||
transaction.Description = description;
|
||||
transaction.Amount = amount;
|
||||
transaction.Date = date;
|
||||
transaction.Type = type;
|
||||
transaction.AccountId = accountId;
|
||||
transaction.CategoryId = categoryId;
|
||||
transaction.RecurrenceType = recurrenceType;
|
||||
transaction.RecurrenceEndDate = recurrenceEndDate;
|
||||
|
||||
if (isPartOfSeries)
|
||||
{
|
||||
// Cascade edits to all future occurrences in the series
|
||||
var parentId = transaction.ParentTransactionId ?? transaction.Id;
|
||||
var cutoffDate = transaction.Date.Date;
|
||||
|
||||
var futureSiblings = await _db.Transactions
|
||||
.Where(t => (t.Id == parentId || t.ParentTransactionId == parentId)
|
||||
&& t.Id != id
|
||||
&& t.Date.Date >= cutoffDate)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var sibling in futureSiblings)
|
||||
{
|
||||
sibling.Description = description;
|
||||
sibling.Amount = amount;
|
||||
sibling.Type = type;
|
||||
sibling.AccountId = accountId;
|
||||
sibling.CategoryId = categoryId;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Standalone transaction — preserve existing recurrence state (None)
|
||||
transaction.RecurrenceType = recurrenceType;
|
||||
transaction.RecurrenceEndDate = recurrenceEndDate;
|
||||
}
|
||||
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user