From b6fbecb4fbe60338015e6c51e0cac3b6c18810c0 Mon Sep 17 00:00:00 2001 From: Paul Howes Date: Fri, 10 Sep 2021 16:07:07 +0100 Subject: [PATCH] Still allow completed records to be deleted --- .../WhenIRemoveALegalEntity.cs | 17 ----------------- .../RemoveLegalEntityCommandHandler.cs | 2 +- .../GetAccountLegalEntityRemoveQueryHandler.cs | 1 - 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Commands/RemoveLegalEntityTests/WhenIRemoveALegalEntity.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Commands/RemoveLegalEntityTests/WhenIRemoveALegalEntity.cs index 0bd3758983..8e2628ddb5 100644 --- a/src/SFA.DAS.EmployerAccounts.UnitTests/Commands/RemoveLegalEntityTests/WhenIRemoveALegalEntity.cs +++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Commands/RemoveLegalEntityTests/WhenIRemoveALegalEntity.cs @@ -243,23 +243,6 @@ public async Task ThenTheAgreementIsCheckedToSeeIfItHasBeenSignedAndHasActiveCom Assert.ThrowsAsync(() => _handler.Handle(_command)); } - [Test] - public async Task ThenTheAgreementIsCheckedToSeeIfItHasBeenSignedAndHasCompletedCommitments() - { - _commitmentsApi - .Setup(x => x.GetEmployerAccountSummary(ExpectedAccountId)) - .ReturnsAsync(new List - { - new ApprenticeshipStatusSummary - { - CompletedCount = 1, - LegalEntityIdentifier = _expectedAgreement.LegalEntityCode - } - }); - - Assert.ThrowsAsync(() => _handler.Handle(_command)); - } - [Test] public async Task ThenTheAgreementIsCheckedToSeeIfItHasBeenSignedAndHasWithdrawnCommitments() { diff --git a/src/SFA.DAS.EmployerAccounts/Commands/RemoveLegalEntity/RemoveLegalEntityCommandHandler.cs b/src/SFA.DAS.EmployerAccounts/Commands/RemoveLegalEntity/RemoveLegalEntityCommandHandler.cs index e3800a7831..ad09af67e2 100644 --- a/src/SFA.DAS.EmployerAccounts/Commands/RemoveLegalEntity/RemoveLegalEntityCommandHandler.cs +++ b/src/SFA.DAS.EmployerAccounts/Commands/RemoveLegalEntity/RemoveLegalEntityCommandHandler.cs @@ -125,7 +125,7 @@ private async Task ValidateLegalEntityHasNoCommitments(EmployerAgreementView agr && c.LegalEntityIdentifier.Equals(agreement.LegalEntityCode) && c.LegalEntityOrganisationType == agreement.LegalEntitySource); - if (commitment != null && (commitment.ActiveCount + commitment.PausedCount + commitment.PendingApprovalCount + commitment.CompletedCount + commitment.WithdrawnCount) != 0) + if (commitment != null && (commitment.ActiveCount + commitment.PausedCount + commitment.PendingApprovalCount + commitment.WithdrawnCount) != 0) { validationResult.AddError(nameof(agreement.HashedAgreementId), "Agreement has already been signed and has active commitments"); throw new InvalidRequestException(validationResult.ValidationDictionary); diff --git a/src/SFA.DAS.EmployerAccounts/Queries/GetAccountLegalEntityRemove/GetAccountLegalEntityRemoveQueryHandler.cs b/src/SFA.DAS.EmployerAccounts/Queries/GetAccountLegalEntityRemove/GetAccountLegalEntityRemoveQueryHandler.cs index ec549532d2..5bee6daeab 100644 --- a/src/SFA.DAS.EmployerAccounts/Queries/GetAccountLegalEntityRemove/GetAccountLegalEntityRemoveQueryHandler.cs +++ b/src/SFA.DAS.EmployerAccounts/Queries/GetAccountLegalEntityRemove/GetAccountLegalEntityRemoveQueryHandler.cs @@ -84,7 +84,6 @@ private async Task SetRemovedStatusBasedOnCommitments(long accountId, Acco return commitmentConnectedToEntity == null || (commitmentConnectedToEntity.ActiveCount + commitmentConnectedToEntity.PendingApprovalCount + - commitmentConnectedToEntity.CompletedCount + commitmentConnectedToEntity.WithdrawnCount + commitmentConnectedToEntity.PausedCount) == 0; }