Skip to content

Commit

Permalink
second pass
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Oct 1, 2024
1 parent b2a4faf commit 0025fd4
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 222 deletions.
5 changes: 0 additions & 5 deletions app/forms/bank_details_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ class BankDetailsForm < Form
attribute :banking_name, :string
attribute :bank_sort_code, :string
attribute :bank_account_number, :string
attribute :building_society_roll_number, :string

attr_reader :hmrc_api_validation_attempted, :hmrc_api_validation_succeeded, :hmrc_api_response_error

validates :banking_name, presence: {message: i18n_error_message(:enter_banking_name)}
validates :banking_name, format: {with: BANKING_NAME_REGEX_FILTER, message: i18n_error_message(:invalid_banking_name)}, if: -> { banking_name.present? }
validates :bank_sort_code, presence: {message: i18n_error_message(:enter_sort_code)}
validates :bank_account_number, presence: {message: i18n_error_message(:enter_account_number)}
validates :building_society_roll_number, presence: {message: i18n_error_message(:enter_roll_number)}, if: -> { answers.building_society? }

validate :bank_account_number_must_be_eight_digits
validate :bank_sort_code_must_be_six_digits
validate :building_society_roll_number_must_be_between_one_and_eighteen_digits
validate :building_society_roll_number_must_be_in_a_valid_format

# This should be the last validation specified to prevent unnecessary API calls
validate :bank_account_is_valid
Expand All @@ -32,7 +28,6 @@ def save
banking_name: banking_name,
bank_sort_code: normalised_bank_detail(bank_sort_code),
bank_account_number: normalised_bank_detail(bank_account_number),
building_society_roll_number: building_society_roll_number,
hmrc_bank_validation_succeeded: hmrc_bank_validation_succeeded
)

Expand Down
39 changes: 0 additions & 39 deletions app/forms/bank_or_building_society_form.rb

This file was deleted.

9 changes: 3 additions & 6 deletions app/models/journeys/base_answers_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ def identity_answers
end

def payment_answers
change_slug = answers.building_society? ? "building-society-account" : "personal-bank-account"
[].tap do |a|
a << [t("questions.bank_or_building_society"), answers.bank_or_building_society.to_s.humanize, "bank-or-building-society"]
a << ["Name on bank account", answers.banking_name, change_slug]
a << ["Bank sort code", answers.bank_sort_code, change_slug]
a << ["Bank account number", answers.bank_account_number, change_slug]
a << ["Building society roll number", answers.building_society_roll_number, change_slug] if answers.building_society_roll_number.present?
a << ["Name on bank account", answers.banking_name, "personal-bank-account"]
a << ["Bank sort code", answers.bank_sort_code, "personal-bank-account"]
a << ["Bank account number", answers.bank_account_number, "personal-bank-account"]
end
end

Expand Down
20 changes: 5 additions & 15 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ en:
personal_details: "Personal details"
national_insurance_number: "What is your National Insurance number?"
bank_details: "Enter bank account details"
bank_or_building_society: What account do you want the money paid into?
account_details: Enter your %{bank_or_building_society} details
account_hint: "For example: your name as it appears on your %{bank_or_building_society} statement or %{card} card."
account_details: Enter your personal bank account details
account_hint: "For example: your name as it appears on your personal bank account statement or %{card} card."
check_your_account_details: Incorrect details will cause a delay to your payment.
check_and_confirm_qualification_details: Check and confirm your qualification details
qualification_details: Qualification details
Expand Down Expand Up @@ -108,7 +107,6 @@ en:
teacher_reference_number: "Teacher reference number"
national_insurance_number: "National Insurance number"
email_address: "Email address"
building_society: "building society"
personal_bank_account: "bank account"
started_at: "Started at"
submitted_at: "Submitted at"
Expand Down Expand Up @@ -157,8 +155,8 @@ en:
student_loan_plan:
title: "Check student loan plan"
payroll_details:
title: "Check bank/building society account details"
question: "The claimant’s %{bank_or_building_society} details have not been automatically validated. Has the claimant confirmed their %{bank_or_building_society} details?"
title: "Check bank account details"
question: "The claimant’s personal bank account details have not been automatically validated. Has the claimant confirmed their personal bank account details?"
census_subjects_taught:
title: "Check eligible subjects are taught"
visa:
Expand Down Expand Up @@ -234,17 +232,9 @@ en:
enter_roll_number: Enter a roll number
format_account_number: Account number must be 8 digits
format_sort_code: Sort code must be 6 digits
format_roll_number:
Building society roll number must only include letters a to z, numbers, hyphens, spaces, forward slashes and
full stops
invalid_sort_code: Enter a valid sort code
invalid_account_number: Enter the account number associated with the name on the account and/or sort code
invalid_banking_name: Enter a valid name on the account
length_roll_number: Building society roll number must be between 1 and 18 characters
bank_or_building_society:
errors:
select_bank_or_building_society:
Select if you want the money paid in to a personal bank account or building society
address:
questions:
your_address: What is your address?
Expand Down Expand Up @@ -892,7 +882,7 @@ en:
matching_details:
title: Is this claim still valid despite having matching details with other claims?
payroll_details:
title: "Check bank/building society account details"
title: "Check bank account details"
provider_verification:
title: "Has the provider confirmed the claimant's details?"
contract_type:
Expand Down
29 changes: 0 additions & 29 deletions spec/forms/bank_details_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
banking_name:,
bank_sort_code:,
bank_account_number:,
building_society_roll_number:,
hmrc_validation_attempt_count:
}
end
Expand All @@ -38,7 +37,6 @@
let(:banking_name) { "Jo Bloggs" }
let(:bank_sort_code) { rand(100000..999999) }
let(:bank_account_number) { rand(10000000..99999999) }
let(:building_society_roll_number) { nil }
let(:hmrc_validation_attempt_count) { 0 }

describe "#valid?" do
Expand Down Expand Up @@ -91,33 +89,6 @@
it { is_expected.not_to be_valid }
end

context "when building society" do
let(:journey_session) do
create(
:"#{journey::I18N_NAMESPACE}_session",
answers: attributes_for(
:"#{journey::I18N_NAMESPACE}_answers",
bank_or_building_society: "building_society"
)
)
end

context "with valid building society roll number" do
let(:building_society_roll_number) { "CXJ-K6 897/98X" }
it { is_expected.to be_valid }
end

context "with invalid building society roll number" do
let(:building_society_roll_number) { "123456789/ABC.CD-EFGH " }
it { is_expected.not_to be_valid }
end

context "with blank building society roll number" do
let(:building_society_roll_number) { "" }
it { is_expected.not_to be_valid }
end
end

context "when HMRC bank validation is enabled", :with_hmrc_bank_validation_enabled do
it "contacts the HMRC API" do
form.valid?
Expand Down
90 changes: 0 additions & 90 deletions spec/forms/bank_or_building_society_form_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/helpers/admin/claims_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -657,15 +657,6 @@
expect(code_msg(bank_account_verification_response, claim)).to eq "Error 400 - HMRC API failure. No checks have been completed on the claimant’s bank account details. Select yes to manually approve the claimant’s bank account details"
end
end

context "429 error with building society" do
let(:claim) { create(:claim, :submitted, bank_or_building_society: :building_society) }
let(:bank_account_verification_response) { Hmrc::BankAccountVerificationResponse.new(OpenStruct.new({code: 429, body: {}.to_json})) }

it "returns message with code and bank account" do
expect(code_msg(bank_account_verification_response, claim)).to eq "Error 429 - HMRC API failure. No checks have been completed on the claimant’s building society details. Select yes to manually approve the claimant’s building society details"
end
end
end

describe "#sort_code_msg" do
Expand Down
29 changes: 0 additions & 29 deletions spec/support/journey_answers_presenter_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@
create(
:additional_payments_session,
answers: {
bank_or_building_society: "personal_bank_account",
bank_sort_code: "123456",
bank_account_number: "12345678",
banking_name: "Jo Bloggs"
Expand All @@ -199,7 +198,6 @@
context "when a personal bank account is selected" do
it "returns an array of questions and answers for displaying to the user for review" do
expected_answers = [
[I18n.t("questions.bank_or_building_society"), "Personal bank account", "bank-or-building-society"],
["Name on bank account", "Jo Bloggs", "personal-bank-account"],
["Bank sort code", "123456", "personal-bank-account"],
["Bank account number", "12345678", "personal-bank-account"]
Expand All @@ -208,32 +206,5 @@
expect(answers).to eq expected_answers
end
end

context "when a building society is selected" do
let(:journey_session) do
create(
:additional_payments_session,
answers: {
bank_or_building_society: "building_society",
bank_sort_code: "659007",
bank_account_number: "90770224",
banking_name: "David Badger-Hillary",
building_society_roll_number: "5890/87654321"
}
)
end

it "returns an array of questions and answers for displaying to the user for review" do
expected_answers = [
[I18n.t("questions.bank_or_building_society"), "Building society", "bank-or-building-society"],
["Name on bank account", "David Badger-Hillary", "building-society-account"],
["Bank sort code", "659007", "building-society-account"],
["Bank account number", "90770224", "building-society-account"],
["Building society roll number", "5890/87654321", "building-society-account"]
]

expect(answers).to eq expected_answers
end
end
end
end

0 comments on commit 0025fd4

Please sign in to comment.