diff --git a/OpenBudgeteer.Core/ViewModels/PageViewModels/DataConsistencyPageViewModel.cs b/OpenBudgeteer.Core/ViewModels/PageViewModels/DataConsistencyPageViewModel.cs index b478806..6cac987 100644 --- a/OpenBudgeteer.Core/ViewModels/PageViewModels/DataConsistencyPageViewModel.cs +++ b/OpenBudgeteer.Core/ViewModels/PageViewModels/DataConsistencyPageViewModel.cs @@ -36,7 +36,7 @@ public async Task RunAllChecksAsync() { CheckTransferReconciliationAsync(), CheckBucketBalanceAsync(), - CheckBankTransactionWithoutBucketAssignmentAsync(), + CheckBankTransactionIncompleteBucketAssignmentAsync(), CheckBudgetedTransactionOutsideOfValidityDateAsync(), CheckNegativeBankTransactionAssignedToIncomeAsync() }; @@ -125,20 +125,23 @@ public async Task CheckBucketBalanceAsync() } /// - /// Checks if there is any which doesn't have a assigned + /// Checks if there is any which are not fully assigned to a /// /// Result of Data Consistency Check - public async Task CheckBankTransactionWithoutBucketAssignmentAsync() + public async Task CheckBankTransactionIncompleteBucketAssignmentAsync() { return await Task.Run(async () => { - const string checkName = "Transactions without Bucket assignment"; + const string checkName = "Transactions with incomplete bucket assignment"; var results = new List>(); var checkTasks = ServiceManager.BankTransactionService .GetAll() .Select(bankTransaction => Task.Run(() => { - if (!ServiceManager.BudgetedTransactionService.GetAllFromTransaction(bankTransaction.Id).Any()) + var budgetedTransactions = + ServiceManager.BudgetedTransactionService.GetAllFromTransaction(bankTransaction.Id).ToList(); + var budgetedAmount = budgetedTransactions.Select(x => x.Amount).Sum(); + if (!budgetedTransactions.Any() || budgetedAmount != bankTransaction.Amount) { results.Add(new( DataConsistencyCheckResult.StatusCode.Warning, @@ -146,7 +149,8 @@ public async Task CheckBankTransactionWithoutBucketA { bankTransaction.TransactionDate.ToShortDateString(), bankTransaction.Memo ?? string.Empty, - bankTransaction.Amount.ToString("C", CultureInfo.CurrentCulture) + bankTransaction.Amount.ToString("C", CultureInfo.CurrentCulture), + budgetedAmount.ToString("C", CultureInfo.CurrentCulture) })); } })) @@ -159,13 +163,13 @@ public async Task CheckBankTransactionWithoutBucketA return new DataConsistencyCheckResult( checkName, DataConsistencyCheckResult.StatusCode.Ok, - "All Transactions are assigned to at least one Bucket", + "All Transactions are fully assigned to at least one Bucket", new List()); } var detailsBuilder = new List { - new[] { "Transaction Date", "Memo", "Amount" } + new[] { "Transaction Date", "Memo", "Amount", "Budgeted" } }; detailsBuilder.AddRange(results @@ -175,7 +179,7 @@ public async Task CheckBankTransactionWithoutBucketA return new DataConsistencyCheckResult( checkName, DataConsistencyCheckResult.StatusCode.Warning, - "Some Transactions do not have any Bucket assigned", + "Some Transactions are not fully assigned", detailsBuilder); }); }