From 0f7d472c6458002f13afc831cf7866599fb21a43 Mon Sep 17 00:00:00 2001 From: Elijah Aremu <45821029+elielijah321@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:43:12 +0000 Subject: [PATCH 1/5] update grant calculation implementation + add values to document generator --- .../Models/HtbTemplate.cs | 27 ++++++++++++++++++- .../Sponsored/GrantDetails.cshtml | 2 +- ...UpdateAcademyConversionProjectPageModel.cs | 24 ++++++++++++----- ...rustInformationAndProjectDatesGenerator.cs | 22 +++++++++++++++ .../SchoolOverviewGenerator.cs | 13 +++++++++ .../Utils/SchoolOverviewHelper.cs | 23 ++++++++++++++++ .../SchoolOverviewViewComponent.cs | 25 ++--------------- 7 files changed, 104 insertions(+), 32 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/HtbTemplate.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/HtbTemplate.cs index 7a833d12d..a68b48954 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/HtbTemplate.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/HtbTemplate.cs @@ -2,6 +2,7 @@ using Dfe.PrepareConversions.Data.Models; using Dfe.PrepareConversions.Data.Models.KeyStagePerformance; using Dfe.PrepareConversions.DocumentGeneration; +using Dfe.PrepareConversions.Utils; using Dfe.PrepareConversions.ViewModels; using System; using System.Collections.Generic; @@ -136,6 +137,24 @@ public class HtbTemplate [DocumentText("MemberOfParliamentNameAndParty")] public string MemberOfParliamentNameAndParty { get; set; } + [DocumentText("PupilsAttendingGroup")] + public string PupilsAttendingGroup { get; set; } + + [DocumentText("NumberOfAlternativeProvisionPlaces")] + public string NumberOfAlternativeProvisionPlaces { get; set; } + + [DocumentText("NumberOfMedicalPlaces")] + public string NumberOfMedicalPlaces { get; set; } + + [DocumentText("NumberOfPost16Places")] + public string NumberOfPost16Places { get; set; } + + [DocumentText("NumberOfSENUnitPlaces")] + public string NumberOfSENUnitPlaces { get; set; } + + [DocumentText("ConversionSupportGrantNumberOfSites")] + public string ConversionSupportGrantNumberOfSites { get; set; } + // rationale [DocumentText("RationaleForProject")] public string RationaleForProject { get; set; } @@ -294,7 +313,13 @@ public static HtbTemplate Build(AcademyConversionProject project, YearThreeProjectedPupilNumbers = project.YearThreeProjectedPupilNumbers.ToString(), YearThreePercentageSchoolFull = project.YearThreeProjectedPupilNumbers.AsPercentageOf(project.YearThreeProjectedCapacity), SchoolPupilForecastsAdditionalInformation = project.SchoolPupilForecastsAdditionalInformation, - SchoolPerformance = schoolPerformance + SchoolPerformance = schoolPerformance, + PupilsAttendingGroup = SchoolOverviewHelper.MapPupilsAttendingGroup(project.PupilsAttendingGroupPermanentlyExcluded, project.PupilsAttendingGroupMedicalAndHealthNeeds, project.PupilsAttendingGroupTeenageMums), + ConversionSupportGrantNumberOfSites = project.ConversionSupportGrantNumberOfSites, + NumberOfAlternativeProvisionPlaces = project.NumberOfAlternativeProvisionPlaces?.ToString(), + NumberOfSENUnitPlaces = project.NumberOfSENUnitPlaces?.ToString(), + NumberOfMedicalPlaces = project.NumberOfMedicalPlaces?.ToString(), + NumberOfPost16Places = project.NumberOfPost16Places?.ToString() }; if (keyStagePerformance.HasKeyStage2PerformanceTables) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/Sponsored/GrantDetails.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/Sponsored/GrantDetails.cshtml index 3ad48e9ff..ca1c9a1c2 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/Sponsored/GrantDetails.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/Sponsored/GrantDetails.cshtml @@ -34,7 +34,7 @@
- +
diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/UpdateAcademyConversionProjectPageModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/UpdateAcademyConversionProjectPageModel.cs index 263a8ae2e..e7ff15f10 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/UpdateAcademyConversionProjectPageModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/UpdateAcademyConversionProjectPageModel.cs @@ -91,13 +91,9 @@ private void RePopDatePickerModelsAfterValidationFail() Project.LocalAuthorityInformationTemplateSentDate = AcademyConversionProject.LocalAuthorityInformationTemplateSentDate; Project.LocalAuthorityInformationTemplateReturnedDate = AcademyConversionProject.LocalAuthorityInformationTemplateReturnedDate; } - public static decimal? CalculateGrantAmount(string type, string phase, string numberOfSites = "1") + public static decimal? CalculateGrantAmount(string type, string phase) { int defaultAmount = 25000; - int supplementAmount = CalculateGrantSupplement(numberOfSites); - - defaultAmount += supplementAmount; - if (phase is null) return defaultAmount; switch (phase.ToLower()) { @@ -107,7 +103,7 @@ private void RePopDatePickerModelsAfterValidationFail() SponsoredGrantType.FastTrack => 70000, SponsoredGrantType.Full => 110000, SponsoredGrantType.Intermediate => 90000, - _ => 25000 + _ => defaultAmount }; case "secondary": return type switch @@ -115,7 +111,7 @@ private void RePopDatePickerModelsAfterValidationFail() SponsoredGrantType.FastTrack => 80000, SponsoredGrantType.Full => 150000, SponsoredGrantType.Intermediate => 115000, - _ => 25000 + _ => defaultAmount }; } @@ -123,6 +119,20 @@ private void RePopDatePickerModelsAfterValidationFail() return defaultAmount; } + public static decimal? CalculatePRUGrantAmount(string type, string numberOfSites = "1") + { + int defaultAmount = 25000; + int supplementAmount = CalculateGrantSupplement(numberOfSites); + + return type switch + { + SponsoredGrantType.FastTrack => 70000 + supplementAmount, + SponsoredGrantType.Full => 110000 + supplementAmount, + SponsoredGrantType.Intermediate => 90000 + supplementAmount, + _ => defaultAmount + supplementAmount + }; + } + protected UpdateAcademyConversionProject Build() { return new UpdateAcademyConversionProject diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolAndTrustInformationAndProjectDatesGenerator.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolAndTrustInformationAndProjectDatesGenerator.cs index 7679ce49c..cab39a63d 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolAndTrustInformationAndProjectDatesGenerator.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolAndTrustInformationAndProjectDatesGenerator.cs @@ -118,6 +118,17 @@ private static List VoluntaryRouteInfo(AcademyConversionProject p new TextElement { Value = project.AcademyOrderRequired } }, }; + + if (project.SchoolType.ToLower().Contains("pupil referral unit")) + { + voluntaryRouteInfo.Add(new[] + { + new TextElement { Value = "Number of sites", Bold = true }, + new TextElement { Value = project.ConversionSupportGrantNumberOfSites} + } + ); + } + return voluntaryRouteInfo; } @@ -166,6 +177,17 @@ private static List SponsoredRouteInfo(AcademyConversionProject p new TextElement { Value = project.DaoPackSentDate.ToDateString() } }, }; + + if (project.SchoolType.ToLower().Contains("pupil referral unit")) + { + sponsoredRouteInfo.Add(new[] + { + new TextElement { Value = "Number of sites", Bold = true }, + new TextElement { Value = project.ConversionSupportGrantNumberOfSites} + } + ); + } + return sponsoredRouteInfo; } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolOverviewGenerator.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolOverviewGenerator.cs index 1e0a1d504..fe1eb3732 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolOverviewGenerator.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolOverviewGenerator.cs @@ -1,6 +1,7 @@ using Dfe.PrepareConversions.DocumentGeneration.Elements; using Dfe.PrepareConversions.DocumentGeneration.Interfaces; using Dfe.PrepareConversions.Models; +using Dfe.PrepareConversions.Utils; using System.Collections.Generic; namespace Dfe.PrepareConversions.Services.DocumentGenerator @@ -28,6 +29,18 @@ public static void AddSchoolOverview(IDocumentBuilder builder, HtbTemplate docum }, new[] { new TextElement { Value = "Viability issues", Bold = true }, new TextElement { Value = document.ViabilityIssues } }}); + if (document.SchoolType.ToLower().Contains("pupil referral unit")) + { + schoolOverviewTable.AddRange(new List { + new[] { new TextElement { Value = "Which groups of pupils attend the school", Bold = true }, new TextElement { Value = document.PupilsAttendingGroup } }, + new[] { new TextElement { Value = "Number of places funded for", Bold = true }, new TextElement { Value = document.NumberOfPlacesFundedFor } }, + new[] { new TextElement { Value = "Alternative provision", Bold = true }, new TextElement { Value = document.NumberOfAlternativeProvisionPlaces } }, + new[] { new TextElement { Value = "SEN Unit", Bold = true }, new TextElement { Value = document.NumberOfSENUnitPlaces } }, + new[] { new TextElement { Value = "Medical", Bold = true }, new TextElement { Value = document.NumberOfMedicalPlaces } }, + new[] { new TextElement { Value = "Post-16", Bold = true }, new TextElement { Value = document.NumberOfPost16Places } }, + }); + } + // Specific SEN fields if (document.SchoolType.ToLower().Contains("special")) { diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/SchoolOverviewHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/SchoolOverviewHelper.cs index d32ecd4a5..fae547550 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/SchoolOverviewHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/SchoolOverviewHelper.cs @@ -6,6 +6,7 @@ using System; using DocumentFormat.OpenXml.Drawing; using AngleSharp.Text; +using System.Collections.Generic; namespace Dfe.PrepareConversions.Utils { @@ -31,5 +32,27 @@ public static SetSchoolOverviewModel CreateUpdateSchoolOverview(ProjectViewModel projectViewModel.PupilsAttendingGroupTeenageMums ); } + + public static string MapPupilsAttendingGroup(bool? pupilsAttendingGroupPermanentlyExcluded, bool? pupilsAttendingGroupMedicalAndHealthNeeds, bool? pupilsAttendingGroupTeenageMums) + { + var listOfAttendes = new List(); + + if (pupilsAttendingGroupPermanentlyExcluded.HasValue && pupilsAttendingGroupPermanentlyExcluded.Value) + { + listOfAttendes.Add("Permanently Excluded"); + } + + if (pupilsAttendingGroupMedicalAndHealthNeeds.HasValue && pupilsAttendingGroupMedicalAndHealthNeeds.Value) + { + listOfAttendes.Add("Medical and Health Needs"); + } + + if (pupilsAttendingGroupTeenageMums.HasValue && pupilsAttendingGroupTeenageMums.Value) + { + listOfAttendes.Add("Teenage Mums"); + } + + return string.Join(", ", listOfAttendes); + } } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolOverviewViewComponent.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolOverviewViewComponent.cs index 92772efe2..44e64e210 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolOverviewViewComponent.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolOverviewViewComponent.cs @@ -2,6 +2,7 @@ using Dfe.PrepareConversions.Data; using Dfe.PrepareConversions.Data.Models; using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Utils; using Dfe.PrepareConversions.ViewModels; using Microsoft.AspNetCore.Mvc; using System; @@ -62,7 +63,7 @@ public async Task InvokeAsync() MemberOfParliamentNameAndParty = project.MemberOfParliamentNameAndParty, IsSpecial = schoolOverview?.SchoolType?.ToLower().Contains("special") ?? false, IsPRU = schoolOverview?.SchoolType?.ToLower().Contains("pupil referral unit") ?? false, - PupilsAttendingGroup = MapPupilsAttendingGroup(project), + PupilsAttendingGroup = SchoolOverviewHelper.MapPupilsAttendingGroup(project.PupilsAttendingGroupPermanentlyExcluded, project.PupilsAttendingGroupMedicalAndHealthNeeds, project.PupilsAttendingGroupTeenageMums), NumberOfAlternativeProvisionPlaces = project.NumberOfAlternativeProvisionPlaces, NumberOfMedicalPlaces = project.NumberOfMedicalPlaces, NumberOfSENUnitPlaces = project.NumberOfSENUnitPlaces, @@ -71,26 +72,4 @@ public async Task InvokeAsync() return View(viewModel); } - - private static string MapPupilsAttendingGroup(AcademyConversionProject project) - { - var listOfAttendes = new List(); - - if (project.PupilsAttendingGroupPermanentlyExcluded.HasValue && project.PupilsAttendingGroupPermanentlyExcluded.Value) - { - listOfAttendes.Add("Permanently Excluded"); - } - - if (project.PupilsAttendingGroupMedicalAndHealthNeeds.HasValue && project.PupilsAttendingGroupMedicalAndHealthNeeds.Value) - { - listOfAttendes.Add("Medical and Health Needs"); - } - - if (project.PupilsAttendingGroupTeenageMums.HasValue && project.PupilsAttendingGroupTeenageMums.Value) - { - listOfAttendes.Add("Teenage Mums"); - } - - return string.Join(", ", listOfAttendes); - } } From 3aff20db529413403e78bc5ca44281068da91e26 Mon Sep 17 00:00:00 2001 From: Elijah Aremu <45821029+elielijah321@users.noreply.github.com> Date: Wed, 24 Jan 2024 09:20:20 +0000 Subject: [PATCH 2/5] Allow Voluntary Academies to change grant amount boolean --- .../Pages/UpdateAcademyConversionProjectPageModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/UpdateAcademyConversionProjectPageModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/UpdateAcademyConversionProjectPageModel.cs index e7ff15f10..6a7355dea 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/UpdateAcademyConversionProjectPageModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/UpdateAcademyConversionProjectPageModel.cs @@ -208,7 +208,7 @@ protected UpdateAcademyConversionProject Build() private bool? ConversionSupportGrantAmountChanged(string academyRoute) { - if (academyRoute == AcademyTypeAndRoutes.Sponsored) + if (academyRoute == AcademyTypeAndRoutes.Sponsored || academyRoute == AcademyTypeAndRoutes.Voluntary) { return AcademyConversionProject.ConversionSupportGrantAmountChanged; } From b22e52a30158486ad315bd35e3babc6b9c0d2882 Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Wed, 24 Jan 2024 14:37:24 +0000 Subject: [PATCH 3/5] Logic adjusted to only show sponsored grants for all PRU's --- .../SchoolAndTrustInformation/default.cshtml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml index e71ecc253..92f7dcf17 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml @@ -18,14 +18,14 @@ @* Voluntary grant *@ - - + + @* Sponsored grant *@ - - + + - - + + From eed1663155cf2b31b9e4e2810426d98f9349bd81 Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Wed, 24 Jan 2024 14:46:10 +0000 Subject: [PATCH 4/5] Duplicate grant amounts no longewr showing for SEN schools --- .../SchoolAndTrustInformation/default.cshtml | 12 ++++++------ .../ViewModels/SchoolAndTrustInformationViewModel.cs | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml index 92f7dcf17..db3b95e4b 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml @@ -18,14 +18,14 @@ @* Voluntary grant *@ - - + + @* Sponsored grant *@ - - + + - - + + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/SchoolAndTrustInformationViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/SchoolAndTrustInformationViewModel.cs index 420b91e8e..9cbbb949e 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/SchoolAndTrustInformationViewModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/SchoolAndTrustInformationViewModel.cs @@ -31,5 +31,6 @@ public class SchoolAndTrustInformationViewModel public string Form7ReceivedDate { get; set; } public bool IsDao { get; set; } public bool IsPRU => SchoolType.ToLower().Equals("pupil referral unit"); + public bool IsSEN => SchoolType.ToLower().Equals("special"); public bool WasForm7Received { get; set; } } From a31614b7841548346bed9004d2fe0ad07d6157cb Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Wed, 24 Jan 2024 15:10:16 +0000 Subject: [PATCH 5/5] Handling null on first project get for SEN or PRU --- .../SchoolAndTrustInformationViewComponent.cs | 7 +++---- .../ViewModels/SchoolAndTrustInformationViewModel.cs | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolAndTrustInformationViewComponent.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolAndTrustInformationViewComponent.cs index 1702e7690..da024e0c1 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolAndTrustInformationViewComponent.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolAndTrustInformationViewComponent.cs @@ -2,7 +2,6 @@ using Dfe.PrepareConversions.Data; using Dfe.PrepareConversions.Data.Models; using Dfe.PrepareConversions.Data.Services; -using Dfe.PrepareConversions.Extensions; using Dfe.PrepareConversions.ViewModels; using Microsoft.AspNetCore.Mvc; using System; @@ -44,7 +43,7 @@ public async Task InvokeAsync() PreviousHeadTeacherBoardLink = project.PreviousHeadTeacherBoardLink, SchoolName = project.SchoolName, SchoolUrn = project.Urn.ToString(), - SchoolType = project.SchoolType.ToString(), + SchoolType = project?.SchoolType?.ToString(), LocalAuthority = project.LocalAuthority, TrustReferenceNumber = project.TrustReferenceNumber, NameOfTrust = project.NameOfTrust, @@ -54,11 +53,11 @@ public async Task InvokeAsync() Form7Received = project.Form7Received, Form7ReceivedDate = project.Form7ReceivedDate.ToDateString(), WasForm7Received = project.Form7Received is not null && project.Form7Received.Equals("Yes"), - ConversionSupportGrantAmount = project.ConversionSupportGrantAmount?.ToMoneyString(true), + ConversionSupportGrantAmount = project?.ConversionSupportGrantAmount?.ToMoneyString(true), ConversionSupportGrantChangeReason = project.ConversionSupportGrantChangeReason, ConversionSupportGrantType = project.ConversionSupportGrantType, ConversionSupportGrantEnvironmentalImprovementGrant = project.ConversionSupportGrantEnvironmentalImprovementGrant, - ConversionSupportNumberOfSites = project.ConversionSupportGrantNumberOfSites, + ConversionSupportNumberOfSites = project?.ConversionSupportGrantNumberOfSites, ProposedAcademyOpeningDate = project.ProposedAcademyOpeningDate.ToDateString(true), DaoPackSentDate = project.DaoPackSentDate.ToDateString() }; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/SchoolAndTrustInformationViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/SchoolAndTrustInformationViewModel.cs index 9cbbb949e..5dda8cd67 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/SchoolAndTrustInformationViewModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/SchoolAndTrustInformationViewModel.cs @@ -30,7 +30,7 @@ public class SchoolAndTrustInformationViewModel public string Form7Received { get; set; } public string Form7ReceivedDate { get; set; } public bool IsDao { get; set; } - public bool IsPRU => SchoolType.ToLower().Equals("pupil referral unit"); - public bool IsSEN => SchoolType.ToLower().Equals("special"); + public bool IsPRU => SchoolType?.ToLower().Equals("pupil referral unit") ?? false; + public bool IsSEN => SchoolType?.ToLower().Contains("special") ?? false; public bool WasForm7Received { get; set; } }