Skip to content

Commit

Permalink
Merge branch 'JB/TM-302-Endofyear-Remaining-Allowance-Finance-Breakdo…
Browse files Browse the repository at this point in the history
…wn-WEB' into SH/TM-301-big-box-summary-available-allowance-on-finance-details-page
  • Loading branch information
Sajid Habib committed Apr 12, 2022
2 parents a331017 + 30a9758 commit 1c58ff6
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ public async Task<ActionResult> Index(string hashedAccountId)
[DasAuthorize("EmployerFeature.FinanceDetails")]
[HttpGet]
[Route("transfers/financial-breakdown")]
public ActionResult FinancialBreakdown(string hashedAccountId)
public async Task<ActionResult> FinancialBreakdown(string hashedAccountId)
{
var viewModel = await _transfersOrchestrator.GetFinancialBreakdownViewModel(hashedAccountId);
return View();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task<OrchestratorResponse<IndexViewModel>> GetIndexViewModel(string
var accountDetail = _accountApiClient.GetAccount(hashedAccountId);

var renderCreateTransfersPledgeButtonTask = _authorizationService.IsAuthorizedAsync(EmployerUserRole.OwnerOrTransactor);
var renderApplicationListButton = _featureTogglesService.GetFeatureToggle("ApplicationList");
// var renderApplicationListButton = _featureTogglesService.GetFeatureToggle("ApplicationList");

await Task.WhenAll(indexTask, renderCreateTransfersPledgeButtonTask, accountDetail);

Expand All @@ -61,12 +61,27 @@ public async Task<OrchestratorResponse<IndexViewModel>> GetIndexViewModel(string
PledgesCount = indexTask.Result.PledgesCount,
ApplicationsCount = indexTask.Result.ApplicationsCount,
RenderCreateTransfersPledgeButton = renderCreateTransfersPledgeButtonTask.Result,
RenderApplicationListButton = renderApplicationListButton.IsEnabled,
RenderApplicationListButton = true,//renderApplicationListButton.IsEnabled,
StartingTransferAllowance = accountDetail.Result.StartingTransferAllowance,
FinancialYearString = DateTime.UtcNow.ToFinancialYearString(),
HashedAccountID = hashedAccountId
}
};
}

public async Task<OrchestratorResponse<FinancialBreakdownViewModel>> GetFinancialBreakdownViewModel(string hashedAccountId)
{
var accountId = _hashingService.DecodeValue(hashedAccountId);
var financialBreakdownTask = await _manageApprenticeshipsService.GetFinancialBreakdown(accountId);

return new OrchestratorResponse<FinancialBreakdownViewModel>
{
Data = new FinancialBreakdownViewModel
{
TransferConnections = financialBreakdownTask.TransferConnections,
HashedAccountID = hashedAccountId
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ public class FinancialBreakdownViewModel
public decimal StartingTransferAllowance { get; set; }
public string FinancialYearString { get; set; }
public string HashedAccountID { get; set; }
public long TransferConnections { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using SFA.DAS.EmployerFinance.Interfaces.OuterApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SFA.DAS.EmployerFinance.Infrastructure.OuterApiRequests.Transfers
{
public class GetFinancialBreakdownRequest : IGetApiRequest
{
private readonly long _accountId;

public GetFinancialBreakdownRequest(long accountId)
{
_accountId = accountId;
}

public string GetUrl => $"Transfers/{_accountId}/transfers/financial-breakdown";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SFA.DAS.EmployerFinance.Infrastructure.OuterApiResponses.Transfers
{
public class GetFinancialBreakdownResponse
{
public long Commitments { get; set; }
public long ApprovedPledgeApplications { get; set; }
public long AcceptedPledgeApplications { get; set; }
public long PledgeOriginatedCommitments { get; set; }
public long TransferConnections { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ namespace SFA.DAS.EmployerFinance.Services
public interface IManageApprenticeshipsService
{
Task<GetIndexResponse> GetIndex(long accountId);
Task<GetFinancialBreakdownResponse> GetFinancialBreakdown(long accountId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ public async Task<GetIndexResponse> GetIndex(long accountId)
{
return await _apiClient.Get<GetIndexResponse>(new GetIndexRequest(accountId));
}

public async Task<GetFinancialBreakdownResponse> GetFinancialBreakdown(long accountId)
{
return await _apiClient.Get<GetFinancialBreakdownResponse>(new GetIndexRequest(accountId));
}
}
}

0 comments on commit 1c58ff6

Please sign in to comment.