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 8, 2025
1 parent 6ac4470 commit 8f6fdca
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 125 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
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
66 changes: 28 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,41 @@
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 %>
56 changes: 25 additions & 31 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,35 @@
<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,
<%= govuk_summary_card(title: t(".card_title"),
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?) } %>
) 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 %>
32 changes: 13 additions & 19 deletions app/views/shared/check_answers/_student_finance.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
<div class="govuk-grid-row" id="app-check-your-answers__<%= individual.class.to_s.downcase %>__student_finance">
<div class="govuk-grid-column-two-thirds">
<h3 class="govuk-heading-m"><%= t(".heading") %></h3>
</div>
<%= govuk_summary_card(title: t(".heading")) do |card| %>
<% 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')} #{individual_text}'s #{t('.heading')}") %></p>
</div>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": "#{t('generic.change')} #{individual_text}'s #{t('.heading')}") } %>
<% end %>
</div>

<%= govuk_summary_list(card: { title: t(".heading") }, actions: false) do |summary_list| %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{individual.class.to_s.downcase}_student_finance_question" }) do |row| %>
<%= row.with_key(text: t(".does_your_client", individual_text:), classes: "govuk-!-width-one-half") %>
<%= row.with_value { yes_no(individual.student_finance?) } %>
<% end %>

<% if individual.student_finance? %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__student_finance_annual_amount" }) do |row| %>
<%= row.with_key(text: t(".how_much"), classes: "govuk-!-width-one-half") %>
<%= row.with_value { gds_number_to_currency(individual.student_finance_amount) } %>
<% card.with_summary_list(html_attributes: { id: "app-check-your-answers__#{individual.class.to_s.downcase}_student_finance" }) do |summary_list| %>
<% if individual.student_finance? %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{individual.class.to_s.downcase}_student_finance_annual_amount" }) do |row| %>
<%= row.with_key(text: t(".how_much"), classes: "govuk-!-width-one-half") %>
<%= row.with_value { gds_number_to_currency(individual.student_finance_amount) } %>
<% end %>
<% else %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{individual.class.to_s.downcase}_student_finance_question" }) do |row| %>
<%= row.with_key(text: t(".question", individual_text:), classes: "govuk-!-width-one-half") %>
<%= row.with_value { "#{yes_no(individual.student_finance?)} every year" } %>
<% end %>
<% end %>
<% end %>
<% end %>
5 changes: 3 additions & 2 deletions config/locales/en/providers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1123,8 +1123,9 @@ en:
credits-section-heading: Payments the partner gets
debits-section-heading: Payments the partner pays
dependants:
heading: Dependants
has_dependants: Does your client have any dependants?
heading: Any dependants
client_with_partner_has_dependants: Client or their partner has dependants?
client_has_dependants: Client has dependants?
add-new: Add dependant
delete: Delete dependant
name: Name
Expand Down
13 changes: 8 additions & 5 deletions config/locales/en/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ en:
nino: National Insurance number
has_partner: Does your client have a partner?
dependants:
dependant_name: "Dependant %{position}: %{name}"
has_dependants: Does %{individual} have any dependants?
dependant_name: "Dependant %{position}"
client_has_dependants: Client has dependants?
partner_has_dependants: Client or their partner has dependants?
add-new: Add dependant
delete: Delete dependant
name: Name
Expand All @@ -435,6 +436,8 @@ en:
new_limit_reasons: Reason
housing_benefit:
heading: Housing Benefit
card_title: Housing benefit details
amount: Amount of housing benefit
does_your_client: Does %{individual} get Housing Benefit?
linking_and_copying:
section_linking:
Expand Down Expand Up @@ -594,12 +597,12 @@ en:
no_transactions: "No"
student_finance:
heading: Student finance
does_your_client: Does %{individual_text} get student finance?
question: "%{individual_text} gets student finance?"
how_much: Amount of student finance
info_html: '<strong>%{student_finance}</strong> this academic year.'
cash_payments:
income_heading: Payments %{individual_with_determiner} receives in cash
outgoings_heading: Payments %{individual_with_determiner} makes in cash
income_heading: Payments %{individual_with_determiner} gets in cash
outgoings_heading: Payments %{individual_with_determiner} pays in cash
proceedings:
heading: Proceedings
proceeding: Proceeding
Expand Down

0 comments on commit 8f6fdca

Please sign in to comment.