From 254d07e096747c6cca2f9c13ebcb8cb0ae257805 Mon Sep 17 00:00:00 2001 From: britto Date: Mon, 11 Dec 2023 13:08:34 -0500 Subject: [PATCH] Always choose max id + 1 as the next id --- NickvisionMoney.Shared/Models/Account.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NickvisionMoney.Shared/Models/Account.cs b/NickvisionMoney.Shared/Models/Account.cs index 55df4df45..8f551c651 100644 --- a/NickvisionMoney.Shared/Models/Account.cs +++ b/NickvisionMoney.Shared/Models/Account.cs @@ -1012,7 +1012,10 @@ public async Task DeleteTransactionAsync(uint id) Transactions.Remove(id); if (id + 1 == NextAvailableTransactionId) { - NextAvailableTransactionId--; + if(Transactions.Count == 0) + NextAvailableTransactionId = 1; + else + NextAvailableTransactionId = Transactions.Max(x => x.Key) + 1; } BackupAccountToCSV(); return true;