Skip to content

Commit

Permalink
remove building society roll number
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Oct 3, 2024
1 parent a8be4d4 commit 97bcfc2
Show file tree
Hide file tree
Showing 41 changed files with 17 additions and 563 deletions.
9 changes: 0 additions & 9 deletions app/controllers/claims_form_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ def personal_bank_account_before_update
inject_hmrc_validation_attempt_count_into_the_form
end

def building_society_account_before_update
inject_hmrc_validation_attempt_count_into_the_form
end

def information_provided_before_update
return unless journey_requires_student_loan_details?

Expand All @@ -49,11 +45,6 @@ def personal_bank_account_after_form_save_failure
render_template_for_current_slug
end

def building_society_account_after_form_save_failure
increment_hmrc_validation_attempt_count if hmrc_api_validation_attempted?
render_template_for_current_slug
end

def postcode_search_after_form_save_failure
lookup_failed_error = @form.errors.messages_for(:base).first
if lookup_failed_error
Expand Down
17 changes: 0 additions & 17 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 Expand Up @@ -65,18 +60,6 @@ def bank_sort_code_must_be_six_digits
errors.add(:bank_sort_code, i18n_errors_path(:format_sort_code)) if bank_sort_code.present? && normalised_bank_detail(bank_sort_code) !~ /\A\d{6}\z/
end

def building_society_roll_number_must_be_between_one_and_eighteen_digits
return unless building_society_roll_number.present?

errors.add(:building_society_roll_number, i18n_errors_path(:length_roll_number)) if building_society_roll_number.length > 18
end

def building_society_roll_number_must_be_in_a_valid_format
return unless building_society_roll_number.present?

errors.add(:building_society_roll_number, i18n_errors_path(:format_roll_number)) unless /\A[a-z0-9\-\s.\/]{1,18}\z/i.match?(building_society_roll_number)
end

def bank_account_is_valid
return unless can_validate_with_hmrc_api?

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

This file was deleted.

2 changes: 1 addition & 1 deletion app/helpers/admin/claims_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def days_between(first_date, second_date)
end

def code_msg(bank_account_verification_response, claim)
"Error #{bank_account_verification_response.code} - HMRC API failure. No checks have been completed on the claimant’s #{t("admin.#{claim.bank_or_building_society}")} details. Select yes to manually approve the claimant’s #{t("admin.#{claim.bank_or_building_society}")} details"
"Error #{bank_account_verification_response.code} - 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

def sort_code_msg(bank_account_verification_response)
Expand Down
15 changes: 0 additions & 15 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,11 @@ class Claim < ApplicationRecord

validates :bank_sort_code, on: [:amendment], presence: {message: "Enter a sort code"}
validates :bank_account_number, on: [:amendment], presence: {message: "Enter an account number"}
validates :building_society_roll_number, on: [:submit, :amendment], presence: {message: "Enter a roll number"}, if: -> { building_society? }

validates :payroll_gender, on: [:"payroll-gender-task"], presence: {message: "You must select a gender that will be passed to HMRC"}

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

before_save :normalise_ni_number, if: %i[national_insurance_number national_insurance_number_changed?]
before_save :normalise_bank_account_number, if: %i[bank_account_number bank_account_number_changed?]
Expand Down Expand Up @@ -484,18 +481,6 @@ def normalised_bank_detail(bank_detail)
bank_detail.gsub(/\s|-/, "")
end

def building_society_roll_number_must_be_between_one_and_eighteen_digits
return unless building_society_roll_number.present?

errors.add(:building_society_roll_number, "Building society roll number must be between 1 and 18 characters") if building_society_roll_number.length > 18
end

def building_society_roll_number_must_be_in_a_valid_format
return unless building_society_roll_number.present?

errors.add(:building_society_roll_number, "Building society roll number must only include letters a to z, numbers, hyphens, spaces, forward slashes and full stops") unless /\A[a-z0-9\-\s.\/]{1,18}\z/i.match?(building_society_roll_number)
end

def bank_account_number_must_be_eight_digits
errors.add(:bank_account_number, "Account number must be 8 digits") if bank_account_number.present? && normalised_bank_detail(bank_account_number) !~ /\A\d{8}\z/
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ class SlugSequence
].freeze

PAYMENT_DETAILS_SLUGS = [
"bank-or-building-society",
"personal-bank-account",
"building-society-account",
"gender",
"teacher-reference-number"
].freeze
Expand Down Expand Up @@ -124,9 +122,6 @@ def slugs
sequence.delete("eligibility-confirmed") unless overall_eligibility_status == :eligible_now
sequence.delete("eligible-later") unless overall_eligibility_status == :eligible_later

sequence.delete("personal-bank-account") if answers.building_society?
sequence.delete("building-society-account") if answers.personal_bank_account?

sequence.delete("teacher-reference-number") if answers.logged_in_with_tid? && answers.teacher_reference_number.present?

sequence.delete("correct-school") unless journey_session.logged_in_with_tid_and_has_recent_tps_school?
Expand Down
2 changes: 0 additions & 2 deletions app/models/journeys/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ module Base
"email-verification" => EmailVerificationForm,
"mobile-number" => MobileNumberForm,
"mobile-verification" => MobileVerificationForm,
"bank-or-building-society" => BankOrBuildingSocietyForm,
"personal-bank-account" => BankDetailsForm,
"building-society-account" => BankDetailsForm,
"teacher-reference-number" => TeacherReferenceNumberForm,
"address" => AddressForm,
"postcode-search" => PostcodeSearchForm,
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ class SlugSequence
].freeze

PAYMENT_DETAILS_SLUGS = %w[
bank-or-building-society
personal-bank-account
building-society-account
gender
teacher-reference-number
].freeze
Expand Down Expand Up @@ -121,9 +119,6 @@ def slugs
sequence.delete("mobile-number")
sequence.delete("mobile-verification")
end

sequence.delete("personal-bank-account") if answers.building_society?
sequence.delete("building-society-account") if answers.personal_bank_account?
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class SlugSequence
]

PAYMENT_DETAILS_SLUGS = [
"bank-or-building-society",
"personal-bank-account",
"building-society-account",
"gender"
].freeze

Expand Down Expand Up @@ -69,9 +67,6 @@ def slugs
sequence.delete("mobile-number")
sequence.delete("mobile-verification")
end

sequence.delete("personal-bank-account") if answers.building_society?
sequence.delete("building-society-account") if answers.personal_bank_account?
end
end
end
Expand Down
8 changes: 0 additions & 8 deletions app/models/journeys/session_answers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ def provide_mobile_number?
!!provide_mobile_number
end

def building_society?
bank_or_building_society == "building_society"
end

def personal_bank_account?
bank_or_building_society == "personal_bank_account"
end

def hmrc_bank_validation_succeeded?
!!hmrc_bank_validation_succeeded
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ class SlugSequence
].freeze

PAYMENT_DETAILS_SLUGS = [
"bank-or-building-society",
"personal-bank-account",
"building-society-account",
"gender",
"teacher-reference-number"
].freeze
Expand Down Expand Up @@ -82,8 +80,6 @@ def slugs
sequence.delete("reset-claim") if skipped_dfe_sign_in? || answers.details_check?
sequence.delete("current-school") if answers.employed_at_claim_school? || answers.employed_at_recent_tps_school?
sequence.delete("mostly-performed-leadership-duties") unless answers.had_leadership_position?
sequence.delete("personal-bank-account") if answers.building_society?
sequence.delete("building-society-account") if answers.personal_bank_account?
sequence.delete("mobile-number") if answers.provide_mobile_number == false
sequence.delete("mobile-verification") if answers.provide_mobile_number == false
sequence.delete("ineligible") unless ineligible?
Expand Down
14 changes: 0 additions & 14 deletions app/views/admin/amendments/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,6 @@
</div>
</div>

<div class="govuk-grid-row">
<div class="govuk-grid-column-one-third">
<%= form_group_tag(@amendment, :building_society_roll_number) do %>
<%= claim_form.label :building_society_roll_number, class: "govuk-label" %>
<%= errors_tag @amendment, :building_society_roll_number %>
<% end %>
</div>
<div class="govuk-grid-column-two-thirds">
<div class="govuk-form-group">
<%= claim_form.text_field :building_society_roll_number, class: "govuk-input govuk-input--width-10" %>
</div>
</div>
</div>

<div class="govuk-grid-row">
<div class="govuk-grid-column-one-third">
<%= form_group_tag(@amendment, :address_line_1) do %>
Expand Down
1 change: 0 additions & 1 deletion app/views/admin/tasks/payroll_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<h3 class="govuk-heading-m">
<%= I18n.t(
"admin.tasks.payroll_details.question",
bank_or_building_society: I18n.t("admin.#{@claim.bank_or_building_society}"),
claimant_name: @claim.full_name
) %>
</h3>
Expand Down
14 changes: 1 addition & 13 deletions app/views/claims/_account_details.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<% account_hint = bank_or_building_society == "personal bank account" ? "bank" : bank_or_building_society %>
<% account_card = account_hint == "bank" ? account_hint : "" %>

<%= form_for @form, url: claim_path(current_journey_routing_name), builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_error_summary %>

Expand All @@ -12,7 +9,7 @@
<%= f.govuk_text_field :banking_name,
spellcheck: "false",
label: { text: "Name on your account" },
hint: { text: t("questions.account_hint", bank_or_building_society: account_hint, card: account_card) } %>
hint: { text: t("questions.account_hint") } %>

<%= f.govuk_text_field :bank_sort_code,
width: "one-quarter",
Expand All @@ -25,15 +22,6 @@
autocomplete: "off",
label: { text: "Account number" },
hint: { text: "For example: 00733445" } %>

<% if bank_or_building_society == "building society" %>
<%= f.govuk_text_field :building_society_roll_number,
width: 20,
autocomplete: "off",
spellcheck: "false",
label: { text: "Building society roll number" },
hint: { text: "You can find it on your card, statement or passbook" } %>
<% end %>
<% end %>

<%= govuk_warning_text(text: t("questions.check_your_account_details")) %>
Expand Down
21 changes: 0 additions & 21 deletions app/views/claims/bank_or_building_society.html.erb

This file was deleted.

5 changes: 2 additions & 3 deletions app/views/claims/building_society_account.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<% bank_or_building_society = @form.answers.bank_or_building_society.humanize.downcase %>
<% content_for(:page_title, page_title(t("questions.account_details", bank_or_building_society: bank_or_building_society), journey: current_journey_routing_name, show_error: @form.errors.any?)) %>
<%= content_for(:page_title, page_title(t("questions.account_details", bank_or_building_society: "personal bank account"), journey: current_journey_routing_name, show_error: @form.errors.any?)) %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render partial: "account_details", locals: { bank_or_building_society: bank_or_building_society, current_journey_routing_name: current_journey_routing_name} %>
<%= render partial: "account_details", locals: { bank_or_building_society: "personal bank account", current_journey_routing_name: current_journey_routing_name} %>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/claims/personal_bank_account.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% bank_or_building_society = @form.answers.bank_or_building_society.humanize.downcase %>
<% bank_or_building_society = "personal bank account" %>
<% content_for(:page_title, page_title(t("questions.account_details", bank_or_building_society: bank_or_building_society), journey: current_journey_routing_name, show_error: @form.errors.any?)) %>

<div class="govuk-grid-row">
Expand Down
Loading

0 comments on commit 97bcfc2

Please sign in to comment.