Skip to content

Commit

Permalink
CON-1597-merge-with-master
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephek committed Apr 1, 2020
2 parents 03ec396 + e7bf7e4 commit b1d20b4
Show file tree
Hide file tree
Showing 24 changed files with 160 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,155 +133,65 @@ SELECT DATEADD(dd, DATEDIFF(dd, 0, tl.DateCreated), 0) AS DateCreated,
AND DateCreated >= @FromDate
AND DateCreated < @ToDate
AND tl.TransactionType = 5
and tl.Amount > 0
AND tl.Amount > 0

UNION ALL

-- sender transfers
SELECT
DATEADD(dd, DATEDIFF(dd, 0, tl.DateCreated), 0) AS DateCreated,
tl.AccountId AS AccountId,
tlt.[Description] AS TransactionType,
NULL AS PayeScheme,
NULL AS PayrollYear,
NULL AS PayrollMonth,
NULL AS LevyDeclared,
NULL AS EnglishFraction,
NULL AS TenPercentTopUp,
CASE tlt.[Description]
WHEN 'Payment' THEN meta.ProviderName
ELSE NULL
END AS TrainingProvider,
NULL AS Uln,
NULL AS Apprentice,
trans.CourseName AS ApprenticeTrainingCourse,
meta.CourseLevel AS ApprenticeTrainingCourseLevel,
SUM(tl.Amount) AS PaidFromLevy,
SUM(tl.SfaCoInvestmentAmount) AS EmployerContribution,
SUM(tl.EmployerCoInvestmentAmount) AS GovermentContribution,
SUM(tl.Amount) AS Total,
tl.TransferSenderAccountId AS TransferSenderAccountId,
tl.TransferSenderAccountName AS TransferSenderAccountName,
tl.TransferReceiverAccountId AS TransferReceiverAccountId,
tl.TransferReceiverAccountName AS TransferReceiverAccountName
FROM [employer_financial].[TransactionLine] tl

JOIN [employer_financial].[TransactionLineTypes] tlt
ON tl.TransactionType = tlt.TransactionType

LEFT JOIN
(SELECT tl2.AccountId, tr2.CourseName, tl2.PeriodEnd
FROM [employer_financial].[TransactionLine] tl2

LEFT JOIN [employer_financial].[AccountTransfers] tr2
ON (tr2.SenderAccountId = tl2.AccountId and tr2.PeriodEnd = tl2.PeriodEnd)

WHERE tl2.AccountId = @AccountId
AND tl2.TransactionType = 4 -- Transfer
) as trans
on trans.AccountId = tl.AccountId
and trans.PeriodEnd = tl.PeriodEnd

LEFT JOIN
(SELECT DISTINCT p3.AccountId, p3.PeriodEnd, m3.ProviderName, m3.ApprenticeshipCourseLevel as 'CourseLevel'
FROM [employer_financial].[Payment] p3
inner join [employer_financial].[TransactionLine] tl3
on tl3.AccountId = @AccountId
AND tl3.AccountId = tl3.TransferSenderAccountId
AND tl3.TransactionType IN (3, 4)
INNER JOIN [employer_financial].[PaymentMetaData] m3
ON m3.Id = p3.PaymentMetaDataId
AND p3.AccountId = tl3.TransferReceiverAccountId
WHERE m3.ProviderName IS NOT NULL
) as meta
on meta.AccountId = tl.TransferReceiverAccountId
and meta.PeriodEnd = tl.PeriodEnd

WHERE tl.AccountId = @AccountId
AND tl.AccountId = tl.TransferSenderAccountId
AND tl.TransactionType IN (3, 4) -- Payment and Transfer
GROUP BY
tl.DateCreated,
tl.AccountId,
tlt.[Description],
tl.PeriodEnd,
meta.ProviderName,
trans.CourseName,
meta.CourseLevel,
tl.TransferSenderAccountId,
tl.TransferSenderAccountName,
tl.TransferReceiverAccountId,
tl.TransferReceiverAccountName

UNION

-- receiver transfers
SELECT
DATEADD(dd, DATEDIFF(dd, 0, tl.DateCreated), 0) AS DateCreated,
tl.AccountId AS AccountId,
tlt.[Description] AS TransactionType,
NULL AS PayeScheme,
NULL AS PayrollYear,
NULL AS PayrollMonth,
NULL AS LevyDeclared,
NULL AS EnglishFraction,
NULL AS TenPercentTopUp,
CASE tlt.[Description]
WHEN 'Payment' THEN meta.ProviderName
ELSE NULL
END AS TrainingProvider,
NULL AS Uln,
NULL AS Apprentice,
trans.CourseName AS ApprenticeTrainingCourse,
meta.CourseLevel AS ApprenticeTrainingCourseLevel,
SUM(tl.Amount) AS PaidFromLevy,
SUM(tl.SfaCoInvestmentAmount) AS EmployerContribution,
SUM(tl.EmployerCoInvestmentAmount) AS GovermentContribution,
SUM(tl.Amount) AS Total,
tl.TransferSenderAccountId AS TransferSenderAccountId,
tl.TransferSenderAccountName AS TransferSenderAccountName,
tl.TransferReceiverAccountId AS TransferReceiverAccountId,
tl.TransferReceiverAccountName AS TransferReceiverAccountName
FROM [employer_financial].[TransactionLine] tl

JOIN [employer_financial].[TransactionLineTypes] tlt
ON tl.TransactionType = tlt.TransactionType
LEFT JOIN
(SELECT tl2.AccountId, tr2.CourseName, tl2.PeriodEnd
FROM [employer_financial].[TransactionLine] tl2

LEFT JOIN [employer_financial].[AccountTransfers] tr2
ON (tr2.ReceiverAccountId = tl2.AccountId and tr2.PeriodEnd = tl2.PeriodEnd)

WHERE tl2.AccountId = @AccountId
AND tl2.TransactionType = 4 -- Transfer
) as trans
on trans.AccountId = tl.AccountId
and trans.PeriodEnd = tl.PeriodEnd

LEFT JOIN
(SELECT DISTINCT p3.AccountId, p3.PeriodEnd, m3.ProviderName, m3.ApprenticeshipCourseLevel as 'CourseLevel'
FROM [employer_financial].[Payment] p3
INNER JOIN [employer_financial].[PaymentMetaData] m3
ON m3.Id = p3.PaymentMetaDataId
AND p3.AccountId = @AccountId
WHERE m3.ProviderName IS NOT NULL
) as meta
on meta.AccountId = tl.TransferReceiverAccountId
and meta.PeriodEnd = tl.PeriodEnd

WHERE tl.AccountId = @AccountId
AND tl.AccountId = tl.TransferReceiverAccountId
AND tl.TransactionType IN (3, 4) -- Payment and Transfer
GROUP BY
tl.DateCreated,
tl.AccountId,
tlt.[Description],
tl.PeriodEnd,
meta.ProviderName,
trans.CourseName,
meta.CourseLevel,
tl.TransferSenderAccountId,
tl.TransferSenderAccountName,
tl.TransferReceiverAccountId,
tl.TransferReceiverAccountName
-- sender transfers
SELECT DATEADD(dd, DATEDIFF(dd, 0, [employer_financial].[AccountTransfers].CreatedDate), 0) AS DateCreated,
[employer_financial].[AccountTransfers].SenderAccountId AS AccountId,
'Transfer' AS TransactionType,
NULL AS PayeScheme,
NULL AS PayrollYear,
NULL AS PayrollMonth,
NULL AS LevyDeclared,
NULL AS EnglishFraction,
NULL AS TenPercentTopUp,
NULL AS TrainingProvider,
NULL AS Uln,
NULL AS Apprentice,
[employer_financial].[AccountTransfers].CourseName AS ApprenticeTrainingCourse,
[employer_financial].[AccountTransfers].CourseLevel AS ApprenticeTrainingCourseLevel,
cast([AccountTransfers].[Amount]as decimal(18,4)) AS PaidFromLevy,
NULL AS EmployerContribution,
NULL AS GovermentContribution,
cast([AccountTransfers].[Amount] as decimal(18,4)) AS Total,
[employer_financial].[AccountTransfers].SenderAccountID AS TransferSenderAccountId,
[employer_financial].[AccountTransfers].[SenderAccountName] AS TransferSenderAccountName,
[employer_financial].[AccountTransfers].[ReceiverAccountId] AS TransferReceiverAccountId,
[employer_financial].[AccountTransfers].[ReceiverAccountName] AS TransferReceiverAccountName
FROM [employer_financial].[AccountTransfers]
WHERE SenderAccountId = @AccountId
AND [employer_financial].[AccountTransfers].[CreatedDate] >= @FromDate
AND [employer_financial].[AccountTransfers].[CreatedDate] < @ToDate

UNION ALL

-- receiver transfers
SELECT DATEADD(dd, DATEDIFF(dd, 0, [employer_financial].[AccountTransfers].CreatedDate), 0) AS DateCreated,
[employer_financial].[AccountTransfers].SenderAccountId AS AccountId,
'Transfer' AS TransactionType,
NULL AS PayeScheme,
NULL AS PayrollYear,
NULL AS PayrollMonth,
NULL AS LevyDeclared,
NULL AS EnglishFraction,
NULL AS TenPercentTopUp,
NULL AS TrainingProvider,
NULL AS Uln,
NULL AS Apprentice,
[employer_financial].[AccountTransfers].CourseName AS ApprenticeTrainingCourse,
[employer_financial].[AccountTransfers].CourseLevel AS ApprenticeTrainingCourseLevel,
cast([AccountTransfers].[Amount] as decimal(18,4)) AS PaidFromLevy,
NULL AS EmployerContribution,
NULL AS GovermentContribution,
cast([employer_financial].[AccountTransfers].[Amount] as decimal(18,4)) AS Total,
[employer_financial].[AccountTransfers].SenderAccountID AS TransferSenderAccountId,
[employer_financial].[AccountTransfers].[SenderAccountName] AS TransferSenderAccountName,
[employer_financial].[AccountTransfers].[ReceiverAccountId] AS TransferReceiverAccountId,
[employer_financial].[AccountTransfers].[ReceiverAccountName] AS TransferReceiverAccountName
FROM [employer_financial].[AccountTransfers]
WHERE [employer_financial].[AccountTransfers].[ReceiverAccountId] = @AccountId
AND [employer_financial].[AccountTransfers].[CreatedDate] >= @FromDate
AND [employer_financial].[AccountTransfers].[CreatedDate] < @ToDate
ORDER BY datecreated
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ public async Task<ActionResult> Sign(string agreementId, string hashedAccountId,
}
else
{
flashMessage.Headline = "All agreements signed";
flashMessage.Message = "You’ve successfully signed your organisation agreement(s)";
flashMessage.Headline = "Agreement accepted";
flashMessage.Message = "You’ve successfully accepted your organisation agreement(s)";
result = RedirectToAction(ControllerConstants.IndexActionName, ControllerConstants.EmployerTeamControllerName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@
<Content Include="Views\EmployerTeam\VacancyClosed.cshtml" />
<Content Include="Views\Shared\_NotSignedV3AgreementMessage.cshtml" />
<Content Include="Views\Shared\_NotSignedV3AgreementMessage_CDN.cshtml" />
<Content Include="Views\Shared\_COVID19GuidanceBanner.cshtml" />
<Content Include="Views\EmployerTeam\SingleApprenticeshipContinueSetup.cshtml" />
<Content Include="Views\EmployerTeam\SingleApprenticeshipApproved.cshtml" />
<Content Include="Views\EmployerTeam\SingleApprenticeshipWithTrainingProvider.cshtml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
@if (Html.IsAuthorized("EmployerFeature.Transfers"))
{
<p class="govuk-body">This agreement creates a legal contract between <span class="govuk-!-font-weight-bold">@Model.Data.EmployerAgreement.LegalEntityName</span> and the <span class="bold">Education and Skills Funding Agency (ESFA)</span>. It allows you to transfer funds to other employers and pay training providers for apprenticeships.</p>
<p class="govuk-body">You need to ensure you have the authority from your organisation before you sign this agreement.</p>
<p class="govuk-body">You need to ensure you have the authority from your organisation before you accept this agreement.</p>
}
else
{
<p class="govuk-body">This agreement creates a legal contract between <span class="govuk-!-font-weight-bold">@Model.Data.EmployerAgreement.LegalEntityName</span>and the <span class="govuk-!-font-weight-bold">Education and Skills Funding Agency (ESFA)</span>.It allows ESFA to pay your training providers for apprenticeships.</p>
<p class="govuk-body"> You need to make sure you have authority from your organisation before you sign this agreement.</p>
<p class="govuk-body"> You need to make sure you have authority from your organisation before you accept this agreement.</p>
}

<form method="get" action="@Url.Action(ControllerConstants.SignAgreementActionName ,ControllerConstants.EmployerAgreementControllerName)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ViewBag.Title = name;
ViewBag.Section = "team";
var errorMessage = string.Empty;

ViewBag.ZenDeskLabel = "eas-change-team-member";
}

@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
@{
ViewBag.PageID = "page-manage-team";
ViewBag.Title = "Manage team members";
ViewBag.Section = "team";
ViewBag.Section = "team";
ViewBag.ZenDeskLabel = "eas-view-team-member";

if (!string.IsNullOrEmpty(Model.FlashMessage?.HiddenFlashMessageInformation))
{
ViewBag.PageID = Model.FlashMessage.HiddenFlashMessageInformation;
}

}

@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<p>Before connecting to another employer, both employers will need to:</p>
<ul class="list list-bullet">
<li>read and understand the <a href="https://www.gov.uk/government/publications/apprenticeship-funding-and-performance-management-rules-2017-to-2018">rules for sending and receiving transfers</a></li>
<li>sign the updated ESFA organisation agreement once it's available. View <a href="https://www.gov.uk/government/publications/apprenticeship-funding-legal-agreement-to-enable-spending/guidance-note-on-the-employer-agreement">guidance on the updated agreement</a> to find out what's changed.</li>
<li>accept the updated ESFA organisation agreement once it's available. View <a href="https://www.gov.uk/government/publications/apprenticeship-funding-legal-agreement-to-enable-spending/guidance-note-on-the-employer-agreement">guidance on the updated agreement</a> to find out what's changed.</li>
</ul>
}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
}
else if (Model.AuthorizationResult.HasError<EmployerFeatureAgreementNotSigned>())
{
<p>Before starting a connection, both the sending and receiving employers need to read and understand the <a href="https://www.gov.uk/government/publications/apprenticeship-funding-and-performance-management-rules-2017-to-2018">rules for sending and receiving transfers</a> and sign the updated organisation agreement with ESFA.</p>
<p>Before starting a connection, both the sending and receiving employers need to read and understand the <a href="https://www.gov.uk/government/publications/apprenticeship-funding-and-performance-management-rules-2017-to-2018">rules for sending and receiving transfers</a> and accept the updated organisation agreement with ESFA.</p>

<div class="grid-row">
<div class="column-two-thirds">
<a class="button" href="@Url.Action("Index", "EmployerAgreement" )">Sign ESFA agreement</a>
<a class="button" href="@Url.Action("Index", "EmployerAgreement" )">Accept ESFA agreement</a>
</div>
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion src/SFA.DAS.EmployerFinance.Web/App_Start/FilterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void RegisterGlobalFilters(GlobalFilterCollection filters)
filters.AddUnitOfWorkFilter();
filters.AddAuthorizationFilter();
filters.AddUnauthorizedAccessExceptionFilter();
filters.Add(new GoogleAnalyticsFilter());
filters.Add(new AnalyticsFilter());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,51 @@

namespace SFA.DAS.EmployerFinance.Web.Filters
{
public class GoogleAnalyticsFilter : ActionFilterAttribute
public class AnalyticsFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
string userId = null;
string hashedAccountId = null;
string userEmail = null;
string userName = null;

var thisController = filterContext.Controller as BaseController;
if (thisController != null)
{
userId = thisController.OwinWrapper.GetClaimValue(@"sub");
userEmail = thisController.OwinWrapper.GetClaimValue(@"email");
userName = $"{thisController.OwinWrapper.GetClaimValue(@"firstname")} {thisController.OwinWrapper.GetClaimValue(@"lastname")}";
}

if (filterContext.ActionParameters.ContainsKey("hashedAccountId"))
{
hashedAccountId = filterContext.ActionParameters["hashedAccountId"] as string;
}
else if(filterContext.Controller.ControllerContext.RouteData.Values.ContainsKey("hashedAccountId"))
{
hashedAccountId = filterContext.Controller.ControllerContext.RouteData.Values["hashedAccountId"] as string;
}

filterContext.Controller.ViewBag.GaData = new GaData
filterContext.Controller.ViewBag.AnalyticsData = new AnalyticsData
{
UserId = userId,
Acc = hashedAccountId
Acc = hashedAccountId,
UserEmail = userEmail,
UserName = userName
};

base.OnActionExecuting(filterContext);
}

public string DataLoaded { get; set; }

public class GaData
public class AnalyticsData
{
public GaData()
{

}
public string DataLoaded { get; set; } = "dataLoaded";
public string UserId { get; set; }

public string UserEmail { get; set; }
public string UserName { get; set; }
public string Vpv { get; set; }
public string Acc { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
<Compile Include="Extensions\TimeSpanExtensions.cs" />
<Compile Include="Extensions\UrlHelperExtensions.cs" />
<Compile Include="Filters\LevyEmployerTypeOnly.cs" />
<Compile Include="Filters\GoogleAnalyticsFilter.cs" />
<Compile Include="Filters\AnalyticsFilter.cs" />
<Compile Include="Extensions\DateTimeExtensions.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
Expand Down Expand Up @@ -637,6 +637,9 @@
<Content Include="src\sass\_cookiebanner.scss" />
<Content Include="Views\Shared\_ZenDeskWidget.cshtml" />
<Content Include="Views\Shared\_COVID19GuidanceBanner.cshtml" />
<Content Include="Views\Shared\_GoogleTagManager.cshtml" />
<Content Include="Views\Shared\_GoogleTagManagerNoScript.cshtml" />
<Content Include="Views\Shared\_ZenDeskApiPush.cshtml" />
</ItemGroup>
<ItemGroup />
<PropertyGroup>
Expand Down
Loading

0 comments on commit b1d20b4

Please sign in to comment.