Skip to content

Commit

Permalink
ap-4566: Display bank accounts and balances on means report
Browse files Browse the repository at this point in the history
also Review and print application page

and fix means_report.feature
  • Loading branch information
kmahern committed Nov 8, 2023
1 parent 1fb965a commit 3389ccd
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 35 deletions.
80 changes: 50 additions & 30 deletions app/views/shared/check_answers/_assets.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,40 @@
<!-- non-passported truelayer only -->

<% if read_only %>
<h3 class="govuk-heading-m"><%= t(".assets.client_bank_accounts") %></h2>
<h3 class="govuk-heading-m"><%= t(".assets.clients_bank_accounts") %></h3>

<%= 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 %>

<h3 class="govuk-heading-m"><%= t(".assets.money_in_bank_accounts") %></h3>

<%= 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 %>
<!-- passported and non-passported bank statement uploaded -->
<div class="govuk-grid-row" id="app-check-your-answers__offline_accounts_link">
<div class="govuk-grid-column-two-thirds">
<h3 class="govuk-heading-m"><%= t(".assets.client_bank_accounts") %></h3>
</div>
<% if read_only == false %>
<div class="govuk-grid-column-two-thirds">
<h3 class="govuk-heading-m"><%= t(".assets.client_bank_accounts") %></h3>
</div>
<div class="govuk-grid-column-one-third align-text-right">
<p>
<%= govuk_link_to(
Expand All @@ -47,13 +59,13 @@
</div>
<% end %>
</div>
<%= 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 %>
Expand All @@ -66,10 +78,10 @@
:offline_accounts
end %>
<div class="govuk-grid-row" id="app-check-your-answers__partner_offline_accounts_link">
<div class="govuk-grid-column-two-thirds">
<h3 class="govuk-heading-m"><%= t(".assets.partner_bank_accounts") %></h3>
</div>
<% if read_only == false %>
<div class="govuk-grid-column-two-thirds govuk-!-padding-top-9">
<h3 class="govuk-heading-m"><%= t(".assets.partner_bank_accounts") %></h3>
</div>
<div class="govuk-grid-column-one-third align-text-right">
<p>
<%= govuk_link_to(
Expand All @@ -81,7 +93,7 @@
</div>
<% end %>
</div>
<%= 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") } %>
Expand All @@ -94,10 +106,10 @@

<% if @legal_aid_application.uploading_bank_statements? || !@legal_aid_application.non_passported? %>
<div class="govuk-grid-row" id="app-check-your-answers__joint_offline_accounts_link">
<div class="govuk-grid-column-two-thirds">
<h3 class="govuk-heading-m"><%= t(".assets.joint_bank_accounts") %></h3>
</div>
<% if read_only == false %>
<div class="govuk-grid-column-two-thirds govuk-!-padding-top-9">
<h3 class="govuk-heading-m"><%= t(".assets.joint_bank_accounts") %></h3>
</div>
<div class="govuk-grid-column-one-third align-text-right">
<p>
<%= govuk_link_to(
Expand All @@ -109,7 +121,7 @@
</div>
<% end %>
</div>
<%= 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") } %>
Expand All @@ -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? %>
<div class="govuk-!-padding-top-9">
<%= render "shared/check_answers/offline_savings_accounts", read_only: %>
</div>
<% end %>

<div class="govuk-!-padding-top-9">
<%= 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:,
) %>
</div>

<%= render(
"shared/check_answers/one_link_section",
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,17 @@ 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
partner_current_account: Partner's current accounts
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:
Expand Down
16 changes: 12 additions & 4 deletions features/providers/means_report.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down
9 changes: 9 additions & 0 deletions features/step_definitions/generic_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 22 additions & 1 deletion features/step_definitions/means_report_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3389ccd

Please sign in to comment.