diff --git a/Service/Budget/BudgetSavingsService.cs b/Service/Budget/BudgetSavingsService.cs index e921566..f6620b0 100644 --- a/Service/Budget/BudgetSavingsService.cs +++ b/Service/Budget/BudgetSavingsService.cs @@ -370,10 +370,19 @@ public class BudgetSavingsService( #endregion var savingsCategories = await configService.GetConfigByKeyAsync("SavingsCategories") ?? string.Empty; - var current = monthlyExpenseItems.Sum(item => item.current) - + yearlyExpenseItems.Sum(item => item.current) - - monthlyIncomeItems.Sum(item => item.current) - - yearlyIncomeItems.Sum(item => item.current); + var currentActual = 0m; + if (!string.IsNullOrEmpty(savingsCategories)) + { + var cats = new HashSet(savingsCategories.Split(',', StringSplitOptions.RemoveEmptyEntries)); + foreach(var kvp in transactionClassify) + { + if (cats.Contains(kvp.Key.Item1)) + { + currentActual += kvp.Value; + } + } + } + var record = new BudgetRecord { Id = -2, @@ -391,7 +400,7 @@ public class BudgetSavingsService( return BudgetResult.FromEntity( record, - current, + currentActual, new DateTime(year, month, 1), description.ToString() );