diff --git a/app/forms/bank_details_form.rb b/app/forms/bank_details_form.rb index 102c48329a..0d43ca6e94 100644 --- a/app/forms/bank_details_form.rb +++ b/app/forms/bank_details_form.rb @@ -7,7 +7,6 @@ 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 @@ -15,12 +14,9 @@ class BankDetailsForm < Form 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 @@ -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 ) diff --git a/app/forms/bank_or_building_society_form.rb b/app/forms/bank_or_building_society_form.rb deleted file mode 100644 index b03601c17c..0000000000 --- a/app/forms/bank_or_building_society_form.rb +++ /dev/null @@ -1,39 +0,0 @@ -class BankOrBuildingSocietyForm < Form - attribute :bank_or_building_society - - validates :bank_or_building_society, - inclusion: { - in: Claim.bank_or_building_societies.keys, - message: i18n_error_message(:select_bank_or_building_society) - } - - def save - return false unless valid? - - if bank_or_building_society_changed? - journey_session.answers.assign_attributes( - banking_name: nil, - bank_account_number: nil, - bank_sort_code: nil, - building_society_roll_number: nil - ) - end - - journey_session.answers.assign_attributes(bank_or_building_society:) - - journey_session.save! - end - - def radio_options - [ - OpenStruct.new(id: :personal_bank_account, name: "Personal bank account"), - OpenStruct.new(id: :building_society, name: "Building society") - ] - end - - private - - def bank_or_building_society_changed? - answers.bank_or_building_society != bank_or_building_society - end -end diff --git a/app/models/journeys/base_answers_presenter.rb b/app/models/journeys/base_answers_presenter.rb index 9d390a0537..094970ab68 100644 --- a/app/models/journeys/base_answers_presenter.rb +++ b/app/models/journeys/base_answers_presenter.rb @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index a6da19c7bd..c0d0c76ad6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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 @@ -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" @@ -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: @@ -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? @@ -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: diff --git a/spec/forms/bank_details_form_spec.rb b/spec/forms/bank_details_form_spec.rb index d66f48280f..9dde933ade 100644 --- a/spec/forms/bank_details_form_spec.rb +++ b/spec/forms/bank_details_form_spec.rb @@ -22,7 +22,6 @@ banking_name:, bank_sort_code:, bank_account_number:, - building_society_roll_number:, hmrc_validation_attempt_count: } end @@ -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 @@ -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? diff --git a/spec/forms/bank_or_building_society_form_spec.rb b/spec/forms/bank_or_building_society_form_spec.rb deleted file mode 100644 index 3be6dfc0d8..0000000000 --- a/spec/forms/bank_or_building_society_form_spec.rb +++ /dev/null @@ -1,90 +0,0 @@ -require "rails_helper" - -RSpec.describe BankOrBuildingSocietyForm, type: :model do - shared_examples "bank_or_building_society_form" do |journey| - before { - create(:journey_configuration, :student_loans) - create(:journey_configuration, :additional_payments) - } - - let(:journey_session) do - create( - :"#{journey::I18N_NAMESPACE}_session", - answers: attributes_for( - :"#{journey::I18N_NAMESPACE}_answers", - :with_bank_details, - building_society_roll_number: "A123456" - ) - ) - end - - let(:slug) { "bank-or-building-society-form" } - let(:claim_params) { {} } - - subject(:form) do - described_class.new( - journey_session: journey_session, - journey: journey, - params: ActionController::Parameters.new({slug:, claim: claim_params}) - ) - end - - describe "validations" do - it { should allow_value(%w[personal_bank_account building_society]).for(:bank_or_building_society).with_message("Select if you want the money paid in to a personal bank account or building society") } - end - - describe "#save" do - context "when submitted with valid params" do - let(:claim_params) { {bank_or_building_society: "personal_bank_account"} } - - it "saves bank_or_building_society" do - expect(form.save).to be true - - expect( - journey_session.reload.answers.bank_or_building_society - ).to eq "personal_bank_account" - end - end - - context "when bank_or_building_society has not changed" do - let(:claim_params) { {bank_or_building_society: "personal_bank_account"} } - - it "doesn't reset dependent answers" do - expect { expect(form.save).to be true }.to( - not_change { journey_session.reload.answers.banking_name }.and( - not_change { journey_session.reload.answers.bank_account_number } - ).and( - not_change { journey_session.reload.answers.bank_sort_code } - ).and( - not_change { journey_session.reload.answers.building_society_roll_number } - ) - ) - end - end - - context "when bank_or_building_society has changed" do - let(:claim_params) { {bank_or_building_society: "building_society"} } - - it "resets dependent answers" do - expect { expect(form.save).to be true }.to( - change { journey_session.reload.answers.banking_name }.to(nil).and( - change { journey_session.reload.answers.bank_account_number }.to(nil) - ).and( - change { journey_session.reload.answers.bank_sort_code }.to(nil) - ).and( - change { journey_session.reload.answers.building_society_roll_number }.to(nil) - ) - ) - end - end - end - end - - describe "for TeacherStudentLoanReimbursement journey" do - include_examples "bank_or_building_society_form", Journeys::TeacherStudentLoanReimbursement - end - - describe "for AdditionalPaymentsForTeaching journey" do - include_examples "bank_or_building_society_form", Journeys::AdditionalPaymentsForTeaching - end -end diff --git a/spec/helpers/admin/claims_helper_spec.rb b/spec/helpers/admin/claims_helper_spec.rb index 628224d9b3..dc65513444 100644 --- a/spec/helpers/admin/claims_helper_spec.rb +++ b/spec/helpers/admin/claims_helper_spec.rb @@ -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 diff --git a/spec/support/journey_answers_presenter_shared_examples.rb b/spec/support/journey_answers_presenter_shared_examples.rb index b083fe102c..5a44291df8 100644 --- a/spec/support/journey_answers_presenter_shared_examples.rb +++ b/spec/support/journey_answers_presenter_shared_examples.rb @@ -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" @@ -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"] @@ -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