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-5572 Use summary card component for CYA income page #7567

Merged
merged 6 commits into from
Jan 24, 2025
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
3 changes: 2 additions & 1 deletion app/helpers/dependant_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def date_of_birth(dependant)
end

def relationship(dependant)
partner = dependant.legal_aid_application.applicant_has_partner? ? "_with_partner" : ""
build_ostruct(
t("relationship", scope: "providers.means.check_income_answers.dependants"),
t("relationship#{partner}", scope: "providers.means.check_income_answers.dependants"),
dependant.relationship.nil? ? "" : t(dependant.relationship, scope: "shared.forms.dependants.relationship.option"),
)
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/transaction_type_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def answer_for_transaction_type(legal_aid_application:, transaction_type:, owner
def regular_transaction_answer_by_type(legal_aid_application:, transaction_type:, owner_type:)
regular_transaction = legal_aid_application.regular_transactions.find_by(transaction_type:, owner_type:)
if regular_transaction
[number_to_currency(regular_transaction.amount), t("transaction_types.frequencies.#{regular_transaction.frequency}")]
[number_to_currency(regular_transaction.amount), t("transaction_types.frequencies.#{regular_transaction.frequency}").downcase]
else
t("generic.none")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@
read_only: false,
url: providers_legal_aid_application_means_cash_income_path,
individual: "Applicant",
individual_with_determiner: "your client",
individual_with_determiner: t("generic.client"),
type: :income,
) %>
<% end %>

<%= render(
"shared/check_answers/student_finance",
individual_text: "your client",
individual: @legal_aid_application.applicant,
individual: "Client",
individual_with_determiner: t("generic.client"),
model: @legal_aid_application.applicant,
url: providers_legal_aid_application_means_student_finance_path(@legal_aid_application),
read_only: false,
) %>
Expand All @@ -78,7 +79,7 @@
read_only: false,
url: providers_legal_aid_application_means_cash_outgoing_path,
individual: "Applicant",
individual_with_determiner: "your client",
individual_with_determiner: t("generic.client"),
type: :outgoings,
) %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% if @legal_aid_application.partner.has_multiple_employments? %>
<%= render(
"shared/check_answers/full_employment_details",
individual: "The partner",
individual: t("generic.partner"),
read_only: false,
partner: true,
) %>
Expand All @@ -17,7 +17,7 @@
<% elsif @legal_aid_application.partner.employed? %>
<%= render(
"shared/check_answers/full_employment_details",
individual: "The partner",
individual: t("generic.partner"),
read_only: false,
partner: true,
) %>
Expand All @@ -42,14 +42,15 @@
read_only: false,
url: providers_legal_aid_application_partners_cash_income_path,
individual: "Partner",
individual_with_determiner: "the partner",
individual_with_determiner: t("generic.partner"),
type: :income,
) %>

<%= render(
"shared/check_answers/student_finance",
individual_text: "the partner",
individual: @legal_aid_application.partner,
individual: "Partner",
individual_with_determiner: t("generic.partner"),
model: @legal_aid_application.partner,
url: providers_legal_aid_application_partners_student_finance_path(@legal_aid_application),
read_only: false,
) %>
Expand All @@ -69,7 +70,7 @@
read_only: false,
url: providers_legal_aid_application_partners_cash_outgoing_path,
individual: "Partner",
individual_with_determiner: "the partner",
individual_with_determiner: t("generic.partner"),
type: :outgoings,
) %>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"your client"
end %>

<%= page_template(page_title: t(".h1-heading")) do %>
<%= page_template(page_title: t(".h1-heading"), column_width: "full") do %>

<%= govuk_inset_text do %>
<p class="govuk-body govuk-!-padding-bottom-2"><%= t("generic.cya_inset_text") %></p>
Expand All @@ -18,13 +18,13 @@
<%= render(
"shared/check_answers/housing_benefit",
read_only: false,
individual:,
partner: @legal_aid_application.applicant.has_partner_with_no_contrary_interest?,
) %>
<% end %>

<h2 class="govuk-heading-l"><%= t("providers.means.check_income_answers.dependants.heading") %></h2>
<h2 class="govuk-heading-l"><%= t("providers.means.check_income_answers.dependants.heading-h2") %></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
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"your client"
end %>
<section class="print-no-break">
<h2 class="govuk-heading-l"><%= t("providers.means.check_income_answers.dependants.heading") %></h2>
<h2 class="govuk-heading-l"><%= t("providers.means.check_income_answers.dependants.heading-h2") %></h2>
<%= render "shared/check_answers/dependants", individual: individual_text, read_only: true, means_report: true %>
</section>

Expand Down
15 changes: 0 additions & 15 deletions app/views/shared/_student_finances_table.html.erb

This file was deleted.

36 changes: 15 additions & 21 deletions app/views/shared/check_answers/_bank_statements.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<h3 class="govuk-heading-m"><%= t(".section_heading") %></h3>

<% read_only = false unless local_assigns.key?(:read_only) %>

<% url = if partner
Expand All @@ -8,26 +6,22 @@
providers_legal_aid_application_bank_statements_path(@legal_aid_application)
end %>

<% individual = if partner
"Partner"
else
"Client"
end %>
<% individual = partner ? "Partner" : "Client" %>

<%= govuk_summary_list(card: { title: t(".section_heading") }, actions: !read_only) do |summary_list| %>
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__bank_statements_#{individual.downcase}" }) do |row| %>
<%= row.with_key(text: t(".bank_statement_question"), classes: "govuk-!-width-one-half") %>
<%= row.with_value do %>
<ul class="govuk-list">
<% attachments_with_size(bank_statements).each do |answer| %>
<li><%= answer %></li>
<% end %>
</ul>
<%= govuk_summary_card(title: t(".section_heading"), html_attributes: { id: "app-check-your-answers__bank_statements_#{individual.downcase}" }, heading_level: 3) do |card| %>
<% unless read_only %>
<%= card.with_action { govuk_link_to(t("generic.change"), url, "aria-label": "#{individual} #{t('.bank_statement_question')}") } %>
<% end %>
<%= card.with_summary_list do |summary_list| %>
<%= summary_list.with_row do |row| %>
<%= row.with_key(text: t(".bank_statement_question"), classes: "govuk-!-width-one-third") %>
<%= row.with_value do %>
<ul class="govuk-list">
<% attachments_with_size(bank_statements).each do |answer| %>
<li><%= answer %></li>
<% end %>
</ul>
<% end %>
<% end %>
<%= row.with_action(
text: t("generic.change"),
href: url,
visually_hidden_text: "#{individual} #{t('.bank_statement_question')}",
) %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<%= govuk_summary_list(card: { title: t(".#{individual}.heading") }, actions: false) do |summary_list| %>
<% data_source.state_benefits.each do |benefit| %>
<% summary_list.with_row do |row|
row.with_key(text: benefit.description || "", classes: "govuk-!-width-one-half")
row.with_key(text: benefit.description || "", classes: "govuk-!-width-one-third")
row.with_value { "#{gds_number_to_currency(benefit.amount)} #{t("transaction_types.frequencies.#{benefit.frequency}").downcase}" }
end %>
<% end %>
Expand Down
77 changes: 30 additions & 47 deletions app/views/shared/check_answers/_benefits_income.html.erb
Original file line number Diff line number Diff line change
@@ -1,61 +1,44 @@
<% 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 %>

<h2 class="govuk-heading-m"><%= t(".#{transactions_for}.heading") %></h2>
<%= govuk_summary_list(card: { title: t(".#{transactions_for}.heading") }, actions: !read_only, 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| %>
<%= row.with_key(text: t(".#{transactions_for}.question"), classes: "govuk-!-width-one-half") %>
<%= row.with_value { yes_no(individual.receives_state_benefits?) } %>
<%= row.with_action(
text: t("generic.change"),
href: url,
visually_hidden_text: t(".#{transactions_for}.change_aria"),
) %>
<%= govuk_summary_card(title: t(".#{transactions_for}.heading"), heading_level: 3, html_attributes: { id: "app-check-your-answers__#{transactions_for}__state_benefits_question" }) do |card| %>
<% unless read_only %>
<%= 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| %>
<%= row.with_key(text: t(".#{transactions_for}.question"), classes: "govuk-!-width-one-third") %>
<%= row.with_value { yes_no(individual.receives_state_benefits?) } %>
<% end %>
<% end %>
<% end %>

<% state_benefits.each_with_index do |state_benefit, index| %>
<div class="govuk-grid-row" id="app-check-your-answers__<%= transactions_for %>__state_benefits_<%= index + 1 %>">
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-m"><%= t(".benefit_heading", index: index + 1) %></h2>
</div>

<% unless read_only %>
<div class="govuk-grid-column-one-third align-text-right">
<p>
<%= 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)}",
) %>
</p>
</div>
<% end %>
</div>

<%= govuk_summary_list(
card: { title: t(".benefit_heading", index: index + 1) },
actions: false,
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) %>
<% 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)) %>
<% end %>
<%= summary_list.with_row do |row| %>
<%= row.with_key(text: t(".frequency"), classes: "govuk-!-width-one-half") %>
<%= row.with_value(text: t("transaction_types.frequencies.#{state_benefit.frequency}")) %>
<%= govuk_summary_card(title: t(".benefit_heading", index: index + 1), heading_level: 3, html_attributes: { id: "app-check-your-answers__#{transactions_for}__state_benefits_#{index + 1}" }) do |card| %>
<%= 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-third") %>
<%= row.with_value(text: state_benefit.description) %>
<% end %>
<%= summary_list.with_row do |row| %>
<%= row.with_key(text: t(".amount"), classes: "govuk-!-width-one-third") %>
<%= row.with_value(text: [number_to_currency(state_benefit.amount), t("transaction_types.frequencies.#{state_benefit.frequency}").downcase].join(" ")) %>
<% end %>
<% end %>
<% end %>
<% end %>
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:), heading_level: 3, html_attributes: { id: "app-check-your-answers__#{individual.downcase}__cash_#{type}" }) 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-third") %>
<%= row.with_value do %>
<% if cash_transactions.for_transaction_type(category.id).any? %>
<% cash_transactions.for_transaction_type(category.id).each do |ctx| %>
<%= t(".amount_and_date", amount: gds_number_to_currency(ctx.amount, precision: 2), month: ctx.transaction_date.strftime("%B %Y")) %> <br>
<% end %>
<% else %>
<%= t("generic.none") %>
<% end %>
<% else %>
<%= t("generic.none") %>
<% end %>
<% end %>
<% end %>
Expand Down
Loading
Loading