Skip to content

Commit

Permalink
AP-5424: Get check capital answers page working
Browse files Browse the repository at this point in the history
  • Loading branch information
jsugarman committed Nov 7, 2024
1 parent ad4c122 commit d4fc062
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/helpers/capital_disregard_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module CapitalDisregardHelper
def mandatory_capital_disregards_list(legal_aid_application)
mandatory_capital_disregards_names = legal_aid_application
.mandatory_capital_disregards
.pluck(:name).map do |key|
I18n.t("providers.means.capital_disregards.mandatory.#{key}")
end
mandatory_capital_disregards_names.join("<br>").html_safe
end

def discretionary_capital_disregards_list(legal_aid_application)
discretionary_capital_disregards_list = legal_aid_application
.discretionary_capital_disregards
.pluck(:name).map do |key|
I18n.t("providers.means.capital_disregards.discretionary.#{key}")
end
discretionary_capital_disregards_list.join("<br>").html_safe
end

def amount_and_date_received(capital_disregard)
"#{gds_number_to_currency(capital_disregard.amount)} on #{capital_disregard.date_received}"
end
end
6 changes: 6 additions & 0 deletions app/views/shared/check_answers/_assets.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,10 @@
) %>
<% end %>
</section>

<section class="print-no-break">
<% if Setting.means_test_review_a? %>
<%= render("shared/check_answers/capital_disregards", read_only:, individual:) %>
<% 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-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 %>
35 changes: 35 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,35 @@
<h2 class="govuk-heading-m"><%= t(".heading#{individual}") %></h2>
<%= govuk_summary_list(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_capital_disregards.key"), 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_capital_disregards.key"),
) %>
<% end %>
<% end %>

<%= summary_list.with_row(html_attributes: { id: "app-check-your-discretionary_capital_disregards" }) do |row| %>
<%= row.with_key(text: t(".discretionary_capital_disregards.key"), classes: "govuk-!-width-one-half") %>
<%= row.with_value { @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_capital_disregards.key"),
) %>
<% 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 %>
19 changes: 19 additions & 0 deletions config/locales/en/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,31 @@ 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_capital_disregards:
key: Disregarded payments
discretionary_capital_disregards:
key: Payments to be reviewed
assets:
assets:
other_assets: Which assets does your client have?
other_assets_with_partner: Which assets does either your client or their partner have?
policy_disregards: Payments from scheme or charities
policy_disregards_with_partner: Your client's and the partner's payments from schemes or charities
# capital_disregards: One-off payments your client received
# capital_disregards_with_partner: One-off payments your client or their partner received
savings_and_investments: Which savings or investments does your client have?
savings_and_investments_with_partner: Which savings or investments does either your client or their partner have?
bank_accounts: Bank accounts
Expand Down

0 comments on commit d4fc062

Please sign in to comment.