Skip to content

Commit

Permalink
Fix to stop induction records from being created when not required
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKevJoy committed Nov 3, 2023
1 parent f095158 commit c035a74
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,20 @@ public async Task<SetIttResultForTeacherResult> SetIttResultForTeacher(
});
Debug.Assert(teacherStatus != null);

qtsUpdate.dfeta_TeacherStatusId = teacherStatus.Id.ToEntityReference(dfeta_teacherstatus.EntityLogicalName);
qtsUpdate.dfeta_QTSDate = qtsDate.Value.ToDateTime();

txnRequest.Requests.Add(new CreateRequest()
if (!lookupData.Teacher.dfeta_QTSDate.HasValue)
{
Target = new dfeta_induction()
txnRequest.Requests.Add(new CreateRequest()
{
dfeta_PersonId = teacherId.ToEntityReference(Contact.EntityLogicalName),
dfeta_InductionStatus = dfeta_InductionStatus.RequiredtoComplete
}
});
Target = new dfeta_induction()
{
dfeta_PersonId = teacherId.ToEntityReference(Contact.EntityLogicalName),
dfeta_InductionStatus = dfeta_InductionStatus.RequiredtoComplete
}
});
}

qtsUpdate.dfeta_TeacherStatusId = teacherStatus.Id.ToEntityReference(dfeta_teacherstatus.EntityLogicalName);
qtsUpdate.dfeta_QTSDate = qtsDate.Value.ToDateTime();
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,35 @@ await _organizationService.ExecuteAsync(new UpdateRequest()
Assert.Equal(SetIttResultForTeacherFailedReason.NoMatchingIttRecord, result.FailedReason);
}

[Fact]
public async Task Given_valid_request_with_existing_qts_date_do_not_recreate_induction_record()
{
// Arrange
var createPersonResult = await _testDataHelper.CreatePerson(earlyYears: false, false, iqts: true);

var ittResult = dfeta_ITTResult.Pass;
var assessmentDate = _clock.Today;
var teacherStatusId = (await _dataverseAdapter.GetTeacherStatus("90", null)).Id;

// Act
var (result, _) = await _dataverseAdapter.SetIttResultForTeacherImpl(
createPersonResult.TeacherId,
createPersonResult.IttProviderUkprn,
ittResult,
assessmentDate);

var (result2, transactionRequest2) = await _dataverseAdapter.SetIttResultForTeacherImpl(
createPersonResult.TeacherId,
createPersonResult.IttProviderUkprn,
ittResult,
assessmentDate);

// Assert
Assert.True(result.Succeeded);
Assert.True(result2.Succeeded);
transactionRequest2.AssertDoesNotContainCreateRequest<dfeta_induction>();
}

public static class SelectIttRecordTestData
{
public static readonly Guid TeacherId = Guid.NewGuid();
Expand Down

0 comments on commit c035a74

Please sign in to comment.