From 0377098c4b73e1acd7662e83ad660f0a4126b4e4 Mon Sep 17 00:00:00 2001 From: Nick Logozzo Date: Tue, 17 Jan 2023 16:59:36 -0500 Subject: [PATCH] Shared - Fix Repeat Transactions --- NickvisionMoney.Shared/Models/Account.cs | 35 +++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/NickvisionMoney.Shared/Models/Account.cs b/NickvisionMoney.Shared/Models/Account.cs index fde625819..cf2a06100 100644 --- a/NickvisionMoney.Shared/Models/Account.cs +++ b/NickvisionMoney.Shared/Models/Account.cs @@ -713,14 +713,15 @@ public async Task UpdateSourceTransactionAsync(Transaction transaction, bool upd { if (t.RepeatFrom == (int)transaction.Id) { - t.Description = transaction.Description; - t.Type = transaction.Type; - t.Amount = transaction.Amount; - t.GroupId = transaction.GroupId; - t.RGBA = transaction.RGBA; - t.Receipt = transaction.Receipt; - t.RepeatEndDate = transaction.RepeatEndDate; - await UpdateTransactionAsync(t); + var tt = (Transaction)t.Clone(); + tt.Description = transaction.Description; + tt.Type = transaction.Type; + tt.Amount = transaction.Amount; + tt.GroupId = transaction.GroupId; + tt.RGBA = transaction.RGBA; + tt.Receipt = transaction.Receipt; + tt.RepeatEndDate = transaction.RepeatEndDate; + await UpdateTransactionAsync(tt); } } await UpdateTransactionAsync(transaction); @@ -731,10 +732,11 @@ public async Task UpdateSourceTransactionAsync(Transaction transaction, bool upd { if (t.RepeatFrom == (int)transaction.Id) { - t.RepeatInterval = TransactionRepeatInterval.Never; - t.RepeatFrom = -1; - t.RepeatEndDate = null; - await UpdateTransactionAsync(t); + var tt = (Transaction)t.Clone(); + tt.RepeatInterval = TransactionRepeatInterval.Never; + tt.RepeatFrom = -1; + tt.RepeatEndDate = null; + await UpdateTransactionAsync(tt); } } await UpdateTransactionAsync(transaction); @@ -805,10 +807,11 @@ public async Task DeleteSourceTransactionAsync(uint id, bool deleteGenerated) { if(transaction.RepeatFrom == (int)id) { - transaction.RepeatInterval = TransactionRepeatInterval.Never; - transaction.RepeatFrom = -1; - transaction.RepeatEndDate = null; - await UpdateTransactionAsync(transaction); + var t = (Transaction)transaction.Clone(); + t.RepeatInterval = TransactionRepeatInterval.Never; + t.RepeatFrom = -1; + t.RepeatEndDate = null; + await UpdateTransactionAsync(t); } } }