Skip to content

Commit

Permalink
Merge pull request #880 from DFE-Digital/feature/182793
Browse files Browse the repository at this point in the history
Feature/182793
  • Loading branch information
sukhybhullar-nimble authored Oct 7, 2024
2 parents f53ea46 + ec3a641 commit c4435e2
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static Kpi BuildProject()
result.ProjectStatusUrnWhenGivenOne = _fixture.Create<string>();
result.ProjectStatusFreeSchoolApplicationWave = _fixture.Create<string>();
result.ProjectStatusRealisticYearOfOpening = _fixture.Create<string>();
result.RyooWd = result.ProjectStatusRealisticYearOfOpening;
result.ProjectStatusDateOfEntryIntoPreOpening = _fixture.Create<DateTime>();
result.ProjectStatusProvisionalOpeningDateAgreedWithTrust = _fixture.Create<DateTime>();
result.ProjectStatusActualOpeningDate = _fixture.Create<DateTime>();
Expand Down Expand Up @@ -83,8 +84,8 @@ public static Kpi BuildProjectMandatoryFieldsOnly()
UpperStatus = _fixture.Create<string>().Substring(0, 10),
FsType = _fixture.Create<string>().Substring(0, 13),
FsType1 = _fixture.Create<string>().Substring(0, 15),
MatUnitProjects = _fixture.Create<string>().Substring(0, 31),
SponsorUnitProjects = _fixture.Create<string>()
MatUnitProjects = "Other",
SponsorUnitProjects = "Free Schools (including Studio Schools)"
};

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public async Task When_CreateProject_Returns_NewProjectFields_201(ProjectType pr
createdProject.UpperStatus.Should().BeEmpty();
createdProject.FsType.Should().BeEmpty();
createdProject.FsType1.Should().BeEmpty();
createdProject.MatUnitProjects.Should().BeEmpty();
createdProject.SponsorUnitProjects.Should().BeEmpty();
createdProject.MatUnitProjects.Should().Be("Other");
createdProject.SponsorUnitProjects.Should().Be("Free Schools (including Studio Schools)");
createdProject.SchoolDetailsGeographicalRegion.Should().Be(projectDetails.Region);
createdProject.SchoolDetailsLocalAuthority.Should().Be(projectDetails.LocalAuthorityCode);
createdProject.LocalAuthority.Should().Be(projectDetails.LocalAuthority);
Expand Down Expand Up @@ -118,6 +118,8 @@ public async Task When_CreateProject_Returns_NewProjectFields_201(ProjectType pr
createdProject.ProjectStatusFreeSchoolsApplicationNumber.Should().BeEmpty();
createdProject.Wave.Should().Be("FS - Presumption");
}

createdProject.RyooWd.Should().Be("Awaiting Year");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks;
using Dfe.ManageFreeSchoolProjects.API.Tests.Fixtures;
using Dfe.ManageFreeSchoolProjects.API.Tests.Helpers;
using Dfe.ManageFreeSchoolProjects.API.Constants;
using System.Threading.Tasks;
using System;
using System.Linq;

namespace Dfe.ManageFreeSchoolProjects.API.Tests.Integration.Tasks
{
Expand Down Expand Up @@ -44,6 +46,47 @@ public async Task Patch_DatesTask_Returns_201()
projectResponse.Dates.ProjectClosedDate.Should().Be(DateTenDaysInFuture);
projectResponse.Dates.RealisticYearOfOpening.Should().Be(request.Dates.RealisticYearOfOpening);
projectResponse.SchoolName.Should().Be(project.ProjectStatusCurrentFreeSchoolName);

using var contextPostSave = _testFixture.GetContext();
var updatedProject = contextPostSave.Kpi.First(p => p.ProjectStatusProjectId == projectId);
updatedProject.RyooWd.Should().Be(request.Dates.RealisticYearOfOpening);
}

[Fact]
public async Task Patch_DatesTask_NoRYOOSetsDefaultValue()
{
var project = DatabaseModelBuilder.BuildProject();
var projectId = project.ProjectStatusProjectId;

using var context = _testFixture.GetContext();
context.Kpi.Add(project);
await context.SaveChangesAsync();

var DateTenDaysInFuture = new DateTime().AddDays(10);
var DateNineDaysInFuture = new DateTime().AddDays(9);

var request = new UpdateProjectByTaskRequest()
{
Dates = new DatesTask()
{
DateOfEntryIntoPreopening = DateTenDaysInFuture,
ProvisionalOpeningDateAgreedWithTrust = DateNineDaysInFuture,
ProjectClosedDate = DateTenDaysInFuture,
RealisticYearOfOpening = "",
}
};

var projectResponse = await _client.UpdateProjectTask(projectId, request, TaskName.Dates.ToString());

projectResponse.Dates.DateOfEntryIntoPreopening.Should().Be(DateTenDaysInFuture);
projectResponse.Dates.ProvisionalOpeningDateAgreedWithTrust.Should().Be(DateNineDaysInFuture);
projectResponse.Dates.ProjectClosedDate.Should().Be(DateTenDaysInFuture);
projectResponse.Dates.RealisticYearOfOpening.Should().Be(request.Dates.RealisticYearOfOpening);
projectResponse.SchoolName.Should().Be(project.ProjectStatusCurrentFreeSchoolName);

using var contextPostSave = _testFixture.GetContext();
var updatedProject = contextPostSave.Kpi.First(p => p.ProjectStatusProjectId == projectId);
updatedProject.RyooWd.Should().Be(ProjectConstants.RYOODefaultValue);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks;
using Dfe.ManageFreeSchoolProjects.API.Tests.Fixtures;
using Dfe.ManageFreeSchoolProjects.API.Tests.Helpers;
using Dfe.ManageFreeSchoolProjects.API.Constants;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace Dfe.ManageFreeSchoolProjects.API.Tests.Integration.Tasks
Expand Down Expand Up @@ -42,6 +44,10 @@ public async Task Patch_NewKickOffMeeting_Returns_201()
projectResponse.KickOffMeeting.RealisticYearOfOpening.Should().Be(request.KickOffMeeting.RealisticYearOfOpening);
projectResponse.KickOffMeeting.FundingArrangementAgreed.Should().Be(request.KickOffMeeting.FundingArrangementAgreed);
projectResponse.KickOffMeeting.FundingArrangementDetailsAgreed.Should().Be(request.KickOffMeeting.FundingArrangementDetailsAgreed);

using var contextPostSave = _testFixture.GetContext();
var updatedProject = contextPostSave.Kpi.First(p => p.ProjectStatusProjectId == projectId);
updatedProject.RyooWd.Should().Be(request.KickOffMeeting.RealisticYearOfOpening);
}

[Fact]
Expand Down Expand Up @@ -77,6 +83,49 @@ public async Task Patch_ExistingKickOffMeeting_Returns_201()
projectResponse.KickOffMeeting.RealisticYearOfOpening.Should().Be(request.KickOffMeeting.RealisticYearOfOpening);
projectResponse.KickOffMeeting.FundingArrangementAgreed.Should().Be(request.KickOffMeeting.FundingArrangementAgreed);
projectResponse.KickOffMeeting.FundingArrangementDetailsAgreed.Should().Be(request.KickOffMeeting.FundingArrangementDetailsAgreed);

using var contextPostSave = _testFixture.GetContext();
var updatedProject = contextPostSave.Kpi.First(p => p.ProjectStatusProjectId == projectId);
updatedProject.RyooWd.Should().Be(request.KickOffMeeting.RealisticYearOfOpening);
}

[Fact]
public async Task Patch_ExistingKickOffMeeting_NoRYOOSetsDefaultValue()
{
var project = DatabaseModelBuilder.BuildProject();
var projectId = project.ProjectStatusProjectId;

using var context = _testFixture.GetContext();
context.Kpi.Add(project);

var kickOffMeetingTask = DatabaseModelBuilder.BuildKickOffMeetingTask(project.Rid);
context.Milestones.Add(kickOffMeetingTask);

await context.SaveChangesAsync();

var dateNineDaysInFuture = new DateTime().AddDays(9);

var request = new UpdateProjectByTaskRequest()
{
KickOffMeeting = new KickOffMeetingTask()
{
FundingArrangementAgreed = true,
RealisticYearOfOpening = "",
FundingArrangementDetailsAgreed = "text",
SavedDocumentsInWorkplacesFolder = true
}
};

var projectResponse = await _client.UpdateProjectTask(projectId, request, TaskName.KickOffMeeting.ToString());

projectResponse.KickOffMeeting.SavedDocumentsInWorkplacesFolder.Should().Be(request.KickOffMeeting.SavedDocumentsInWorkplacesFolder);
projectResponse.KickOffMeeting.RealisticYearOfOpening.Should().Be(request.KickOffMeeting.RealisticYearOfOpening);
projectResponse.KickOffMeeting.FundingArrangementAgreed.Should().Be(request.KickOffMeeting.FundingArrangementAgreed);
projectResponse.KickOffMeeting.FundingArrangementDetailsAgreed.Should().Be(request.KickOffMeeting.FundingArrangementDetailsAgreed);

using var contextPostSave = _testFixture.GetContext();
var updatedProject = contextPostSave.Kpi.First(p => p.ProjectStatusProjectId == projectId);
updatedProject.RyooWd.Should().Be(ProjectConstants.RYOODefaultValue);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Dfe.ManageFreeSchoolProjects.API.Constants
{
public static class ProjectConstants
{
public const string RYOODefaultValue = "Awaiting Year";
public const string MATUnitProjects = "Other";
public const string SponsorUnitProjects = "Free Schools (including Studio Schools)";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Dfe.ManageFreeSchoolProjects.API.UseCases.Tasks;
using Dfe.ManageFreeSchoolProjects.Data;
using Dfe.ManageFreeSchoolProjects.Data.Entities.Existing;
using Dfe.ManageFreeSchoolProjects.API.Constants;
using Microsoft.EntityFrameworkCore;

namespace Dfe.ManageFreeSchoolProjects.API.UseCases.Project
Expand Down Expand Up @@ -83,6 +84,7 @@ private Po MapToPo(ProjectDetails proj, string rid)

private static Kpi MapToKpi(ProjectDetails proj, string rid, Trust trust)
{

return new Kpi
{
Rid = rid,
Expand All @@ -96,8 +98,8 @@ private static Kpi MapToKpi(ProjectDetails proj, string rid, Trust trust)
UpperStatus = "",
FsType = "",
FsType1 = "",
MatUnitProjects = "",
SponsorUnitProjects = "",
MatUnitProjects = ProjectConstants.MATUnitProjects,
SponsorUnitProjects = ProjectConstants.SponsorUnitProjects,
SchoolDetailsGeographicalRegion = proj.Region,
SchoolDetailsLocalAuthority = proj.LocalAuthorityCode,
LocalAuthority = proj.LocalAuthority,
Expand All @@ -122,6 +124,8 @@ private static Kpi MapToKpi(ProjectDetails proj, string rid, Trust trust)
ProjectStatusProvisionalOpeningDateAgreedWithTrust = proj.ProvisionalOpeningDate,
KeyContactsFsgLeadContact = proj.ProjectAssignedToName,
KeyContactsFsgLeadContactEmail = proj.ProjectAssignedToEmail,
RyooWd = ProjectConstants.RYOODefaultValue

};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DocumentFormat.OpenXml.Drawing;
using Microsoft.IdentityModel.Tokens;
using Dfe.ManageFreeSchoolProjects.API.Constants;

namespace Dfe.ManageFreeSchoolProjects.API.UseCases.Project.Tasks.Dates
{
Expand All @@ -9,6 +10,7 @@ public async Task Update(UpdateTaskServiceParameters parameters)
var dbKpi = parameters.Kpi;
var task = parameters.Request.Dates;


if (task == null)
{
return;
Expand All @@ -20,6 +22,7 @@ public async Task Update(UpdateTaskServiceParameters parameters)
dbKpi.ProjectStatusDateCancelled = task.ProjectCancelledDate;
dbKpi.ProjectStatusDateWithdrawn = task.ProjectWithdrawnDate;
dbKpi.ProjectStatusRealisticYearOfOpening = task.RealisticYearOfOpening;
dbKpi.RyooWd = task.RealisticYearOfOpening.IsNullOrEmpty() ? ProjectConstants.RYOODefaultValue : task.RealisticYearOfOpening;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Dfe.ManageFreeSchoolProjects.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using Dfe.ManageFreeSchoolProjects.API.Constants;

namespace Dfe.ManageFreeSchoolProjects.API.UseCases.Project.Tasks.KickOffMeeting
{
Expand Down Expand Up @@ -32,6 +34,7 @@ public async Task Update(UpdateTaskServiceParameters parameters)
}

dbKpi.ProjectStatusRealisticYearOfOpening = task.RealisticYearOfOpening;
dbKpi.RyooWd = task.RealisticYearOfOpening.IsNullOrEmpty() ? ProjectConstants.RYOODefaultValue : task.RealisticYearOfOpening;
db.FsgPreOpeningMilestonesFundingArrangementAgreedBetweenLaAndSponsor = task.FundingArrangementAgreed;
db.FsgPreOpeningMilestonesDetailsOfFundingArrangementAgreedBetweenLaAndSponsor =
task.FundingArrangementDetailsAgreed;
Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.14.0
* 177717 - Build: Create central route projects
* 178172 - Build: Iterate funding agreement health check and submission
* 182793 - Build: set values for calculated database fields

## 0.13.0
* 147110 - Build: Readiness to open meeting (ROM)
Expand Down

0 comments on commit c4435e2

Please sign in to comment.