Skip to content

Commit

Permalink
AP-5572 income cya page
Browse files Browse the repository at this point in the history
update rest of partials to use summary card component
  • Loading branch information
RoseSAK committed Jan 14, 2025
1 parent 6ac4470 commit e5e795d
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<h2 class="govuk-heading-l"><%= t("providers.means.check_income_answers.dependants.heading") %></h2>

<%= render "shared/check_answers/dependants", individual: %>
<%= render "shared/check_answers/dependants" %>

<h3 class="govuk-heading-m"><%= t(".what_happens_next.heading") %></h3>
<p class="govuk-body govuk-!-margin-bottom-8"><%= t(".what_happens_next.text", individual:) %></p>
Expand Down
26 changes: 14 additions & 12 deletions app/views/shared/check_answers/_benefits_income.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<% read_only = false unless local_assigns.key?(:read_only) %>

<% unless read_only %>
<% url = if individual.receives_state_benefits?
<% unless read_only
url = if individual.receives_state_benefits?
state_benefit_partial_url(:add_benefits, version, @legal_aid_application)
else
state_benefit_partial_url(:receive_benefits, version, @legal_aid_application)
end %>
<% end %>
end
end %>

<%= govuk_summary_card(title: t(".#{transactions_for}.heading"), html_attributes: { id: "state-benefit-section-#{transactions_for}" }) do |card| %>
<% unless read_only %>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": t(".#{transactions_for}.change_aria"))} %>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": t(".#{transactions_for}.change_aria")) } %>
<% end %>
<% card.with_summary_list(html_attributes: { id: "state-benefit-section-#{transactions_for}" }) do |summary_list| %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{transactions_for}__state_benefits" }) do |row| %>
Expand All @@ -23,19 +23,21 @@
<% state_benefits.each_with_index do |state_benefit, index| %>

<%= govuk_summary_card(title: t(".benefit_heading", index: index + 1), html_attributes: { id: "app-check-your-answers__#{transactions_for}__state_benefits_#{index + 1}" }) do |card| %>
<% unless read_only %>
<%= card.with_action { govuk_link_to(t("generic.change"),
state_benefit_partial_url(:change_benefits, version, @legal_aid_application, state_benefit),
"aria-label": "#{t('generic.change')} #{t('.benefit_heading', index: index + 1)}")} %>
<% end %>
<%= unless read_only
card.with_action do
govuk_link_to(t("generic.change"),
state_benefit_partial_url(:change_benefits, version, @legal_aid_application, state_benefit),
"aria-label": [t("generic.change"), t(".benefit_heading", index: index + 1)].join(" "))
end
end %>
<% card.with_summary_list(html_attributes: { id: "app-check-your-answers__#{transactions_for}__state_benefits_#{index + 1}_items" }) do |summary_list| %>
<%= summary_list.with_row do |row| %>
<%= row.with_key(text: t(".type"), classes: "govuk-!-width-one-half") %>
<%= row.with_value(text: state_benefit.description)%>
<%= row.with_value(text: state_benefit.description) %>
<% end %>
<%= summary_list.with_row do |row| %>
<%= row.with_key(text: t(".amount"), classes: "govuk-!-width-one-half") %>
<%= row.with_value(text: "#{number_to_currency(state_benefit.amount)} #{t("transaction_types.frequencies.#{state_benefit.frequency}").downcase}") %>
<%= row.with_value(text: [number_to_currency(state_benefit.amount), t("transaction_types.frequencies.#{state_benefit.frequency}").downcase].join(" ")) %>
<% end %>
<% end %>
<% end %>
Expand Down
48 changes: 19 additions & 29 deletions app/views/shared/check_answers/_cash_payments.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
<% read_only = false unless local_assigns.key?(:read_only) %>
<div class="govuk-grid-row" id="app-check-your-answers__<%= individual.to_s.downcase %>__cash_<%= type.to_s.downcase %>">
<div class="govuk-grid-column-two-thirds">
<h3 class="govuk-heading-m"><%= t(".#{type}_heading", individual_with_determiner:) %></h3>
</div>
<% unless read_only %>
<div class="govuk-grid-column-one-third align-text-right">
<p><%= govuk_link_to(t("generic.change"), url, "aria-label": "#{t('generic.change')} #{t(".#{type}_heading", individual_with_determiner:)}") %></p>
</div>
<% end %>
</div>

<% cash_transaction_types = if type.eql?(:income)
@legal_aid_application.income_cash_transaction_types_for(individual)
elsif type.eql?(:outgoings)
Expand All @@ -18,26 +7,27 @@

<% cash_transactions = @legal_aid_application.cash_transactions.where(owner_type: individual) %>

<%= govuk_summary_list(
card: { title: t(".#{type}_heading", individual_with_determiner:) },
actions: false,
html_attributes: { "data-check-your-answers-section": t(".#{type}_heading", individual_with_determiner:).parameterize },
) do |summary_list| %>
<% if cash_transaction_types.none? %>
<%= summary_list.with_row do |row| %>
<%= row.with_value { t("generic.none") } %>
<% end %>
<%= govuk_summary_card(title: t(".#{type}_heading", individual_with_determiner:)) do |card| %>
<% unless read_only %>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": "#{t('generic.change')} #{t(".#{type}_heading", individual_with_determiner:)}") } %>
<% end %>
<% cash_transaction_types.each do |category| %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{category.label_name.parameterize}-cash-#{type}-#{individual.downcase}" }) do |row| %>
<%= row.with_key(text: category.label_name, classes: "govuk-!-width-one-half") %>
<%= row.with_value do %>
<% if cash_transactions.for_transaction_type(category.id).any? %>
<% cash_transactions.for_transaction_type(category.id).each do |ctx| %>
<strong><%= ctx.transaction_date.strftime("%B") %></strong>: <%= gds_number_to_currency(ctx.amount, precision: 2) %><br>
<% card.with_summary_list(html_attributes: { "data-check-your-answers-section": t(".#{type}_heading", individual_with_determiner:).parameterize }) do |summary_list| %>
<% if cash_transaction_types.none? %>
<%= summary_list.with_row do |row| %>
<%= row.with_value { t("generic.none") } %>
<% end %>
<% end %>
<% cash_transaction_types.each do |category| %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{category.label_name.parameterize}-cash-#{type}-#{individual.downcase}" }) do |row| %>
<%= row.with_key(text: category.label_name, classes: "govuk-!-width-one-half") %>
<%= row.with_value do %>
<% if cash_transactions.for_transaction_type(category.id).any? %>
<% cash_transactions.for_transaction_type(category.id).each do |ctx| %>
<strong><%= ctx.transaction_date.strftime("%B") %></strong>: <%= gds_number_to_currency(ctx.amount, precision: 2) %><br>
<% end %>
<% else %>
<%= t("generic.none") %>
<% end %>
<% else %>
<%= t("generic.none") %>
<% end %>
<% end %>
<% end %>
Expand Down
63 changes: 25 additions & 38 deletions app/views/shared/check_answers/_dependants.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<% read_only = false unless local_assigns.key?(:read_only) %>
<% means_report = false unless local_assigns.key?(:means_report) %>

<% individual = @legal_aid_application.applicant.has_partner? ? "client_with_partner" : "client" %>

<% unless read_only
url = if @legal_aid_application.has_dependants?
providers_legal_aid_application_means_has_other_dependants_path
Expand All @@ -10,53 +12,38 @@
end
end %>

<%= govuk_summary_list(card: { title: t("providers.means.check_income_answers.dependants.heading") },
actions: !read_only,
html_attributes: { id: "dependants-questions" }) do |summary_list| %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__dependants" }) do |row| %>
<%= row.with_key(text: t("shared.check_answers.dependants.has_dependants", individual:), classes: "govuk-!-width-one-half") %>
<%= row.with_value { yes_no(@legal_aid_application.has_dependants) } %>
<%= row.with_action(
text: t("generic.change"),
href: url,
html_attributes: { "aria-label": "#{t('generic.change')} #{t('shared.check_answers.dependants.has_dependants', individual:)}" },
) %>
<%= govuk_summary_card(title: t("providers.means.check_income_answers.dependants.heading"), html_attributes: { id: "app-check-your-answers__dependants" }) do |card| %>
<% unless read_only %>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": "#{t('generic.change')} #{t("shared.check_answers.dependants.#{individual}_has_dependants")}") } %>
<% end %>
<%= card.with_summary_list do |summary_list| %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__dependants" }) do |row| %>
<%= row.with_key(text: t("shared.check_answers.dependants.#{individual}_has_dependants"), classes: "govuk-!-width-one-half") %>
<%= row.with_value { yes_no(@legal_aid_application.has_dependants) } %>
<% end %>
<% end %>
<% end %>

<% if @legal_aid_application.dependants %>
<% @legal_aid_application.dependants.each_with_index do |dependant, index| %>
<div class="govuk-grid-row" id="app-check-your-answers__dependants_<%= index + 1 %>">
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-m">Dependant <%= index + 1 %>: <%= dependant.name %></h2>
</div>

<% if !read_only %>
<div class="govuk-grid-column-one-third align-text-right">
<p>
<%= govuk_link_to(
t("generic.change"),
providers_legal_aid_application_means_dependant_path(@legal_aid_application, dependant),
"aria-label": "#{t('generic.change')} Dependant #{index + 1}: #{dependant.name}",
) %>
</p>
</div>
<%= govuk_summary_card(title: t(".dependant_name", position: index + 1),
html_attributes: { id: "app-check-your-answers__dependants_#{index + 1}_items" }) do |card| %>
<% unless read_only %>
<%= card.with_action { govuk_link_to(t("generic.change"), providers_legal_aid_application_means_dependant_path(@legal_aid_application, dependant), "aria-label": "#{t('generic.change')} Dependant #{index + 1}: #{dependant.name}") } %>
<% end %>
</div>
<%= govuk_summary_list(
card: { title: t(".dependant_name", position: index + 1, name: dependant.name) },
actions: false,
html_attributes: { id: "app-check-your-answers__dependants_#{index + 1}_items" },
) do |summary_list| %>
<% dependant_hash(dependant)&.fetch(:items, [])&.each_with_index do |item, index| %>
<% name = item.name || "dependants_#{index + 1}_#{index}" %>
<% unless means_report && !item.label.in?(["Name", "Date of birth", "What is their relationship to your client?"]) %>
<%= summary_list.with_row do |row| %>
<%= row.with_key(text: item.label, classes: "govuk-!-width-one-half") %>
<%= row.with_value { safe_yes_or_no(item.amount_text) } %>

<% card.with_summary_list do |summary_list| %>
<% dependant_hash(dependant)&.fetch(:items, [])&.each_with_index do |item, index| %>
<% name = item.name || "dependants_#{index + 1}_#{index}" %>
<% unless means_report && !item.label.in?(["Name", "Date of birth", "What is their relationship to your client?"]) %>
<%= summary_list.with_row do |row| %>
<%= row.with_key(text: item.label, classes: "govuk-!-width-one-half") %>
<%= row.with_value { safe_yes_or_no(item.amount_text) } %>
<% end %>
<% end %>
<% end %>
<% end %>

<% end %>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/shared/check_answers/_employed_income.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<%= govuk_summary_card(title: t(".heading", individual_with_determiner:).upcase_first) do |card| %>
<% unless read_only %>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": t('.aria_label', individual_with_determiner:)) } %>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": t(".aria_label", individual_with_determiner:)) } %>
<% end %>
<%= card.with_summary_list(html_attributes: { id: "employment-#{individual}-notes-questions" }) do |summary_list| %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__extra_employment_information" }) do |row| %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<%= govuk_summary_card(title: t(".employment")) do |card| %>
<% unless read_only %>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": "#{t('generic.change')} #{individual_with_determiner}'s #{t('.employment')}")} %>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": "#{t('generic.change')} #{individual_with_determiner}'s #{t('.employment')}") } %>
<% end %>
<%= card.with_summary_list(html_attributes: { id: "app-check-your-answers__full_employment_details" }) do |summary_list| %>
<%= summary_list.with_row do |row| %>
Expand Down
54 changes: 22 additions & 32 deletions app/views/shared/check_answers/_housing_benefit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,31 @@
<div class="govuk-grid-column-two-thirds">
<h3 class="govuk-heading-m"><%= t(".heading") %></h3>
</div>
<% unless read_only %>
<div class="govuk-grid-column-one-third govuk-summary-list--no-border align-text-right">
<p>
<%= govuk_link_to(
t("generic.change"),
providers_legal_aid_application_means_housing_benefits_path(@legal_aid_application),
class: "change-link",
"aria-label": t(".heading"),
) %>
</p>
</div>
<% end %>
</div>

<%= govuk_summary_list(
card: { title: t(".heading") },
actions: false,
html_attributes: { "data-check-your-answers-section": t(".heading").parameterize },
) do |summary_list| %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__housing_benefit_question" }) do |row| %>
<%= row.with_key(text: t(".does_your_client", individual:), classes: "govuk-!-width-one-half") %>
<%= row.with_value { yes_no(@legal_aid_application.applicant_in_receipt_of_housing_benefit?) } %>
<%= govuk_summary_card(title: t(".card_title"), html_attributes: { "data-check-your-answers-section": t(".heading").parameterize }) do |card| %>
<% unless read_only %>
<%= card.with_action { govuk_link_to(t("generic.change"), providers_legal_aid_application_means_housing_benefits_path(@legal_aid_application), "aria-label": t(".card_title")) } %>
<% end %>

<% housing_benefit_type = TransactionType.find_by(name: "housing_benefit") %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{housing_benefit_type.label_name}" }) do |row| %>
<%= row.with_key(text: t("generic.amount"), classes: "govuk-!-width-one-half") %>
<%= row.with_value do %>
<% regular_transaction_amount, regular_transaction_frequency = regular_transaction_answer_by_type(
legal_aid_application: @legal_aid_application,
transaction_type: housing_benefit_type,
owner_type: "Applicant",
) %>
<p><%= regular_transaction_amount %></p>
<p><%= regular_transaction_frequency %></p>
<%= card.with_summary_list do |summary_list| %>
<% if @legal_aid_application.applicant_in_receipt_of_housing_benefit? %>
<% housing_benefit_type = TransactionType.find_by(name: "housing_benefit") %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{housing_benefit_type.label_name}" }) do |row| %>
<%= row.with_key(text: t(".amount"), classes: "govuk-!-width-one-half") %>
<%= row.with_value do %>
<% regular_transaction_amount, regular_transaction_frequency = regular_transaction_answer_by_type(
legal_aid_application: @legal_aid_application,
transaction_type: housing_benefit_type,
owner_type: "Applicant",
) %>
<p><%= regular_transaction_amount %><br><%= regular_transaction_frequency %></p>
<% end %>
<% end %>
<% else %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__housing_benefit_question" }) do |row| %>
<%= row.with_key(text: t(".does_your_client", individual:), classes: "govuk-!-width-one-half") %>
<%= row.with_value { yes_no(@legal_aid_application.applicant_in_receipt_of_housing_benefit?) } %>
<% end %>
<% end %>
<% end %>
<% end %>
12 changes: 6 additions & 6 deletions app/views/shared/check_answers/_payments_summary.html.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<% read_only = false unless local_assigns.key?(:read_only) %>

<%= govuk_summary_card(title: payment_type, html_attributes: { id: "app-check-your-answers__#{payment_type.parameterize(separator: "_")}" }) do |card| %>
<%= govuk_summary_card(title: payment_type, html_attributes: { id: "app-check-your-answers__#{payment_type.parameterize(separator: '_')}" }) do |card| %>
<% unless read_only %>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": "#{t('generic.change')} #{payment_type}")} %>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": "#{t('generic.change')} #{payment_type}") } %>
<% end %>
<% card.with_summary_list(html_attributes: { "data-check-your-answers-section": payment_type.parameterize }) do |summary_list| %>
<% transaction_types.each do |transaction_type| %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{transaction_type.label_name.parameterize}-#{individual.downcase}" }) do |row| %>
<%= row.with_key(text: transaction_type.label_name, classes: "govuk-!-width-one-half") %>
<%= row.with_value do %>
<% regular_transaction_amount, regular_transaction_frequency = regular_transaction_answer_by_type(
legal_aid_application: @legal_aid_application,
transaction_type:,
owner_type: individual,
) %>
legal_aid_application: @legal_aid_application,
transaction_type:,
owner_type: individual,
) %>
<% if @legal_aid_application.client_uploading_bank_statements? || individual.eql?("Partner") %>
<p><%= regular_transaction_amount %></p>
<% unless regular_transaction_amount.eql?("None") %>
Expand Down
Loading

0 comments on commit e5e795d

Please sign in to comment.