Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP-5424: Add capital disregards CYA, review & print/certificate and means report #7410

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions app/helpers/capital_disregard_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module CapitalDisregardHelper
def mandatory_capital_disregards_list(legal_aid_application)
capital_disregard_names(legal_aid_application.mandatory_capital_disregards).join("<br>").html_safe
end

def mandatory_capital_disregards_detailed_list(legal_aid_application)
legal_aid_application.mandatory_capital_disregards.map { |capital_disregard|
capital_disregards_detail_for(capital_disregard)
}.join("<br><br>").html_safe
end

def discretionary_capital_disregards_list(legal_aid_application)
capital_disregard_names(legal_aid_application.discretionary_capital_disregards).join("<br>").html_safe
end

def discretionary_capital_disregards_detailed_list(legal_aid_application)
legal_aid_application.discretionary_capital_disregards.map { |capital_disregard|
capital_disregards_detail_for(capital_disregard)
}.join("<br><br>").html_safe
end

# NOTE: single digit days get extra left padding so we strip for consistent spacing
def amount_and_date_received(capital_disregard)
"#{gds_number_to_currency(capital_disregard.amount)} on #{capital_disregard.date_received.to_s.strip}"
end

private

def capital_disregard_names(capital_disregard_association)
capital_disregard_association
.map do |capital_disregard|
name_t(capital_disregard)
end
end

def capital_disregards_detail_for(capital_disregard)
[
name_t(capital_disregard),
payment_reason_for(capital_disregard),
amount_and_date_received(capital_disregard),
held_in(capital_disregard.account_name),
].compact.join("<br>").html_safe
end

def payment_reason_for(capital_disregard)
t("providers.means.capital_disregards.payment_reason_for", reason: capital_disregard.payment_reason) if capital_disregard.payment_reason.present?
end

def name_t(capital_disregard)
type = capital_disregard.mandatory? ? "mandatory" : "discretionary"

t("providers.means.capital_disregards.#{type}.#{capital_disregard.name}")
end

def held_in(account_name)
t("providers.means.capital_disregards.held_in", account_name:)
end
end
17 changes: 17 additions & 0 deletions app/views/providers/means_reports/_capital_disregards.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<h2 class="govuk-heading-m"><%= t(".heading") %></h2>
<%= govuk_summary_list(
naseberry marked this conversation as resolved.
Show resolved Hide resolved
actions: false,
classes: "govuk-!-margin-bottom-9",
html_attributes: { id: "capital-disregards-questions" },
) do |summary_list| %>

<%= summary_list.with_row(html_attributes: { id: "app-check-your-mandatory_capital_disregards" }) do |row| %>
<%= row.with_key(text: t(".mandatory.heading"), classes: "govuk-!-width-one-half") %>
<%= row.with_value { @legal_aid_application.mandatory_capital_disregards.any? ? mandatory_capital_disregards_detailed_list(@legal_aid_application) : t("generic.none") } %>
<% end %>

<%= summary_list.with_row(html_attributes: { id: "app-check-your-discretionary_capital_disregards" }) do |row| %>
<%= row.with_key(text: t(".discretionary.heading"), classes: "govuk-!-width-one-half") %>
<%= row.with_value(text: @legal_aid_application.discretionary_capital_disregards.any? ? discretionary_capital_disregards_detailed_list(@legal_aid_application) : t("generic.none")) %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<%= t(".assets_heading") %>
</h2>
<% individual = "_with_partner" if @legal_aid_application.applicant.has_partner_with_no_contrary_interest? %>
<%= render "shared/check_answers/assets", read_only: true, individual: %>
<%= render "shared/check_answers/assets", means_report: true, read_only: true, individual: %>

<% if @legal_aid_application.passported? && @manual_review_determiner.manual_review_required? %>
<div class="govuk-!-padding-bottom-8"></div>
Expand Down
22 changes: 22 additions & 0 deletions app/views/shared/check_answers/_assets.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% read_only = false unless local_assigns.key?(:read_only) %>
<% means_report = false unless local_assigns.key?(:means_report) %>
<% online_savings_accounts = @legal_aid_application.online_savings_accounts_balance %>
<% online_current_accounts = @legal_aid_application.online_current_accounts_balance %>
<% showing_bank_accounts = @legal_aid_application.partner_uploading_bank_statements? ||
Expand All @@ -16,6 +17,7 @@
<% if showing_bank_accounts %>
<h2 class="govuk-heading-m"><%= t(".assets.bank_accounts") %></h2>
<% end %>

<% if @legal_aid_application.non_passported? && !@legal_aid_application.client_uploading_bank_statements? %>
<!-- non-passported truelayer only -->

Expand Down Expand Up @@ -83,6 +85,8 @@
else
:offline_accounts
end %>

<%# offline savings accounts for partner %>
jsugarman marked this conversation as resolved.
Show resolved Hide resolved
<div class="govuk-grid-row" id="app-check-your-answers__partner_offline_accounts_link">
<% if read_only == false %>
<div class="govuk-grid-column-two-thirds">
Expand All @@ -99,6 +103,7 @@
</div>
<% end %>
</div>

<%= govuk_summary_list(classes: "govuk-!-margin-bottom-9", html_attributes: { "data-test": "partner-bank-accounts" }) do |summary_list| %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__partner_offline_current_accounts" }) do |row| %>
<%= row.with_key(text: t(".assets.partner_current_account"), classes: "govuk-!-width-one-half") %>
Expand All @@ -110,6 +115,7 @@
<% end %>
<% end %>

<%# offline savings accounts for bank statement uploads or passported %>
<% if @legal_aid_application.uploading_bank_statements? || !@legal_aid_application.non_passported? %>
<div class="govuk-grid-row" id="app-check-your-answers__joint_offline_accounts_link">
<% if read_only == false %>
Expand Down Expand Up @@ -140,12 +146,14 @@
<% end %>
<% end %>

<%# offline savings accounts for non-passpoted truelayer %>
<% if @legal_aid_application.non_passported? && !@legal_aid_application.uploading_bank_statements? %>
<div class="govuk-!-padding-bottom-9">
<%= render "shared/check_answers/offline_savings_accounts", read_only: %>
</div>
<% end %>

<%# savings and investments %>
<div class="govuk-!-padding-bottom-9">
<%= render(
"shared/check_answers/one_link_section",
Expand All @@ -160,6 +168,7 @@
) %>
</div>

<%# other assets %>
<%= render(
"shared/check_answers/one_link_section",
name: :other_assets,
Expand All @@ -173,8 +182,10 @@
read_only:,
) %>

<%# asset restrictions %>
<%= render("shared/check_answers/restrictions", read_only:, individual:) if @legal_aid_application.own_capital? %>

<%# policy disregards %>
<section class="print-no-break">
<% if @legal_aid_application.policy_disregards.present? %>
<%= render(
Expand All @@ -187,4 +198,15 @@
) %>
<% end %>
</section>

<%# capital disregards %>
<section class="print-no-break">
<% if Setting.means_test_review_a? %>
<% if means_report %>
<%= render("providers/means_reports/capital_disregards", read_only:, individual:) %>
<% else %>
<%= render("shared/check_answers/capital_disregards", read_only:, individual:) %>
<% end %>
<% end %>
</section>
</section>
41 changes: 41 additions & 0 deletions app/views/shared/check_answers/_capital_disregard_details.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<% capital_disregard_type = capital_disregard.mandatory? ? "mandatory" : "discretionary" %>
<% capital_disregard_name = t("providers.means.capital_disregards.#{capital_disregard_type}.#{capital_disregard.name}") %>

<%= govuk_summary_list(
actions: !read_only,
classes: "govuk-!-margin-bottom-9",
html_attributes: { id: "#{capital_disregard_type}-capital-disregard-questions_#{index}" },
) do |summary_list| %>

<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__capital_disregard_#{index}_change_link" }) do |row| %>
<%= row.with_key(text: t(".#{capital_disregard_type}.heading", count: index + 1), classes: "govuk-!-width-one-half govuk-heading-m") %>
<%= row.with_value(text: nil) %>
<%= row.with_action(
text: t("generic.change"),
href: providers_legal_aid_application_means_capital_disregards_add_detail_path(@legal_aid_application, capital_disregard),
visually_hidden_text: capital_disregard_name,
) %>
<% end %>

<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__payment_type" }) do |row| %>
<%= row.with_key(text: t(".questions.payment_type"), classes: "govuk-!-width-one-half") %>
<%= row.with_value { capital_disregard_name } %>
<% end %>

<% if capital_disregard.payment_reason.present? %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__payment_reason" }) do |row| %>
<%= row.with_key(text: t(".questions.payment_reason"), classes: "govuk-!-width-one-half") %>
<%= row.with_value { capital_disregard.payment_reason } %>
<% end %>
<% end %>

<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__amount_and_date_received" }) do |row| %>
<%= row.with_key(text: t(".questions.amount_and_date_received"), classes: "govuk-!-width-one-half") %>
<%= row.with_value { amount_and_date_received(capital_disregard) } %>
<% end %>

<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__bank_account_name" }) do |row| %>
<%= row.with_key(text: t(".questions.bank_account_name"), classes: "govuk-!-width-one-half") %>
<%= row.with_value { capital_disregard.account_name } %>
<% end %>
<% end %>
39 changes: 39 additions & 0 deletions app/views/shared/check_answers/_capital_disregards.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<h2 class="govuk-heading-m"><%= t(".heading#{individual}") %></h2>
<%= govuk_summary_list(
actions: !read_only,
classes: "govuk-!-margin-bottom-9",
html_attributes: { id: "capital-disregards-questions" },
) do |summary_list| %>

<%= summary_list.with_row(html_attributes: { id: "app-check-your-mandatory_capital_disregards" }) do |row| %>
<%= row.with_key(text: t(".mandatory.heading"), classes: "govuk-!-width-one-half") %>
<%= row.with_value { @legal_aid_application.mandatory_capital_disregards.any? ? mandatory_capital_disregards_list(@legal_aid_application) : t("generic.none") } %>
<% unless read_only %>
<%= row.with_action(
text: t("generic.change"),
href: check_answer_url_for(journey_type, :capital_disregards_mandatory, @legal_aid_application),
visually_hidden_text: t(".mandatory.heading"),
) %>
<% end %>
<% end %>

<%= summary_list.with_row(html_attributes: { id: "app-check-your-discretionary_capital_disregards" }) do |row| %>
<%= row.with_key(text: t(".discretionary.heading"), classes: "govuk-!-width-one-half") %>
<%= row.with_value(text: @legal_aid_application.discretionary_capital_disregards.any? ? discretionary_capital_disregards_list(@legal_aid_application) : t("generic.none")) %>
<% unless read_only %>
<%= row.with_action(
text: t("generic.change"),
href: check_answer_url_for(journey_type, :capital_disregards_discretionary, @legal_aid_application),
visually_hidden_text: t(".discretionary.heading"),
) %>
<% end %>
<% end %>
<% end %>

<% @legal_aid_application.mandatory_capital_disregards.each_with_index do |capital_disregard, index| %>
<%= render("shared/check_answers/capital_disregard_details", capital_disregard:, index:, read_only:) %>
<% end %>

<% @legal_aid_application.discretionary_capital_disregards.each_with_index do |capital_disregard, index| %>
<%= render("shared/check_answers/capital_disregard_details", capital_disregard:, index:, read_only:) %>
<% end %>
9 changes: 9 additions & 0 deletions config/locales/en/providers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,8 @@ en:
london_emergencies_trust: The London Emergencies Trust
none_of_these: None of these schemes or trusts
capital_disregards:
payment_reason_for: "For: %{reason}"
held_in: Held in %{account_name}
discretionary:
backdated_benefits: Backdated benefits and child maintenance payments received more than 24 months ago
compensation_for_personal_harm: Compensation, damages or ex-gratia payments for personal harm
Expand Down Expand Up @@ -1422,6 +1424,13 @@ en:
assets_heading: &assets_heading Property, savings and other assets
benefit_check_heading: Passported means
benefit_check_question: In receipt of passporting benefit
capital_disregards:
heading: Capital disregards
discretionary:
heading: Discretionary disregards
mandatory:
heading: Mandatory disregards

capital_result_heading: &capital_result_heading Capital result
caseworker_review_section_heading: Caseworker Review
child_dependants: Child dependants
Expand Down
17 changes: 17 additions & 0 deletions config/locales/en/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,23 @@ en:
total_outgoings: Total outgoings
total_deductions: Total deductions
check_answers:
capital_disregard_details:
mandatory:
heading: Disregarded payment %{count}
discretionary:
heading: Payment to be reviewed %{count}
questions:
payment_type: Payment type
payment_reason: What the payment is for
amount_and_date_received: Amount and date received
bank_account_name: Bank account
capital_disregards:
heading: One-off payments your client received
heading_with_partner: One-off payments your client or their partner received
mandatory:
heading: Disregarded payments
discretionary:
heading: Payments to be reviewed
assets:
assets:
other_assets: Which assets does your client have?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Feature: mandatory and discretionary capital disregards questions and flow
# TODO: This flow file can be moved to a full flow non-passported journey feature after the MTR-A feature flag is removed
# TODO: AP-5493 - This flow file can be moved to a full flow non-passported journey feature after the MTR-A feature flag is removed

@javascript
Scenario: When the MTR-A feature flag is off I should not see the mandatory or discretionary capital disregard questions in the flow
Expand Down
Loading