diff --git a/Repository/BudgetRepository.cs b/Repository/BudgetRepository.cs index 377ce2a..deeaae9 100644 --- a/Repository/BudgetRepository.cs +++ b/Repository/BudgetRepository.cs @@ -3,6 +3,8 @@ public interface IBudgetRepository : IBaseRepository { Task GetCurrentAmountAsync(BudgetRecord budget, DateTime startDate, DateTime endDate); + + Task UpdateBudgetCategoryNameAsync(string oldName, string newName, TransactionType type); } public class BudgetRepository(IFreeSql freeSql) : BaseRepository(freeSql), IBudgetRepository @@ -33,4 +35,31 @@ public class BudgetRepository(IFreeSql freeSql) : BaseRepository(f return await query.SumAsync(t => t.Amount); } + + public async Task UpdateBudgetCategoryNameAsync(string oldName, string newName, TransactionType type) + { + var records = await FreeSql.Select() + .Where(b => b.SelectedCategories.Contains(oldName) && + ((type == TransactionType.Expense && b.Category == BudgetCategory.Expense) || + (type == TransactionType.Income && b.Category == BudgetCategory.Income) || + (type == TransactionType.None && b.Category == BudgetCategory.Savings))) + .ToListAsync(); + + foreach (var record in records) + { + var categories = record.SelectedCategories.Split(',').ToList(); + for (int i = 0; i < categories.Count; i++) + { + if (categories[i] == oldName) + { + categories[i] = newName; + } + } + record.SelectedCategories = string.Join(',', categories); + } + + await FreeSql.Update() + .SetSource(records) + .ExecuteAffrowsAsync(); + } } diff --git a/Web/src/components/Bill/BillForm.vue b/Web/src/components/Bill/BillForm.vue index b05ee4d..5d4fbd6 100644 --- a/Web/src/components/Bill/BillForm.vue +++ b/Web/src/components/Bill/BillForm.vue @@ -90,7 +90,7 @@ /> - + - + diff --git a/Web/src/components/PopupContainer.vue b/Web/src/components/PopupContainer.vue index d7cc4c4..a9e3e6c 100644 --- a/Web/src/components/PopupContainer.vue +++ b/Web/src/components/PopupContainer.vue @@ -6,6 +6,7 @@ :style="{ height: height }" round :closeable="closeable" + teleport="body" >