Skip to content

Commit

Permalink
CON-1654 - Users to see version history of accepted agreements - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
VasanthaKasirajan3008 committed Apr 7, 2020
1 parent 6979851 commit ad74481
Showing 21 changed files with 649 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -327,5 +327,13 @@ public async Task<ActionResult> WhenDoYouWantToView(int? choice, string agreemen
}
}
}

[HttpGet]
[Route("agreements/{accountLegalEntityHashedId}/viewallagreements")]
public async Task<ActionResult> ViewAllAgreements(string hashedAccountId, string accountLegalEntityHashedId)
{
var model = await _orchestrator.GetOrganisationAgreements(accountLegalEntityHashedId);
return View(model);
}
}
}
Original file line number Diff line number Diff line change
@@ -90,5 +90,6 @@ public static class ControllerConstants
public const string ViewApprentice = "ViewApprentice";
public const string ApproveOrRejectApprentice = "ApproveOrRejectApprentice";
public const string ViewApprenticeBeforeApprove = "ViewApprenticeBeforeApprove";
public const string ViewAllAgreementActionName = "ViewAllAgreements";
}
}
13 changes: 13 additions & 0 deletions src/SFA.DAS.EmployerAccounts.Web/Mappings/AgreementMappings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using AutoMapper;
using SFA.DAS.EAS.Account.Api.Types;
using SFA.DAS.EmployerAccounts.Dtos;
using SFA.DAS.EmployerAccounts.Models.EmployerAgreement;
using SFA.DAS.EmployerAccounts.Queries.GetEmployerAgreement;
using SFA.DAS.EmployerAccounts.Web.ViewModels;

@@ -35,6 +36,18 @@ public AgreementMappings()

CreateMap<AccountDetailViewModel, AgreementInfoViewModel>()
.ConvertUsing(new AgreementInfoConverter());

CreateMap<OrganisationAgreement, OrganisationAgreementViewModel>()
.ForMember(dest => dest.AgreementV1SignedDate, opts => opts.Ignore())
.ForMember(dest => dest.AgreementV2SignedDate, opts => opts.Ignore())
.ForMember(dest => dest.AgreementV3SignedDate, opts => opts.Ignore())
.ForMember(dest => dest.AgreementV1Signed, opts => opts.Ignore())
.ForMember(dest => dest.AgreementV2Signed, opts => opts.Ignore())
.ForMember(dest => dest.AgreementV3Signed, opts => opts.Ignore());

CreateMap<EmployerAgreementDto, EmployerAgreementViewModelV1>()
.ForMember(dest => dest.SignedDateText, opt => opt.MapFrom(src => src.SignedDate.HasValue ? src.SignedDate.Value.ToString("dd MMMM yyyy") : ""))
.ForMember(dest => dest.AccountLegalEntityPublicHashedId, opts => opts.Ignore());
}
}
}
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
using SFA.DAS.EmployerAccounts.Queries.GetEmployerAgreement;
using SFA.DAS.EmployerAccounts.Queries.GetEmployerAgreementPdf;
using SFA.DAS.EmployerAccounts.Queries.GetEmployerAgreementType;
using SFA.DAS.EmployerAccounts.Queries.GetOrganisationAgreements;
using SFA.DAS.EmployerAccounts.Queries.GetSignedEmployerAgreementPdf;
using SFA.DAS.EmployerAccounts.Queries.GetUnsignedEmployerAgreement;
using SFA.DAS.EmployerAccounts.Web.ViewModels;
@@ -367,5 +368,47 @@ public virtual async Task<OrchestratorResponse<ConfirmLegalAgreementToRemoveView

return response;
}

public virtual async Task<OrchestratorResponse<OrganisationAgreementViewModelV1>> GetOrganisationAgreements(string accountLegalEntityHashedId)
{
try
{
var response = await _mediator.SendAsync(new GetOrganisationAgreementsRequest
{
AccountLegalEntityHashedId = accountLegalEntityHashedId
});

var employerAgreementView =
_mapper.Map<OrganisationAgreement, OrganisationAgreementViewModel>(response.OrganisationAgreements);

var organisationLookupByIdPossible = await _referenceDataService.IsIdentifiableOrganisationType(response.OrganisationAgreements.LegalEntity.Source);

return new OrchestratorResponse<OrganisationAgreementViewModelV1>
{
Data = new OrganisationAgreementViewModelV1
{
OrganisationAgreementViewModel = employerAgreementView,
OrganisationLookupPossible = organisationLookupByIdPossible
}
};
}
catch (InvalidRequestException ex)
{
return new OrchestratorResponse<OrganisationAgreementViewModelV1>
{
Status = HttpStatusCode.BadRequest,
Data = new OrganisationAgreementViewModelV1(),
Exception = ex
};
}
catch (UnauthorizedAccessException)
{
return new OrchestratorResponse<OrganisationAgreementViewModelV1>
{
Status = HttpStatusCode.Unauthorized
};
}
}
}
}
}

Original file line number Diff line number Diff line change
@@ -281,6 +281,9 @@
<Compile Include="ViewModels\CallToActionViewModel.cs" />
<Compile Include="ViewModels\CohortViewModel.cs" />
<Compile Include="ViewModels\CreateUserAccountViewModel.cs" />
<Compile Include="ViewModels\EmployerAgreementViewModelV1.cs" />
<Compile Include="ViewModels\OrganisationAgreementViewModel.cs" />
<Compile Include="ViewModels\OrganisationEmployerAgreementViewModel.cs" />
<Compile Include="ViewModels\SignEmployerAgreementViewModel.cs" />
<Compile Include="ViewModels\PensionRegulatorDetailsViewModel.cs" />
<Compile Include="ViewModels\PanelViewModel.cs" />
@@ -882,6 +885,9 @@
<Content Include="Views\EmployerTeam\SingleApprenticeshipWithTrainingProvider.cshtml" />
<Content Include="Views\EmployerTeam\SingleApprenticeshipReadyForReview.cshtml" />
<Content Include="Views\EmployerTeam\SingleApprenticeshipContinueWithProvider.cshtml" />
<Content Include="Views\EmployerAgreement\ViewAllAgreements.cshtml" />
<Content Include="Views\Shared\_AcceptedAgreement.cshtml" />
<Content Include="Views\Shared\_NotAcceptedAgreement.cshtml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SFA.DAS.Account.Api.Client\SFA.DAS.EAS.Account.Api.Client.csproj">
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using SFA.DAS.EmployerAccounts.Models.Account;
using SFA.DAS.EmployerAccounts.Models.EmployerAgreement;
namespace SFA.DAS.EmployerAccounts.Web.ViewModels
{
public class EmployerAgreementViewModelV1
{
public long Id { get; set; }
public DateTime? ExpiredDate { get; set; }
public long? SignedById { get; set; }
public string SignedByName { get; set; }
public DateTime? SignedDate { get; set; }
public long AccountLegalEntityId { get; set; }
public AccountLegalEntity AccountLegalEntity { get; set; }
public EmployerAgreementStatus StatusId { get; set; }
public AgreementTemplate Template { get; set; }
public int TemplateId { get; set; }
public bool OrganisationLookupPossible { get; set; }
public string HashedAccountId { get; set; }
public string HashedLegalEntityId { get; set; }
public string HashedAgreementId { get; set; }

public string AccountLegalEntityPublicHashedId => AccountLegalEntity.PublicHashedId;

public string SignedDateText { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Linq;
using System.Collections.Generic;
using SFA.DAS.EmployerAccounts.Models.Account;

namespace SFA.DAS.EmployerAccounts.Web.ViewModels
{
public class OrganisationAgreementViewModel
{
public long Id { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public long AccountId { get; set; }
public long LegalEntityId { get; set; }
public DateTime Created { get; set; }
public long? SignedAgreementId { get; set; }
public int? SignedAgreementVersion { get; set; }
public long? PendingAgreementId { get; set; }
public int? PendingAgreementVersion { get; set; }
public string AccountLegalEntityPublicHashedId { get; set; }
public DateTime? Deleted { get; set; }

public ICollection<EmployerAgreement> Agreements { get; set; } = new List<EmployerAgreement>();

public bool AgreementV1Signed => DoCheck(Agreements.Where(x => x.Template.PartialViewName == "_Agreement_V1").FirstOrDefault());
public bool AgreementV2Signed => DoCheck(Agreements.Where(x => x.Template.PartialViewName == "_Agreement_V2").FirstOrDefault());
public bool AgreementV3Signed => DoCheck(Agreements.Where(x => x.Template.PartialViewName == "_Agreement_V3").FirstOrDefault());

public DateTime? AgreementV1SignedDate => Agreements.Where(x => x.Template.PartialViewName == "_Agreement_V1").FirstOrDefault().SignedDate;
public DateTime? AgreementV2SignedDate => Agreements.Where(x => x.Template.PartialViewName == "_Agreement_V2").FirstOrDefault().SignedDate;
public DateTime? AgreementV3SignedDate => Agreements.Where(x => x.Template.PartialViewName == "_Agreement_V3").FirstOrDefault().SignedDate;

public EmployerAgreementViewModelV1 EmployerAgreementV1 { get; set; }
public EmployerAgreementViewModelV1 EmployerAgreementV2 { get; set; }
public EmployerAgreementViewModelV1 EmployerAgreementV3 { get; set; }

public LegalEntity LegalEntity { get; set; }

public string HashedAccountId { get; set; }
public string HashedLegalEntityId { get; set; }

private bool DoCheck(EmployerAgreement employerAgreement)
{
return employerAgreement != null ? employerAgreement.SignedDate.HasValue : false;
}


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using SFA.DAS.EmployerAccounts.Models.EmployerAgreement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


namespace SFA.DAS.EmployerAccounts.Web.ViewModels
{

public class OrganisationAgreementViewModelV1
{
public OrganisationAgreementViewModel OrganisationAgreementViewModel { get; set; }

public bool OrganisationLookupPossible { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -100,8 +100,10 @@
<a href="@Url.Action(ControllerConstants.AboutYourAgreementActionName, ControllerConstants.EmployerAgreementControllerName, new { agreementid = employerAgreement.Pending.HashedAgreementId })" title="View agreement for @employerAgreement.LegalEntity.Name">Accept agreement</a>
}
else if (employerAgreement.HasSignedAgreement)
{
<a href="@Url.Action(ControllerConstants.DetailsActionName, ControllerConstants.EmployerAgreementControllerName, new { agreementid = employerAgreement.Signed.HashedAgreementId })" title="View agreement">View</a>
{
<a href="@Url.Action(ControllerConstants.ViewAllAgreementActionName, ControllerConstants.EmployerAgreementControllerName, new {accountLegalEntityHashedId = employerAgreement.LegalEntity.AccountLegalEntityPublicHashedId})" title="View all agreements">
View all agreements
</a>
}
</td>
<td data-label="Agreement ID">
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
@using SFA.DAS.EmployerAccounts.Web.Extensions
@using SFA.DAS.EmployerAccounts.Web.Helpers
@{Layout = "~/Views/Shared/_Layout_CDN.cshtml"; }
@model OrchestratorResponse<OrganisationAgreementViewModelV1>
@{
ViewBag.PageID = "organisations-agreements-details";
ViewBag.Title = "ViewAllAgreements";
ViewBag.Section = "organisations";
ViewBag.ZenDeskLabel = "eas-your-esfa-agreement";
}

@{
ViewBag.GaData.Vpv = "/accounts/agreements/view-your-agreement/agreement-details";
}


<h1>Your agreements with the Education and Skills Funding Agency (ESFA)</h1>

<div class="govuk-tabs" data-module="govuk-tabs">
<h2 class="govuk-tabs__title">
Contents
</h2>
<ul class="govuk-tabs__list">
<li class="govuk-tabs__list-item govuk-tabs__list-item--selected">
<a class="govuk-tabs__tab" href="#v3-agreement">
Published 9 January 2020
</a>
</li>
@if (@Model.Data.OrganisationAgreementViewModel.AgreementV2Signed)
{
<li class="govuk-tabs__list-item">
<a class="govuk-tabs__tab" href="#v2-agreement">
Published 1 May 2018
</a>
</li>
}
@if (@Model.Data.OrganisationAgreementViewModel.AgreementV1Signed)
{
<li class="govuk-tabs__list-item">
<a class="govuk-tabs__tab" href="#v1-agreement">
Published 1 May 2017
</a>
</li>
}
</ul>
<div class="govuk-tabs__panel" id="v3-agreement">
V3 Agreement

@if (@Model.Data.OrganisationAgreementViewModel.AgreementV3Signed)
{
<h2>Accepted on @Model.Data.OrganisationAgreementViewModel.AgreementV3SignedDate</h2>

<h2>Agreement between @Model.Data.OrganisationAgreementViewModel.Name and ESFA </h2>
<Subheading>
Published 9 January 2020
</Subheading>

<Insettext>
This is a new agreement.
</Insettext>

@Html.Partial("_AcceptedAgreement", @Model.Data.OrganisationAgreementViewModel.EmployerAgreementV3)
}
else
{
<h2>NOT ACCEPTED YET</h2>

<h2>Agreement between @Model.Data.OrganisationAgreementViewModel.Name and ESFA </h2>

<subheading>
Published 9 January 2020
</subheading>

@Html.Partial("_NotAcceptedAgreement", @Model.Data.OrganisationAgreementViewModel)
}
</div>
<div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="v2-agreement">

V2 Agreement

@if (@Model.Data.OrganisationAgreementViewModel.AgreementV2Signed)
{
<h2>Accepted on @Model.Data.OrganisationAgreementViewModel.AgreementV2SignedDate</h2>

<h2>Agreement between @Model.Data.OrganisationAgreementViewModel.Name and ESFA </h2>
<Subheading>
Published 1 May 2018
</Subheading>

<Insettext>
This is a variation of the agreement that we published 1 May 2017. We updated it to add clause 7 (transfer of funding).
</Insettext>

@Html.Partial("_AcceptedAgreement", @Model.Data.OrganisationAgreementViewModel.EmployerAgreementV2)
}
else
{
<p> Not Required </p>
}

</div>

<div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="v1-agreement">
V1 Agreement
@if (@Model.Data.OrganisationAgreementViewModel.AgreementV1Signed)
{
<h2>Accepted on @Model.Data.OrganisationAgreementViewModel.AgreementV1SignedDate</h2>

<h2>Agreement between @Model.Data.OrganisationAgreementViewModel.Name and ESFA </h2>
<Subheading>
Published 1 May 2017
</Subheading>

@Html.Partial("_AcceptedAgreement", @Model.Data.OrganisationAgreementViewModel.EmployerAgreementV1)
}
else
{
<p> Not Required </p>
}

</div>
</div>
Loading

0 comments on commit ad74481

Please sign in to comment.