Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed finance plan caching issue, added errors to num inputs and corr… #1015

Merged
merged 3 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using System.ComponentModel;
using System.Linq;
using Dfe.ManageFreeSchoolProjects.Services.Tasks;
using Dfe.ManageFreeSchoolProjects.ViewModels;
using Microsoft.AspNetCore.Http;


namespace Dfe.ManageFreeSchoolProjects.Pages.Project.Tasks.FinancePlan
Expand All @@ -25,6 +27,7 @@ public class EditFinancePlanTaskModel : PageModel
private readonly IUpdateProjectByTaskService _updateProjectTaskService;
private readonly IUpdateFinancePlanCache _updateFinancePlanCache;
private readonly ILogger<EditFinancePlanTaskModel> _logger;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ErrorService _errorService;

[BindProperty(SupportsGet = true, Name = "projectId")]
Expand Down Expand Up @@ -70,12 +73,14 @@ public EditFinancePlanTaskModel(
IUpdateProjectByTaskService updateProjectTaskService,
IUpdateFinancePlanCache updateFinancePlanCache,
ILogger<EditFinancePlanTaskModel> logger,
IHttpContextAccessor httpContextAccessor,
ErrorService errorService)
{
_getProjectService = getProjectService;
_updateProjectTaskService = updateProjectTaskService;
_updateFinancePlanCache = updateFinancePlanCache;
_logger = logger;
_httpContextAccessor = httpContextAccessor;
_errorService = errorService;
}

Expand Down Expand Up @@ -165,15 +170,39 @@ private async Task LoadProject()
{
var project = await _getProjectService.Execute(ProjectId, TaskName.FinancePlan);

FinancePlanAgreed = project.FinancePlan.FinancePlanAgreed == YesNo.Yes;
DateAgreed = project.FinancePlan.DateAgreed;
PlanSavedInWorkplacesFolder = project.FinancePlan.PlanSavedInWorkplacesFolder == YesNo.Yes;
LocalAuthorityAgreedToPupilNumbers = project.FinancePlan.LocalAuthorityAgreedPupilNumbers?.ToString();
TrustOptIntoRpa = project.FinancePlan.TrustWillOptIntoRpa?.ToString();
RpaStartDate = project.FinancePlan.RpaStartDate;
RpaCoverType = project.FinancePlan.RpaCoverType;
var referrerQuery = _httpContextAccessor.HttpContext.Request.Query["referrer"];

var isReferred = Enum.TryParse(referrerQuery, out Referrer referrer);


if (isReferred && referrer == Referrer.EditUnderwrittenPlaces)
{
var existingCacheItem = _updateFinancePlanCache.Get();

FinancePlanAgreed = existingCacheItem.FinancePlan.FinancePlanAgreed == YesNo.Yes;
DateAgreed = existingCacheItem.FinancePlan.DateAgreed;
PlanSavedInWorkplacesFolder = existingCacheItem.FinancePlan.PlanSavedInWorkplacesFolder == YesNo.Yes;
LocalAuthorityAgreedToPupilNumbers = existingCacheItem.FinancePlan.LocalAuthorityAgreedPupilNumbers?.ToString();
TrustOptIntoRpa = existingCacheItem.FinancePlan.TrustWillOptIntoRpa?.ToString();
RpaStartDate = existingCacheItem.FinancePlan.RpaStartDate;
RpaCoverType = existingCacheItem.FinancePlan.RpaCoverType;

}

else
{
FinancePlanAgreed = project.FinancePlan.FinancePlanAgreed == YesNo.Yes;
DateAgreed = project.FinancePlan.DateAgreed;
PlanSavedInWorkplacesFolder = project.FinancePlan.PlanSavedInWorkplacesFolder == YesNo.Yes;
LocalAuthorityAgreedToPupilNumbers = project.FinancePlan.LocalAuthorityAgreedPupilNumbers?.ToString();
TrustOptIntoRpa = project.FinancePlan.TrustWillOptIntoRpa?.ToString();
RpaStartDate = project.FinancePlan.RpaStartDate;
RpaCoverType = project.FinancePlan.RpaCoverType;
}

SchoolName = project.SchoolName;


}

private static YesNoNotApplicable? ConvertYesNoNotApplicable(string value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@{
ViewData["Title"] = $"Local authority underwriting pupil numbers - {Model.SchoolName}";

var backlink = string.Format(RouteConstants.EditFinancePlanTask, Model.ProjectId);
var backlink = string.Format(RouteConstants.EditFinancePlanTask, Model.ProjectId) + "?referrer=" + Referrer.EditUnderwrittenPlaces;

}
@section BeforeMain {
Expand All @@ -28,7 +28,9 @@
School phase
</dt>
<dd class="govuk-summary-list__value">
@Model.SchoolPhase.ToDescription()
@{
RenderValue(Model.SchoolPhase.ToDescription());
}
</dd>
</div>
</govuk-summary-list>
Expand All @@ -45,13 +47,13 @@
<h1 class="govuk-heading-l" data-testid="title">
Provide the total number of underwritten places
</h1>
<govuk-number-input-cell id="primary-year-1-places" name="primary-year-1-places" asp-for="@Model.PrimaryYear1Places" label="First year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-2-places" name="primary-year-2-places" asp-for="@Model.PrimaryYear2Places" label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-3-places" name="primary-year-3-places" asp-for="@Model.PrimaryYear3Places" label="Third year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-4-places" name="primary-year-4-places" asp-for="@Model.PrimaryYear4Places" label="Fourth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-5-places" name="primary-year-5-places" asp-for="@Model.PrimaryYear5Places" label="Fifth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-6-places" name="primary-year-6-places" asp-for="@Model.PrimaryYear6Places" label="Sixth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-7-places" name="primary-year-7-places" asp-for="@Model.PrimaryYear7Places" label="Seventh year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-1-places" name="primary-year-1-places" asp-for="@Model.PrimaryYear1Places" show-label=true label="First year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-2-places" name="primary-year-2-places" asp-for="@Model.PrimaryYear2Places" show-label=true label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-3-places" name="primary-year-3-places" asp-for="@Model.PrimaryYear3Places" show-label=true label="Third year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-4-places" name="primary-year-4-places" asp-for="@Model.PrimaryYear4Places" show-label=true label="Fourth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-5-places" name="primary-year-5-places" asp-for="@Model.PrimaryYear5Places" show-label=true label="Fifth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-6-places" name="primary-year-6-places" asp-for="@Model.PrimaryYear6Places" show-label=true label="Sixth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-7-places" name="primary-year-7-places" asp-for="@Model.PrimaryYear7Places" show-label=true label="Seventh year of opening" suffix="places" />
</div>
}

Expand All @@ -61,11 +63,11 @@
<h1 class="govuk-heading-l" data-testid="title">
Provide the total number of underwritten places
</h1>
<govuk-number-input-cell id="secondary-year-1-places" name="secondary-year-1-places" asp-for="@Model.SecondaryYear1Places" label="First year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-2-places" name="secondary-year-2-places" asp-for="@Model.SecondaryYear2Places" label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-3-places" name="secondary-year-3-places" asp-for="@Model.SecondaryYear3Places" label="Third year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-4-places" name="secondary-year-4-places" asp-for="@Model.SecondaryYear4Places" label="Fourth year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-5-places" name="secondary-year-5-places" asp-for="@Model.SecondaryYear5Places" label="Fifth year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-1-places" name="secondary-year-1-places" asp-for="@Model.SecondaryYear1Places" show-label=true label="First year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-2-places" name="secondary-year-2-places" asp-for="@Model.SecondaryYear2Places" show-label=true label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-3-places" name="secondary-year-3-places" asp-for="@Model.SecondaryYear3Places" show-label=true label="Third year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-4-places" name="secondary-year-4-places" asp-for="@Model.SecondaryYear4Places" show-label=true label="Fourth year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-5-places" name="secondary-year-5-places" asp-for="@Model.SecondaryYear5Places" show-label=true label="Fifth year of opening" suffix="places" />
</div>
}

Expand All @@ -75,9 +77,9 @@
<h1 class="govuk-heading-l" data-testid="title">
Provide the total number of underwritten places
</h1>
<govuk-number-input-cell id="sixteen-to-nineteen-year-1-places" name="sixteen-to-nineteen-year-1-places" asp-for="@Model.SixteenToNineteenYear1Places" label="First year of opening" suffix="places" />
<govuk-number-input-cell id="sixteen-to-nineteen-year-2-places" name="sixteen-to-nineteen-year-2-places" asp-for="@Model.SixteenToNineteenYear2Places" label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="sixteen-to-nineteen-year-3-places" name="sixteen-to-nineteen-year-3-places" asp-for="@Model.SixteenToNineteenYear3Places" label="Third year of opening" suffix="places" />
<govuk-number-input-cell id="sixteen-to-nineteen-year-1-places" name="sixteen-to-nineteen-year-1-places" asp-for="@Model.SixteenToNineteenYear1Places" show-label=true label="First year of opening" suffix="places" />
<govuk-number-input-cell id="sixteen-to-nineteen-year-2-places" name="sixteen-to-nineteen-year-2-places" asp-for="@Model.SixteenToNineteenYear2Places" show-label=true label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="sixteen-to-nineteen-year-3-places" name="sixteen-to-nineteen-year-3-places" asp-for="@Model.SixteenToNineteenYear3Places" show-label=true label="Third year of opening" suffix="places" />
</div>
}

Expand All @@ -87,33 +89,33 @@
<h1 class="govuk-heading-l" data-testid="title">
Provide the total number of underwritten primary places
</h1>
<govuk-number-input-cell id="primary-year-1-places" name="primary-year-1-places" asp-for="@Model.PrimaryYear1Places" label="First year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-2-places" name="primary-year-2-places" asp-for="@Model.PrimaryYear2Places" label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-3-places" name="primary-year-3-places" asp-for="@Model.PrimaryYear3Places" label="Third year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-4-places" name="primary-year-4-places" asp-for="@Model.PrimaryYear4Places" label="Fourth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-5-places" name="primary-year-5-places" asp-for="@Model.PrimaryYear5Places" label="Fifth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-6-places" name="primary-year-6-places" asp-for="@Model.PrimaryYear6Places" label="Sixth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-7-places" name="primary-year-7-places" asp-for="@Model.PrimaryYear7Places" label="Seventh year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-1-places" name="primary-year-1-places" asp-for="@Model.PrimaryYear1Places" show-label=true label="First year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-2-places" name="primary-year-2-places" asp-for="@Model.PrimaryYear2Places" show-label=true label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-3-places" name="primary-year-3-places" asp-for="@Model.PrimaryYear3Places" show-label=true label="Third year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-4-places" name="primary-year-4-places" asp-for="@Model.PrimaryYear4Places" show-label=true label="Fourth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-5-places" name="primary-year-5-places" asp-for="@Model.PrimaryYear5Places" show-label=true label="Fifth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-6-places" name="primary-year-6-places" asp-for="@Model.PrimaryYear6Places" show-label=true label="Sixth year of opening" suffix="places" />
<govuk-number-input-cell id="primary-year-7-places" name="primary-year-7-places" asp-for="@Model.PrimaryYear7Places" show-label=true label="Seventh year of opening" suffix="places" />
</div>

<div class="govuk-form-group govuk-!-margin-bottom-9">
<h1 class="govuk-heading-l" data-testid="title">
Provide the total number of underwritten secondary places
</h1>
<govuk-number-input-cell id="secondary-year-1-places" name="secondary-year-1-places" asp-for="@Model.SecondaryYear1Places" label="First year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-2-places" name="secondary-year-2-places" asp-for="@Model.SecondaryYear2Places" label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-3-places" name="secondary-year-3-places" asp-for="@Model.SecondaryYear3Places" label="Third year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-4-places" name="secondary-year-4-places" asp-for="@Model.SecondaryYear4Places" label="Fourth year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-5-places" name="secondary-year-5-places" asp-for="@Model.SecondaryYear5Places" label="Fifth year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-1-places" name="secondary-year-1-places" asp-for="@Model.SecondaryYear1Places" show-label=true label="First year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-2-places" name="secondary-year-2-places" asp-for="@Model.SecondaryYear2Places" show-label=true label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-3-places" name="secondary-year-3-places" asp-for="@Model.SecondaryYear3Places" show-label=true label="Third year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-4-places" name="secondary-year-4-places" asp-for="@Model.SecondaryYear4Places" show-label=true label="Fourth year of opening" suffix="places" />
<govuk-number-input-cell id="secondary-year-5-places" name="secondary-year-5-places" asp-for="@Model.SecondaryYear5Places" show-label=true label="Fifth year of opening" suffix="places" />
</div>

<div class="govuk-form-group govuk-!-margin-bottom-9">
<h1 class="govuk-heading-l" data-testid="title">
Provide the total number of underwritten 16 to 19 places
</h1>
<govuk-number-input-cell id="sixteen-to-nineteen-year-1-places" name="sixteen-to-nineteen-year-1-places" asp-for="@Model.SixteenToNineteenYear1Places" label="First year of opening" suffix="places" />
<govuk-number-input-cell id="sixteen-to-nineteen-year-2-places" name="sixteen-to-nineteen-year-2-places" asp-for="@Model.SixteenToNineteenYear2Places" label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="sixteen-to-nineteen-year-3-places" name="sixteen-to-nineteen-year-3-places" asp-for="@Model.SixteenToNineteenYear3Places" label="Third year of opening" suffix="places" />
<govuk-number-input-cell id="sixteen-to-nineteen-year-1-places" name="sixteen-to-nineteen-year-1-places" asp-for="@Model.SixteenToNineteenYear1Places" show-label=true label="First year of opening" suffix="places" />
<govuk-number-input-cell id="sixteen-to-nineteen-year-2-places" name="sixteen-to-nineteen-year-2-places" asp-for="@Model.SixteenToNineteenYear2Places" show-label=true label="Second year of opening" suffix="places" />
<govuk-number-input-cell id="sixteen-to-nineteen-year-3-places" name="sixteen-to-nineteen-year-3-places" asp-for="@Model.SixteenToNineteenYear3Places" show-label=true label="Third year of opening" suffix="places" />
</div>
}

Expand All @@ -126,4 +128,20 @@
</form>

</div>
</div>
</div>

@functions {

public void RenderValue(string value)
{
if (string.IsNullOrEmpty(value) || value == "NotSet")
{
<span class="empty">Empty</span>
}
else
{
@value
}
}

}
Loading
Loading