Skip to content

Commit

Permalink
Merge pull request #586 from SkillsFundingAgency/CV-381-Fix-Issue-Wit…
Browse files Browse the repository at this point in the history
…hParty-TransferSender

Fixes issue where cohort is with transfer sender but not identified a…
  • Loading branch information
CThomp2018 authored Oct 21, 2019
2 parents e226f90 + f4b3b86 commit 6460fa6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,19 @@ public void AndPartyIsTransferSenderAndHasNoDraftApprenticeshipsAndCohortIsFunde

_fixture.Invoking(f => f.Approve()).Should().Throw<DomainException>();
}


[Test]
public void AndPartyIsEmployerAndCohortWasRejectedByTransferSenderThenShouldResetTransferApprovalStatus()
{
_fixture.SetModifyingParty(Party.Employer)
.SetEditStatus(Party.Employer.ToEditStatus())
.AddDraftApprenticeship(AgreementStatus.EmployerAgreed)
.SetTransferApprovalStatus(TransferApprovalStatus.Rejected)
.Approve();

_fixture.Cohort.TransferApprovalStatus.Should().BeNull();
}
}

public class WhenApprovingCohortFixture
Expand Down Expand Up @@ -291,6 +304,11 @@ public WhenApprovingCohortFixture SetEditStatus(EditStatus editStatus)

return this;
}
public WhenApprovingCohortFixture SetTransferApprovalStatus(TransferApprovalStatus status)
{
Cohort.Set(x => x.TransferApprovalStatus, status);
return this;
}

public WhenApprovingCohortFixture SetLastAction(LastAction lastAction)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ public void ThenShouldResetApprovals()
_fixture.Cohort.Apprenticeships.Should().HaveCount(2)
.And.Subject.All(a => a.AgreementStatus == AgreementStatus.NotAgreed).Should().BeTrue();
}

[Test]
public void ThenShouldResetTransferApprovalStatus()
{
_fixture.SetModifyingParty(Party.Employer)
.SetEditStatus(Party.Employer.ToEditStatus())
.AddDraftApprenticeship(AgreementStatus.EmployerAgreed)
.SetTransferApprovalStatus(TransferApprovalStatus.Rejected)
.SendToOtherParty();

_fixture.Cohort.TransferApprovalStatus.Should().BeNull();
}
}

public class WhenSendingCohortToOtherPartyTestsFixture
Expand Down Expand Up @@ -169,6 +181,12 @@ public WhenSendingCohortToOtherPartyTestsFixture AddDraftApprenticeship(Agreemen
return this;
}

public WhenSendingCohortToOtherPartyTestsFixture SetTransferApprovalStatus(TransferApprovalStatus status)
{
Cohort.Set(x => x.TransferApprovalStatus, status);
return this;
}

public WhenSendingCohortToOtherPartyTestsFixture SetEditStatus(EditStatus editStatus)
{
Cohort.Set(c => c.EditStatus, editStatus);
Expand Down
4 changes: 3 additions & 1 deletion src/CommitmentsV2/SFA.DAS.CommitmentsV2/Models/Cohort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Party WithParty
return Party.Employer;
case EditStatus.ProviderOnly:
return Party.Provider;
case EditStatus.Both when TransferSenderId != null && TransferApprovalStatus == Types.TransferApprovalStatus.Pending:
case EditStatus.Both when TransferSenderId != null && TransferApprovalStatus != Types.TransferApprovalStatus.Approved:
return Party.TransferSender;
default:
return Party.None;
Expand Down Expand Up @@ -156,6 +156,7 @@ public void Approve(Party modifyingParty, string message, UserInfo userInfo, Dat
EditStatus = isApprovedByOtherParty ? EditStatus.Both : otherParty.ToEditStatus();
LastAction = LastAction.Approve;
CommitmentStatus = CommitmentStatus.Active;
TransferApprovalStatus = null;
DraftApprenticeships.ForEach(a => a.Approve(modifyingParty, now));
AddMessage(message, modifyingParty, userInfo);
UpdatedBy(modifyingParty, userInfo);
Expand Down Expand Up @@ -197,6 +198,7 @@ public void SendToOtherParty(Party modifyingParty, string message, UserInfo user
EditStatus = modifyingParty.GetOtherParty().ToEditStatus();
LastAction = LastAction.Amend;
CommitmentStatus = CommitmentStatus.Active;
TransferApprovalStatus = null;
AddMessage(message, modifyingParty, userInfo);
UpdatedBy(modifyingParty, userInfo);

Expand Down

0 comments on commit 6460fa6

Please sign in to comment.