diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerAgreementOrchestratorTests/WhenIGetOrganisationAgreements.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerAgreementOrchestratorTests/WhenIGetOrganisationAgreements.cs index aa688ecafc..8a0393fd3a 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerAgreementOrchestratorTests/WhenIGetOrganisationAgreements.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerAgreementOrchestratorTests/WhenIGetOrganisationAgreements.cs @@ -94,7 +94,7 @@ public async Task ThenTheValuesAreReturnedInTheResponseFromTheRequestForAllOrgan var actual = await _orchestrator.GetOrganisationAgreements(AccountLegalEntityHashedId); //Assert - Assert.IsNotNull(actual.Data.Any()); + Assert.IsNotNull(actual.Data.Agreements.Any()); } } } diff --git a/src/SFA.DAS.EmployerAccounts.Web/Controllers/EmployerAgreementController.cs b/src/SFA.DAS.EmployerAccounts.Web/Controllers/EmployerAgreementController.cs index 0debad41d2..de5dd9a66e 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Controllers/EmployerAgreementController.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/Controllers/EmployerAgreementController.cs @@ -292,7 +292,7 @@ public async Task WhenDoYouWantToView(int? choice, string agreemen public async Task ViewAllAgreements(string hashedAccountId, string accountLegalEntityHashedId) { var model = await _orchestrator.GetOrganisationAgreements(accountLegalEntityHashedId); - return View(model); + return View(model.Data); } } } \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/Helpers/ControllerConstants.cs b/src/SFA.DAS.EmployerAccounts.Web/Helpers/ControllerConstants.cs index 0c735937f3..0d981fdb02 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Helpers/ControllerConstants.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/Helpers/ControllerConstants.cs @@ -100,5 +100,6 @@ public static class ControllerConstants public const string ApproveOrRejectApprentice = "ApproveOrRejectApprentice"; public const string ViewApprenticeBeforeApprove = "ViewApprenticeBeforeApprove"; public const string ViewAllAgreementActionName = "ViewAllAgreements"; + public const string InsetText = "Inset"; } } \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerAgreementOrchestrator.cs b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerAgreementOrchestrator.cs index f9230b7125..fee98c9b54 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerAgreementOrchestrator.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerAgreementOrchestrator.cs @@ -320,9 +320,9 @@ public virtual async Task>> GetOrganisationAgreements(string accountLegalEntityHashedId) + public virtual async Task> GetOrganisationAgreements(string accountLegalEntityHashedId) { - var response = new OrchestratorResponse>(); + var response = new OrchestratorResponse(); try { @@ -330,12 +330,16 @@ public virtual async Task, ICollection>(result.Agreements); + + response.Data = new OrganisationAgreementsViewModel + { + AgreementId = accountLegalEntityHashedId, + Agreements = _mapper.Map, ICollection>(result.Agreements) + }; } catch (InvalidRequestException ex) { - return new OrchestratorResponse> + return new OrchestratorResponse { Status = HttpStatusCode.BadRequest, Exception = ex @@ -343,7 +347,7 @@ public virtual async Task> + return new OrchestratorResponse { Status = HttpStatusCode.Unauthorized }; diff --git a/src/SFA.DAS.EmployerAccounts.Web/SFA.DAS.EmployerAccounts.Web.csproj b/src/SFA.DAS.EmployerAccounts.Web/SFA.DAS.EmployerAccounts.Web.csproj index 59ade2fd1b..0395ad91ca 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/SFA.DAS.EmployerAccounts.Web.csproj +++ b/src/SFA.DAS.EmployerAccounts.Web/SFA.DAS.EmployerAccounts.Web.csproj @@ -255,6 +255,7 @@ + @@ -864,8 +865,6 @@ - - @@ -875,6 +874,8 @@ + + diff --git a/src/SFA.DAS.EmployerAccounts.Web/ViewModels/OrganisationAgreementViewModel.cs b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/OrganisationAgreementViewModel.cs index bc9dd00ce3..4ab7d656e1 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/ViewModels/OrganisationAgreementViewModel.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/OrganisationAgreementViewModel.cs @@ -19,8 +19,5 @@ public class OrganisationAgreementViewModel public string AccountLegalEntityPublicHashedId => AccountLegalEntity.PublicHashedId; public string SignedDateText => SignedDate.HasValue ? SignedDate.Value.ToString("dd MMMM yyyy") : ""; - - public string GetAgreementTabListId => $"#v{Template.VersionNumber}-agreement"; - public string GetAgreementTabPanelId => $"v{Template.VersionNumber}-agreement"; } } \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/ViewModels/OrganisationAgreementsViewModel.cs b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/OrganisationAgreementsViewModel.cs new file mode 100644 index 0000000000..884f66277c --- /dev/null +++ b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/OrganisationAgreementsViewModel.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +namespace SFA.DAS.EmployerAccounts.Web.ViewModels +{ + public class OrganisationAgreementsViewModel + { + public OrganisationAgreementsViewModel() + { + Agreements = new Collection(); + } + + public ICollection Agreements { get; set; } + + public string AgreementId { get; set; } + + public bool HasSignedAgreements => Agreements.Any(agreement => agreement.SignedDate != null); + public bool HasUnsignedAgreement => Agreements.Any(agreement => agreement.SignedDate == null); + + public OrganisationAgreementViewModel UnsignedAgreement => Agreements.Single(agreement => agreement.SignedDate == null); + + public IEnumerable SignedAgreements => Agreements.Where(agreement => agreement.SignedDate != null); + } +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerAgreement/ViewAllAgreements.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerAgreement/ViewAllAgreements.cshtml index ec8df491a7..44ce969f6e 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerAgreement/ViewAllAgreements.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerAgreement/ViewAllAgreements.cshtml @@ -1,5 +1,6 @@ @using SFA.DAS.EmployerAccounts.Web.Extensions -@model OrchestratorResponse> +@using SFA.DAS.EmployerAccounts.Web.Helpers +@model OrganisationAgreementsViewModel @{ Layout = "~/Views/Shared/_Layout_CDN.cshtml"; @@ -8,109 +9,38 @@ ViewBag.Section = "organisations"; ViewBag.ZenDeskLabel = "eas-your-esfa-agreement"; ViewBag.GaData.Vpv = "/accounts/agreements/view-your-agreement/agreement-details"; - var tabsCount = 0; }
- -

- Your agreements with the Education and Skills Funding Agency (ESFA) -

- +

Your agreements with the Education and Skills Funding Agency (ESFA)

+

Agreement ID: @Model.AgreementId

-
- -
- -
- -

- By published dates -

+
-
    +@if (Model.HasUnsignedAgreement) +{ + @Html.Partial("_AwaitingAcceptance", Model.UnsignedAgreement, new ViewDataDictionary {{ ControllerConstants.InsetText, Model.UnsignedAgreement.Template.InsetText(Model.Agreements)}}) +} - @foreach (var item in Model.Data) +
    +
    +

    Accepted agreements

    + @if (Model.HasSignedAgreements) + { +
    + @foreach (var agreement in Model.SignedAgreements) { - tabsCount++; -
  • - - @item.Template.PublishedInfo - -
  • + @Html.Partial("_AcceptedAgreement", agreement, new ViewDataDictionary{{ControllerConstants.InsetText, agreement.Template.InsetText(Model.Agreements) } }) } -
- @foreach (var item in Model.Data) - { -
- - @if (item.SignedDate != null) - { - ViewBag.SelectedTab = @item.Template.VersionNumber; - - - Accepted on @item.SignedDateText - - - ViewBag.BreadCrumbsTrail = @item.AccountLegalEntity.Name; - -
-
- -

- Agreement between @item.AccountLegalEntity.Name and ESFA -

- - @item.Template.PublishedInfo - - @if (@item.Template.InsetText(Model.Data) != string.Empty) - { -
- @item.Template.InsetText(Model.Data) -
- } - -
-
- - @Html.Partial("_AcceptedAgreement", item) - } - else - { - - NOT ACCEPTED YET - - - ViewBag.BreadCrumbsTrail = @item.AccountLegalEntity.Name; - -
-
- -

- Agreement between @item.AccountLegalEntity.Name and ESFA -

- - @item.Template.PublishedInfo - - @if (@item.Template.InsetText(Model.Data) != string.Empty) - { -
- @item.Template.InsetText(Model.Data) -
- } - -
-
- - @Html.Partial("_NotAcceptedAgreement", item) - } -
- } - -
+
+ } + else + { +

You have no accepted agreements

+ }
diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerAgreement/_AcceptedAgreement.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerAgreement/_AcceptedAgreement.cshtml new file mode 100644 index 0000000000..cef4f6b9fb --- /dev/null +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerAgreement/_AcceptedAgreement.cshtml @@ -0,0 +1,127 @@ +@using SFA.DAS.EmployerAccounts.Web.Helpers +@model SFA.DAS.EmployerAccounts.Web.ViewModels.OrganisationAgreementViewModel + +
+
+

+ + @Model.Template.PublishedInfo + +

+ + Accepted on @Model.SignedDateText + +
+
+
+
+ + @Model.Template.PublishedInfo + +

+ Agreement between @Model.AccountLegalEntity.Name and ESFA +

+
+ @ViewData[ControllerConstants.InsetText] +
+ + This agreement allows you to spend funds for @Model.AccountLegalEntity.Name. + +
+
+
+

+ Parties +

+
+
+

+ + The Secretary of State for Education acting through the Education and Skills Funding Agency an executive agency of the Department for Education
+ Cheylesmore House
+ Quinton Road
+ Coventry
+ CV1 2WT +
+

+ @if (Model.OrganisationLookupPossible) + { + +

+ BARBERRY COVENTRY LIMITED
+ @Html.CommaSeperatedAddressToHtml(@Model.AccountLegalEntity.Address) + +

+
+

+ + Update these details + +

+ } +
+
+
+
+

+ Document +

+
+
+
+
+ +
+
+ Your ESFA agreement +

HTML

+

+
+
+
+
+
+
+
+

+ This agreement has been accepted +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
Accepted by:@Model.SignedByName
On behalf of:@Model.AccountLegalEntity.Name
Address: @Model.AccountLegalEntity.Address
Accepted on:@Model.SignedDateText
Agreement ID:@Model.AccountLegalEntityPublicHashedId
+
+
+
+
+
+
\ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerAgreement/_AwaitingAcceptance.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerAgreement/_AwaitingAcceptance.cshtml new file mode 100644 index 0000000000..404bd05594 --- /dev/null +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerAgreement/_AwaitingAcceptance.cshtml @@ -0,0 +1,35 @@ +@using SFA.DAS.EmployerAccounts.Web.Helpers +@model SFA.DAS.EmployerAccounts.Web.ViewModels.OrganisationAgreementViewModel + +
+
+

Agreement between @Model.AccountLegalEntity.Name and ESFA

+
+
+ + Awaiting acceptance + +

+ @Model.Template.PublishedInfo +

+

+@if (ViewData[ControllerConstants.InsetText] as string != string.Empty) +{ +
+ @ViewData[ControllerConstants.InsetText] +
+} +

+ This agreement creates a legal contract between @Model.AccountLegalEntity.Name and ESFA. It allows you to transfer funds to other employers and pay training providers for apprenticeships. +

+

+

+ You need to ensure you have authority from your organisation before you accept this agreement on their behalf. +

+ +
+ @Html.AntiForgeryToken() + +
+ +
\ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/Shared/_AcceptedAgreement.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/Shared/_AcceptedAgreement.cshtml deleted file mode 100644 index ec739a9132..0000000000 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/Shared/_AcceptedAgreement.cshtml +++ /dev/null @@ -1,112 +0,0 @@ -@model SFA.DAS.EmployerAccounts.Web.ViewModels.OrganisationAgreementViewModel - -
-
- -

This agreement allows you to spend funds for @Model.AccountLegalEntity.Name.

- -
-
- -
- -
-
- -
-
-

Parties

-
- -
-
-
-
The Secretary of State for Education acting through the Education and Skills Funding Agency an executive agency of the Department for Education
- -
Cheylesmore House
-
Quinton Road
-
Coventry
-
CV1 2WT
-
-
- -
- @if (Model.OrganisationLookupPossible) - { -
-
@Model.AccountLegalEntity.Name
- -
- @Html.CommaSeperatedAddressToHtml(@Model.AccountLegalEntity.Address) -
-
- - Update these details - } -
-
-
- -
-
-

Document

-
- -
- -
-
- -
-
-

- Your ESFA agreement
- Document format: HTML -

-
-
- -
-
- -
-
- -
- -
-
- -
-
- -

This agreement has been accepted

- -
-
Accepted by
-
@Model.SignedByName
- -
On behalf of
-
@Model.AccountLegalEntity.Name
- -
Address
-
@Model.AccountLegalEntity.Address
- -
Accepted on
-
@Model.SignedDateText
- -
Agreement ID
-
@Model.AccountLegalEntityPublicHashedId
-
- -
-
- -
-
- diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/Shared/_NotAcceptedAgreement.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/Shared/_NotAcceptedAgreement.cshtml deleted file mode 100644 index a5240f2f3b..0000000000 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/Shared/_NotAcceptedAgreement.cshtml +++ /dev/null @@ -1,20 +0,0 @@ -@model SFA.DAS.EmployerAccounts.Web.ViewModels.OrganisationAgreementViewModel - -
-
-

About the agreement

- -

- This agreement creates a legal contract between @Model.AccountLegalEntity.Name and ESFA. It allows you to transfer funds to other employers and pay training providers for apprenticeships. -

- -

- You need to ensure you have authority from your organisation before you accept this agreement on their behalf. -

- -
- @Html.AntiForgeryToken() - -
-
-
\ No newline at end of file