From 3389ccdc172493d1ade1e6ce9b566510e83f36a8 Mon Sep 17 00:00:00 2001 From: Katharine Ahern Date: Tue, 31 Oct 2023 13:42:43 +0000 Subject: [PATCH] ap-4566: Display bank accounts and balances on means report also Review and print application page and fix means_report.feature --- .../shared/check_answers/_assets.html.erb | 80 ++++++++++++------- config/locales/en/shared.yml | 4 + features/providers/means_report.feature | 16 +++- features/step_definitions/generic_steps.rb | 9 +++ .../step_definitions/means_report_steps.rb | 23 +++++- 5 files changed, 97 insertions(+), 35 deletions(-) diff --git a/app/views/shared/check_answers/_assets.html.erb b/app/views/shared/check_answers/_assets.html.erb index 990fffdbc3..8730df4eda 100644 --- a/app/views/shared/check_answers/_assets.html.erb +++ b/app/views/shared/check_answers/_assets.html.erb @@ -14,28 +14,40 @@ <% if read_only %> -

<%= t(".assets.client_bank_accounts") %>

+

<%= t(".assets.clients_bank_accounts") %>

- <%= govuk_summary_list(classes: "govuk-!-margin-bottom-9", html_attributes: { "data-test": "applicant-bank-accounts" }) do |summary_list| %> + <%= govuk_table(classes: "govuk-!-margin-bottom-9", html_attributes: { id: "applicant-bank-accounts-details" }) do |table| + table.with_body do |body| + @legal_aid_application&.applicant&.bank_accounts&.each do |account| + body.with_row do |row| + row.with_cell(header: true, text: "#{account.name},#{account.account_number},#{account.sort_code}") + row.with_cell(numeric: true, text: gds_number_to_currency(account.balance).to_s) + end + end + end + end %> + +

<%= t(".assets.money_in_bank_accounts") %>

+ + <%= govuk_summary_list(classes: "govuk-!-margin-bottom-0", html_attributes: { "data-test": "applicant-bank-accounts" }) do |summary_list| %> <%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__online_current_accounts" }) do |row| %> - <%= row.with_key(text: t(".assets.client_current_account"), classes: "govuk-!-width-one-half") %> + <%= row.with_key(text: @legal_aid_application&.applicant&.has_partner? ? t(".assets.client_current_account") : t(".assets.current_accounts"), classes: "govuk-!-width-one-half") %> <%= row.with_value { online_current_accounts.present? ? gds_number_to_currency(online_current_accounts) : t("generic.none") } %> <% end %> <%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__online_savings_accounts" }) do |row| %> - <%= row.with_key(text: t(".assets.client_savings_account"), classes: "govuk-!-width-one-half") %> + <%= row.with_key(text: @legal_aid_application&.applicant&.has_partner? ? t(".assets.client_savings_account") : t(".assets.savings_accounts"), classes: "govuk-!-width-one-half") %> <%= row.with_value { online_savings_accounts.present? ? gds_number_to_currency(online_savings_accounts) : t("generic.none") } %> <% end %> <% end %> <% end %> - <%= render "shared/check_answers/offline_savings_accounts", read_only: %> <% else %> - <%= govuk_summary_list(classes: "govuk-!-margin-bottom-9", html_attributes: { id: "app-check-your-answers__bank_accounts_items", "data-test": "applicant-bank-accounts" }) do |summary_list| %> + <%= govuk_summary_list(classes: "govuk-!-margin-bottom-0", html_attributes: { id: "app-check-your-answers__bank_accounts_items", "data-test": "applicant-bank-accounts" }) do |summary_list| %> <%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__offline_current_accounts" }) do |row| %> - <%= row.with_key(text: t(".assets.client_current_account"), classes: "govuk-!-width-one-half") %> + <%= row.with_key(text: @legal_aid_application&.applicant&.has_partner? ? t(".assets.client_current_account") : t(".assets.current_accounts"), classes: "govuk-!-width-one-half") %> <%= row.with_value { @legal_aid_application&.savings_amount&.offline_current_accounts.present? ? gds_number_to_currency(@legal_aid_application.savings_amount.offline_current_accounts) : t("generic.none") } %> <% end %> <%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__offline_savings_accounts" }) do |row| %> - <%= row.with_key(text: t(".assets.client_savings_account"), classes: "govuk-!-width-one-half") %> + <%= row.with_key(text: @legal_aid_application&.applicant&.has_partner? ? t(".assets.client_savings_account") : t(".assets.savings_accounts"), classes: "govuk-!-width-one-half") %> <%= row.with_value { @legal_aid_application&.savings_amount&.offline_savings_accounts.present? ? gds_number_to_currency(@legal_aid_application.savings_amount.offline_savings_accounts) : t("generic.none") } %> <% end %> <% end %> @@ -66,10 +78,10 @@ :offline_accounts end %> - <%= govuk_summary_list(classes: "govuk-!-margin-bottom-9", html_attributes: { "data-test": "partner-bank-accounts" }) do |summary_list| %> + <%= govuk_summary_list(classes: "govuk-!-margin-bottom-0", 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") %> <%= row.with_value { @legal_aid_application.savings_amount.partner_offline_current_accounts.present? ? gds_number_to_currency(@legal_aid_application.savings_amount.partner_offline_current_accounts) : t("generic.none") } %> @@ -94,10 +106,10 @@ <% if @legal_aid_application.uploading_bank_statements? || !@legal_aid_application.non_passported? %> - <%= govuk_summary_list(classes: "govuk-!-margin-bottom-9", html_attributes: { "data-test": "joint-bank-accounts" }) do |summary_list| %> + <%= govuk_summary_list(classes: "govuk-!-margin-bottom-0", html_attributes: { "data-test": "joint-bank-accounts" }) do |summary_list| %> <%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__joint_offline_current_accounts" }) do |row| %> <%= row.with_key(text: t(".assets.joint_current_account"), classes: "govuk-!-width-one-half") %> <%= row.with_value { @legal_aid_application.savings_amount.joint_offline_current_accounts.present? ? gds_number_to_currency(@legal_aid_application.savings_amount.joint_offline_current_accounts) : t("generic.none") } %> @@ -122,17 +134,25 @@ <% end %> <% end %> - <%= render( - "shared/check_answers/one_link_section", - name: :savings_and_investments, - url: check_answer_url_for(journey_type, :savings_and_investments, @legal_aid_application), - question: t(".assets.savings_and_investments#{individual}"), - answer_hash: capital_assets_list( - @legal_aid_application, - locale_namespace: "shared.forms.revealing_checkbox.attribute.#{journey_type}.savings_and_investments.check_box_", - ), - read_only:, - ) %> + <% if @legal_aid_application.non_passported? && !@legal_aid_application.uploading_bank_statements? %> +
+ <%= render "shared/check_answers/offline_savings_accounts", read_only: %> +
+ <% end %> + +
+ <%= render( + "shared/check_answers/one_link_section", + name: :savings_and_investments, + url: check_answer_url_for(journey_type, :savings_and_investments, @legal_aid_application), + question: t(".assets.savings_and_investments#{individual}"), + answer_hash: capital_assets_list( + @legal_aid_application, + locale_namespace: "shared.forms.revealing_checkbox.attribute.#{journey_type}.savings_and_investments.check_box_", + ), + read_only:, + ) %> +
<%= render( "shared/check_answers/one_link_section", diff --git a/config/locales/en/shared.yml b/config/locales/en/shared.yml index f08c9f58ae..5b77e23c86 100644 --- a/config/locales/en/shared.yml +++ b/config/locales/en/shared.yml @@ -243,6 +243,8 @@ en: 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 + current_accounts: Current accounts + savings_accounts: Savings accounts client_current_account: Client's current accounts client_savings_account: Client's savings accounts partner_savings_account: Partner's savings accounts @@ -250,6 +252,8 @@ en: joint_savings_account: Joint savings accounts joint_current_account: Joint current accounts client_bank_accounts: Your client's accounts + clients_bank_accounts: Client's bank accounts + money_in_bank_accounts: Money in bank accounts partner_bank_accounts: The partner's accounts joint_bank_accounts: Joint accounts property: diff --git a/features/providers/means_report.feature b/features/providers/means_report.feature index 6e68bc797c..c58bf2c01d 100644 --- a/features/providers/means_report.feature +++ b/features/providers/means_report.feature @@ -28,7 +28,9 @@ Feature: Means report | h3 | Bank statements | Then the following sections should not exist: + | tag | section | | h3 | Your client's accounts | + | h3 | Client's bank accounts | Then the following sections should not exist: | tag | section | @@ -135,8 +137,8 @@ Feature: Means report And the "Bank accounts", for static bank account totals, questions should exist: | question | - | Client's current accounts | - | Client's savings accounts | + | Current accounts | + | Savings accounts | And the "Which savings or investments does your client have?" questions should exist: | question | @@ -200,6 +202,7 @@ Feature: Means report | h2 | Which assets does your client have? | | h2 | Restrictions on your client's assets | | h2 | Payments from scheme or charities | + | h3 | Client's bank accounts | Then the following sections should not exist: | tag | section | @@ -308,8 +311,13 @@ Feature: Means report And the "Bank accounts", for open banking accounts, questions should exist: | question | - | Client's current accounts | - | Client's savings accounts | + | Current accounts | + | Savings accounts | + + And the "Bank accounts", for open banking accounts, questions and answers table should exist: + | question | answer | + | Account Name,12345678,000000 | 75.57 | + | Second Account,87654321,999999 | 57.57 | And the "Your client's accounts" questions should exist: | question | diff --git a/features/step_definitions/generic_steps.rb b/features/step_definitions/generic_steps.rb index adeb59d091..7c985f25d5 100644 --- a/features/step_definitions/generic_steps.rb +++ b/features/step_definitions/generic_steps.rb @@ -72,3 +72,12 @@ def expect_questions_and_answers_in(expected:, selector:) end end end + +def expect_questions_and_answers_in_table(expected:, selector:) + within(selector) do + expected.hashes.each do |row| + expect(page).to have_css("th", text: row[:question]), "expected to find tag \"th\" with text: \"#{row[:question]}\"" + expect(page).to have_css("td", text: row[:answer]), "expected to find tag \"td\" with text: \"#{row[:answer]}\"" + end + end +end diff --git a/features/step_definitions/means_report_steps.rb b/features/step_definitions/means_report_steps.rb index 76e6100b19..7532919f27 100644 --- a/features/step_definitions/means_report_steps.rb +++ b/features/step_definitions/means_report_steps.rb @@ -32,6 +32,23 @@ end Given("I have completed a non-passported application with truelayer") do + bank_provider = create(:bank_provider) + create( + :bank_account, + bank_provider:, + name: "Account Name", + account_number: "12345678", + sort_code: "000000", + balance: "75.57", + ) + create( + :bank_account, + bank_provider:, + name: "Second Account", + account_number: "87654321", + sort_code: "999999", + balance: "57.57", + ) @legal_aid_application = create( :legal_aid_application, :with_proceedings, @@ -60,7 +77,7 @@ explicit_proceedings: %i[da002 da006], set_lead_proceeding: :da002, ) - + @legal_aid_application.applicant.update!(bank_providers: [bank_provider]) login_as @legal_aid_application.provider end @@ -228,6 +245,10 @@ expect_questions_in(selector: "[data-test=\"applicant-bank-accounts\"]", expected: table) end +Then("the \"Bank accounts\", for open banking accounts, questions and answers table should exist:") do |table| + expect_questions_and_answers_in_table(selector: "#applicant-bank-accounts-details", expected: table) +end + Then("the \"Your client's accounts\" questions should exist:") do |table| expect_questions_in(selector: "[data-test=\"offline-savings-accounts\"]", expected: table) end