Skip to content

Commit

Permalink
Merge pull request #2205 from SkillsFundingAgency/CON-3854---Organisa…
Browse files Browse the repository at this point in the history
…tion-can-be-deleted

CON-3854 - Organisation can be deleted
  • Loading branch information
reachash authored Sep 13, 2021
2 parents 9bf6c8e + b6fbecb commit 69465b7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ public void Arrange()
{
new ApprenticeshipStatusSummary
{
ActiveCount = 0,PausedCount = 0,PendingApprovalCount = 0,LegalEntityIdentifier = _expectedAgreement.LegalEntityCode
ActiveCount = 0,
PausedCount = 0,
PendingApprovalCount = 0,
CompletedCount = 0,
LegalEntityIdentifier = _expectedAgreement.LegalEntityCode
}
});

Expand Down Expand Up @@ -229,7 +233,27 @@ public async Task ThenTheAgreementIsCheckedToSeeIfItHasBeenSignedAndHasActiveCom
{
new ApprenticeshipStatusSummary
{
ActiveCount = 1,PausedCount = 1,PendingApprovalCount = 1,LegalEntityIdentifier = _expectedAgreement.LegalEntityCode
ActiveCount = 1,
PausedCount = 1,
PendingApprovalCount = 1,
LegalEntityIdentifier = _expectedAgreement.LegalEntityCode
}
});

Assert.ThrowsAsync<InvalidRequestException>(() => _handler.Handle(_command));
}

[Test]
public async Task ThenTheAgreementIsCheckedToSeeIfItHasBeenSignedAndHasWithdrawnCommitments()
{
_commitmentsApi
.Setup(x => x.GetEmployerAccountSummary(ExpectedAccountId))
.ReturnsAsync(new List<ApprenticeshipStatusSummary>
{
new ApprenticeshipStatusSummary
{
WithdrawnCount = 1,
LegalEntityIdentifier = _expectedAgreement.LegalEntityCode
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) != 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public HashingRegistry()
.Ctor<IHashingService>()
.Is(c =>
new HashingService.HashingService(
c.GetInstance<EmployerAccountsConfiguration>() .PublicAllowedAccountLegalEntityHashstringCharacters,
c.GetInstance<EmployerAccountsConfiguration>().PublicAllowedAccountLegalEntityHashstringCharacters,
c.GetInstance<EmployerAccountsConfiguration>().PublicAllowedAccountLegalEntityHashstringSalt));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private async Task<bool> SetRemovedStatusBasedOnCommitments(long accountId, Acco

return commitmentConnectedToEntity == null || (commitmentConnectedToEntity.ActiveCount +
commitmentConnectedToEntity.PendingApprovalCount +
commitmentConnectedToEntity.WithdrawnCount +
commitmentConnectedToEntity.PausedCount) == 0;
}
}
Expand Down

0 comments on commit 69465b7

Please sign in to comment.