Skip to content

Commit

Permalink
Merge pull request #1279 from DFE-Digital/feature/148313-build-transf…
Browse files Browse the repository at this point in the history
…ers-export-journey

(148313) Transfers export journey for Grant management and finance team
  • Loading branch information
Laura Porter authored Jan 5, 2024
2 parents 2be6ae6 + ed99951 commit 60b717c
Show file tree
Hide file tree
Showing 16 changed files with 339 additions and 43 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
outgoing trust sharepoint link field.
- Fix statistics page to show accurate data for Transfer's `by region` table.

### Added

- Add the ability to download Transfer projects for the Grant management and
finance team

### Changed

- Changed the existing Grant management and finance team Conversions download
page to include an information page about the download, and a tabbed view on
the index page to switch between Transfers and Conversions

## [Release-49][release-49]

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,34 @@ class All::Export::GrantManagementAndFinanceUnit::Conversions::ProjectsControlle
def index
authorize Project, :index?

@months = export_months
@data = export_months.map do |month|
{
month: month,
count: ProjectsForExportService.new.grant_management_and_finance_unit_conversion_projects(month: month.month, year: month.year).count
}
end
end

def show
authorize Project, :show?
@month = Date.new(year, month)
end

def csv
authorize Project, :index?

projects = ProjectsForExportService.new.grant_management_and_finance_unit_projects(month: month, year: year)
projects = ProjectsForExportService.new.grant_management_and_finance_unit_conversion_projects(month: month, year: year)
csv = Export::Conversions::GrantManagementAndFinanceUnitCsvExportService.new(projects).call

send_data csv, filename: "#{year}-#{month}_grant_management_and_finance_unit_conversions_export.csv", type: :csv, disposition: "attachment"
end

private def month
params[:month]
params[:month].to_i
end

private def year
params[:year]
params[:year].to_i
end

private def export_months
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class All::Export::GrantManagementAndFinanceUnit::Transfers::ProjectsController < ApplicationController
def index
authorize Project, :index?

@data = export_months.map do |month|
{
month: month,
count: ProjectsForExportService.new.grant_management_and_finance_unit_transfer_projects(month: month.month, year: month.year).count
}
end
end

def show
authorize Project, :show?
@month = Date.new(year, month)
end

def csv
authorize Project, :index?

projects = ProjectsForExportService.new.grant_management_and_finance_unit_transfer_projects(month: month, year: year)
csv = Export::Transfers::GrantManagementAndFinanceUnitCsvExportService.new(projects).call

send_data csv, filename: "#{year}-#{month}_grant_management_and_finance_unit_transfers_export.csv", type: :csv, disposition: "attachment"
end

private def month
params[:month].to_i
end

private def year
params[:year].to_i
end

private def export_months
12.times.map do |index|
Date.today.at_beginning_of_month - index.months
end
end
end
11 changes: 10 additions & 1 deletion app/services/projects_for_export_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ def funding_agreement_letters_projects(month:, year:)
AcademiesApiPreFetcherService.new.call!(projects)
end

def grant_management_and_finance_unit_projects(month:, year:)
def grant_management_and_finance_unit_conversion_projects(month:, year:)
projects = conversion_projects_by_advisory_board_date(month, year)
AcademiesApiPreFetcherService.new.call!(projects)
end

def grant_management_and_finance_unit_transfer_projects(month:, year:)
projects = transfer_projects_by_advisory_board_date(month, year)
AcademiesApiPreFetcherService.new.call!(projects)
end

def transfer_by_month_projects(month:, year:)
projects = transfer_projects_by_month_and_year(month, year)
AcademiesApiPreFetcherService.new.call!(projects)
Expand All @@ -30,4 +35,8 @@ def transfer_by_month_projects(month:, year:)
private def conversion_projects_by_advisory_board_date(month, year)
Conversion::Project.confirmed.filtered_by_advisory_board_date(month, year)
end

private def transfer_projects_by_advisory_board_date(month, year)
Transfer::Project.confirmed.filtered_by_advisory_board_date(month, year)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,48 @@
<%= render partial: "shared/navigation/all_projects_primary_navigation" %>
<% end %>

<h2 class="govuk-heading-l"><%= t("export.grant_management_and_finance_unit.conversions.index.title") %></h2>
<p class="govuk-body"><%= t("export.grant_management_and_finance_unit.conversions.index.body") %></p>
<% content_for :page_title do %>
<%= page_title(t("export.grant_management_and_finance_unit.conversions.index.title")) %>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">

<h1 class="govuk-heading-l">
<%= t("export.grant_management_and_finance_unit.conversions.index.title") %>
</h1>
<p><%= t("export.grant_management_and_finance_unit.conversions.index.body") %></p>

<nav class="moj-sub-navigation" aria-label="Project index sub-navigation">
<ul class="moj-sub-navigation__list">
<%= render partial: "shared/sub_navigation_item",
locals: {name: t("subnavigation.conversions"),
path: all_export_grant_management_and_finance_unit_conversions_projects_path} %>
<%= render partial: "shared/sub_navigation_item",
locals: {name: t("subnavigation.transfers"),
path: all_export_grant_management_and_finance_unit_transfers_projects_path} %>
</ul>
</nav>

<table class="govuk-table" name="projects_table" aria-label="Grant management and finance unit exports">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.date") %></th>
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.export") %></th>
</tr>
</thead>
<tbody class="govuk-table__body">
<% @months.each do |month| %>
<tr class="govuk-table__row">
<td class="govuk-table__header govuk-table__cell"><%= month.to_fs(:govuk_month) %></td>
<td class="govuk-table__cell">
<%= link_to t("project.table.body.export_for_html", date: month.to_fs(:govuk_month)), csv_all_export_grant_management_and_finance_unit_conversions_projects_path(month.month, month.year) %>
</td>
</tr>
<% end %>
</tbody>
</table>
<table class="govuk-table" name="projects_table" aria-label="Grant management and finance unit exports">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.date") %></th>
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.number_of_conversions") %></th>
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.export") %></th>
</tr>
</thead>
<tbody class="govuk-table__body">
<% @data.each do |month| %>
<tr class="govuk-table__row" id="<%= month[:month].to_fs(:govuk_month).tr(" ", "_") %>">
<td class="govuk-table__header govuk-table__cell"><%= month[:month].to_fs(:govuk_month) %></td>
<td class="govuk-table__cell"><%= month[:count] %></td>
<td class="govuk-table__cell">
<%= link_to t("project.table.body.export_for_html", date: month[:month].to_fs(:govuk_month)), show_all_export_grant_management_and_finance_unit_conversions_projects_path(month[:month].month, month[:month].year) %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<% content_for :primary_navigation do %>
<%= render partial: "shared/navigation/all_projects_primary_navigation" %>
<% end %>

<% content_for :page_title do %>
<%= page_title(t("export.grant_management_and_finance_unit.conversions.show.title", date: @month.to_fs(:govuk_month))) %>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= govuk_back_link(href: all_export_grant_management_and_finance_unit_conversions_projects_path) %>
<h1 class="govuk-heading-l"><%= t("export.grant_management_and_finance_unit.conversions.show.title", date: @month.to_fs(:govuk_month)) %></h1>
<%= t("export.grant_management_and_finance_unit.conversions.show.body_html") %>
<div class="govuk-form-group">
<%= govuk_button_link_to t("export.funding_agreement_letters.show.button"), "/projects/all/export/grant-management-and-finance-unit/conversions/#{@month.month}/#{@month.year}/csv" %>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<% content_for :primary_navigation do %>
<%= render partial: "shared/navigation/all_projects_primary_navigation" %>
<% end %>

<% content_for :page_title do %>
<%= page_title(t("export.grant_management_and_finance_unit.transfers.index.title")) %>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">

<h1 class="govuk-heading-l">
<%= t("export.grant_management_and_finance_unit.transfers.index.title") %>
</h1>
<p><%= t("export.grant_management_and_finance_unit.transfers.index.body") %></p>

<nav class="moj-sub-navigation" aria-label="Project index sub-navigation">
<ul class="moj-sub-navigation__list">
<%= render partial: "shared/sub_navigation_item",
locals: {name: t("subnavigation.conversions"),
path: all_export_grant_management_and_finance_unit_conversions_projects_path} %>
<%= render partial: "shared/sub_navigation_item",
locals: {name: t("subnavigation.transfers"),
path: all_export_grant_management_and_finance_unit_transfers_projects_path} %>
</ul>
</nav>

<table class="govuk-table" name="projects_table" aria-label="Grant management and finance unit exports">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.date") %></th>
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.number_of_transfers") %></th>
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.export") %></th>
</tr>
</thead>
<tbody class="govuk-table__body">
<% @data.each do |month| %>
<tr class="govuk-table__row" id="<%= month[:month].to_fs(:govuk_month).tr(" ", "_") %>">
<td class="govuk-table__header govuk-table__cell"><%= month[:month].to_fs(:govuk_month) %></td>
<td class="govuk-table__cell"><%= month[:count] %></td>
<td class="govuk-table__cell">
<%= link_to t("project.table.body.export_for_html", date: month[:month].to_fs(:govuk_month)), show_all_export_grant_management_and_finance_unit_transfers_projects_path(month[:month].month, month[:month].year) %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<% content_for :primary_navigation do %>
<%= render partial: "shared/navigation/all_projects_primary_navigation" %>
<% end %>

<% content_for :page_title do %>
<%= page_title(t("export.grant_management_and_finance_unit.transfers.show.title", date: @month.to_fs(:govuk_month))) %>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= govuk_back_link(href: all_export_grant_management_and_finance_unit_transfers_projects_path) %>
<h1 class="govuk-heading-l"><%= t("export.grant_management_and_finance_unit.transfers.show.title", date: @month.to_fs(:govuk_month)) %></h1>
<%= t("export.grant_management_and_finance_unit.transfers.show.body_html") %>
<div class="govuk-form-group">
<%= govuk_button_link_to t("export.funding_agreement_letters.show.button"), "/projects/all/export/grant-management-and-finance-unit/transfers/#{@month.month}/#{@month.year}/csv" %>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions app/views/all/export/projects/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
<h4 class="govuk-heading-m"><%= t("export.landing_page.transfers.title") %></h4>
<p class="govuk-body"><%= t("export.landing_page.transfers.body") %></p>
<p class="govuk-body"><%= t("export.landing_page.transfers.academies_due_to_transfer_html", link: all_export_by_month_transfers_projects_path) %></p>
<p class="govuk-body"><%= t("export.landing_page.transfers.grant_management_html", link: all_export_grant_management_and_finance_unit_transfers_projects_path) %></p>
</div>
</div>
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ en:
revised: Revised date
active_users: Active users
inactive_users: Inactive users
conversions: Conversions
transfers: Transfers
pages:
academies_api_client_timeout:
title: Sorry, there was a problem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,29 @@ en:
conversions:
index:
title: Grant management and finance unit exports
body: Conversions by Advisory board date
body: Check which projects were approved at each advisory board meeting.
show:
title: "%{date} Grants Management and Finance Unit export"
body_html:
<p>This export contains data to help you process pre-opening grants for new academies, including:</p>
<ul>
<li>converter grant</li>
<li>sponsored grant (fast track, intermediate or full sponsored)</li>
</ul>
<p>It can take a little time to create these files. Thank you for your patience.</p>
transfers:
index:
title: Grant management and finance unit exports
body: Check which projects were approved at each advisory board meeting.
show:
title: "%{date} Grants Management and Finance Unit export"
body_html:
<p>This export contains data to help you process pre-opening grants for transferring academies, including:</p>
<ul>
<li>standard transfer support grant element</li>
<li>academy transfer grant fund (fast track, intermediate or full sponsored)</li>
</ul>
<p>It can take a little time to create these files. Thank you for your patience.</p>
show:
title: "%{date} grant management and funding unit export"
body_html:
Expand Down
1 change: 1 addition & 0 deletions config/locales/export/landing_page.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ en:
title: Transfer project data
body: View tables and download spreadsheets that show information about transfers.
academies_due_to_transfer_html: You can <a href="%{link}">check which academies are due to transfer in an particular month</a>.
grant_management_html: You can <a href="%{link}">get information pre-opening grants for transferring academies</a>.
2 changes: 2 additions & 0 deletions config/locales/project.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ en:
confirmed_transfer_date: Confirmed transfer date
revised_transfer_date: Revised transfer date
all_transfers: All transfers
number_of_conversions: Number of conversions
number_of_transfers: Number of transfers
body:
type_name:
conversion_project: Conversion
Expand Down
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@
get ":month/:year", to: "projects#show", constraints: {month: MONTH_1_12_REGEX, year: YEAR_2000_2499_REGEX}, as: :show
get ":month/:year/csv", to: "projects#csv", constraints: {month: MONTH_1_12_REGEX, year: YEAR_2000_2499_REGEX}, as: :csv
end
namespace :transfers do
get "/", to: "projects#index"
get ":month/:year", to: "projects#show", constraints: {month: MONTH_1_12_REGEX, year: YEAR_2000_2499_REGEX}, as: :show
get ":month/:year/csv", to: "projects#csv", constraints: {month: MONTH_1_12_REGEX, year: YEAR_2000_2499_REGEX}, as: :csv
end
end
namespace :by_month, path: "by-month" do
namespace :transfers do
Expand Down
Loading

0 comments on commit 60b717c

Please sign in to comment.