Skip to content

Commit

Permalink
Merge pull request #7513 from ministryofjustice/ap-5387/remove-studen…
Browse files Browse the repository at this point in the history
…t-loan-transaction-type

AP-5387: Remove student loan
  • Loading branch information
jsugarman authored Dec 9, 2024
2 parents d75258f + 45c47b5 commit d0daace
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 63 deletions.
1 change: 0 additions & 1 deletion app/forms/providers/base_regular_income_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class BaseRegularIncomeForm < RegularTransactionForm
friends_or_family
maintenance_in
property_or_lodger
student_loan
pension
].freeze

Expand Down
2 changes: 0 additions & 2 deletions app/models/transaction_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class TransactionType < ApplicationRecord
friends_or_family
maintenance_in
property_or_lodger
student_loan
pension
],
debit: %i[
Expand All @@ -30,7 +29,6 @@ class TransactionType < ApplicationRecord
friends_or_family
maintenance_in
property_or_lodger
student_loan
pension
].freeze

Expand Down
7 changes: 3 additions & 4 deletions app/services/populators/transaction_type_populator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ def find_or_create(name, operation)
# "deactivation/archiving" this would mean the test environment and UAT branches would not reflect the
# real world data, as they would not be seeded with that transaction type at all. Archiving a type explicitly,
# aside from being clearer, therefore allows us identify test suite failures and manually test on UAT with
# like-real-world data as well as enable use to conditional logic for existing applications with that transaction
# tyoe that we may want to handle differently
# like-real-world data as well as enable use of conditional logic for existing applications with that transaction
# type that we may want to handle differently.
#
# After a period of time and once we are confident the impact would be minimal we could then remove the transaction type
# After a period of time, once we are confident the impact would be minimal, we could then remove the transaction type
# from the TransactionType::NAMES constant AND possibly delete the old transaction type (and associated bank transactions??)
#
def mark_old_as_archived
TransactionType.active.where.not(name: TransactionType::NAMES.values.flatten).update!(archived_at: Time.current)

TransactionType.active.find_by(name: "student_loan")&.update!(archived_at: Time.current)
TransactionType.active.find_by(name: "excluded_benefits")&.update!(archived_at: Time.current)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
row.with_cell(numeric: true, text: gds_number_to_currency(@cfe_result.mei_property_or_lodger(partner:)))
end
body.with_row do |row|
row.with_cell(header: true, text: t(".student_loan_or_grant"))
row.with_cell(header: true, text: t(".student_finance"))
row.with_cell(numeric: true, text: gds_number_to_currency(@cfe_result.mei_student_loan(partner:)))
end
body.with_row do |row|
Expand Down
1 change: 0 additions & 1 deletion config/locales/cy/activemodel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ cy:
friends_or_family: ylimaf ro sdneirf morf pleh laicnaniF
maintenance_in: stnemyap ecnanetniaM
property_or_lodger: regdol ro ytreporp morf emocnI
student_loan: tnarg ro naol tnedutS
pension: noisneP
rent_or_mortgage: stnemyap gnisuoH
child_care: stnemyap eracdlihC
Expand Down
7 changes: 0 additions & 7 deletions config/locales/cy/transaction_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ cy:
property_or_lodger: regdol ro ytreporp a morf emocnI
rent_or_mortgage: stnemyap gnisuoH
salary: segaw ro yralaS
student_loan: tnarg ro naol tnedutS
providers:
benefits: stifeneB
child_care: stnemyap eracdlihC
Expand All @@ -27,7 +26,6 @@ cy:
property_or_lodger: regdol ro ytreporp a morf emocnI
rent_or_mortgage: stnemyap gnisuoH
salary: segaw ro yralaS
student_loan: tnarg ro naol tnedutS
table_label:
benefits: stifeneB
child_care: eracdlihC
Expand All @@ -40,7 +38,6 @@ cy:
property_or_lodger: ytreporP
rent_or_mortgage: gnisuoH
salary: yralaS
student_loan: naol tnedutS
page_titles:
benefits: stnemyap stifeneb tceleS
child_care: stnemyap eracdlihc tceleS
Expand All @@ -52,7 +49,6 @@ cy:
property_or_lodger: regdol ro ytreporp a morf stnemyap tceleS
rent_or_mortgage: stnemyap gnisuoh tceleS
salary: stnemyap egaw ro yralas tceleS
student_loan: stnemyap tnarg ro naol tneduts tceleS
excluded_benefits: stnemyap stifeneb dedragersid tceleS
benefits:
inset_paras: |
Expand Down Expand Up @@ -91,9 +87,6 @@ cy:
ruoy tnemyap yreve tceleS"
rent_or_mortgage:
inset_text: ".shtnom 3 tsap eht ni edam tneilc ruoy tnemyap gnisuoh yreve tceleS"
student_loan:
inset_text: ".shtnom 3 tsap eht ni deviecer tneilc ruoy tnemyap tnarg ro naol
tneduts yreve tceleS"
pension:
inset_text: ".shtnom 3 tsap eht ni deviecer tneilc ruoy tnemyap noisnep yreve
tceleS"
1 change: 0 additions & 1 deletion config/locales/en/activemodel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ en:
friends_or_family: Financial help
maintenance_in: Maintenance
property_or_lodger: Property
student_loan: Student loan or grant
pension: Pension
rent_or_mortgage: Housing
child_care: Childcare
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en/providers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ en:
friends_or_family: Financial help from friends or family
maintenance: Maintenance payments from a former partner
property_or_lodger: Income from property or lodger
student_loan_or_grant: Student finance
student_finance: Student finance
pension: Pension
total: Total
table_caption: Income
Expand Down
6 changes: 0 additions & 6 deletions config/locales/en/transaction_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ en:
property_or_lodger: Income from a property or lodger
rent_or_mortgage: Housing payments
salary: Salary or wages
student_loan: Student loan or grant
providers:
benefits: Benefits, charitable or government payments
child_care: Childcare payments
Expand All @@ -30,7 +29,6 @@ en:
property_or_lodger: Income from a property or lodger
rent_or_mortgage: Housing payments
salary: Salary or wages
student_loan: Student loan or grant
error_message:
benefits: in benefits
friends_or_family: from friends or family
Expand Down Expand Up @@ -59,7 +57,6 @@ en:
property_or_lodger: Property
rent_or_mortgage: Housing
salary: Salary
student_loan: Student loan
page_titles:
benefits: Select any benefits, charitable or government payments
child_care: Select childcare payments
Expand All @@ -71,7 +68,6 @@ en:
property_or_lodger: Select payments from a property or lodger
rent_or_mortgage: Select housing payments
salary: Select salary or wage payments
student_loan: Select student loan or grant payments
excluded_benefits: Select Government Cost of Living Payments and disregarded benefits
benefits:
inset_paras: |
Expand Down Expand Up @@ -101,7 +97,5 @@ en:
inset_text: Select every payment your client received from property or a lodger in the past 3 months.
rent_or_mortgage:
inset_text: Select every housing payment your client made in the past 3 months.
student_loan:
inset_text: Select every student loan or grant payment your client received in the past 3 months.
pension:
inset_text: Select every pension payment your client received in the past 3 months.
27 changes: 27 additions & 0 deletions db/migrate/20241206121926_destroy_student_loan_transaction_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class DestroyStudentLoanTransactionType < ActiveRecord::Migration[7.2]
disable_ddl_transaction!

def up
TransactionType.find_by(name: 'student_loan')&.destroy!

# reset sort_order attribute of all transaction types
Populators::TransactionTypePopulator.call
end

def down
# Irreversible data migration. You will need the transaction_type_id of any child records to reverse this!
# attribute values from production at time of writing:
#
# "id"=>"a9de405c-74f7-45de-956f-4a602e994450"
# "name"=>"student_loan",
# "operation"=>"credit",
# "created_at"=>Mon, 29 Jul 2019 13:10:16.836407000 BST +01:00,
# "updated_at"=>Wed, 09 Oct 2024 07:32:36.113001000 BST +01:00,
# "sort_order"=>60,
# "archived_at"=>Wed, 09 Oct 2024 07:32:36.112851000 BST +01:00,
# "other_income"=>true,
# "parent_id"=>nil
#
nil
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2024_12_02_152952) do
ActiveRecord::Schema[7.2].define(version: 2024_12_06_121926) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/civil_journey_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
Given("I start the merits application with student finance") do
@legal_aid_application = create(
:application,
:with_applicant_with_student_loan,
:with_applicant_with_student_finance,
:with_proceedings,
:with_non_passported_state_machine,
:provider_assessing_means,
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/review_and_print_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@legal_aid_application = create(
:legal_aid_application,
:with_proceedings,
:with_applicant_with_student_loan,
:with_applicant_with_student_finance,
:with_non_passported_state_machine,
:with_restrictions,
:with_vehicle,
Expand Down
5 changes: 0 additions & 5 deletions spec/factories/bank_transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@
transaction_type { TransactionType.where(name: "property_or_lodger").first || create(:transaction_type, :property_or_lodger) }
end

trait :student_loan do
operation { "credit" }
transaction_type { TransactionType.where(name: "student_loan").first || create(:transaction_type, :student_loan) }
end

trait :pension do
operation { "credit" }
transaction_type { TransactionType.where(name: "pension").first || create(:transaction_type, :pension) }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/legal_aid_applications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
applicant { build(:applicant, :with_address, with_bank_accounts:, same_correspondence_and_home_address: true, has_partner: false) }
end

trait :with_applicant_with_student_loan do
trait :with_applicant_with_student_finance do
transient do
with_bank_accounts { 0 }
end
Expand Down
6 changes: 3 additions & 3 deletions spec/models/transaction_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
it "returns all other_income type TransactionTypes" do
Populators::TransactionTypePopulator.call
names = described_class.other_income.pluck(:name)
expect(names).to eq %w[friends_or_family maintenance_in property_or_lodger student_loan pension]
expect(names).to eq %w[friends_or_family maintenance_in property_or_lodger pension]
end
end

Expand Down Expand Up @@ -194,8 +194,8 @@

describe "active" do
it "does not return records with a date in archived at" do
described_class.find_by(name: "student_loan").update!(archived_at: Time.current)
expect(described_class.active.pluck(:name)).not_to include("student_loan")
described_class.find_by(name: "excluded_benefits").update!(archived_at: Time.current)
expect(described_class.active.pluck(:name)).not_to include("excluded_benefits")
end
end
end
Expand Down
11 changes: 0 additions & 11 deletions spec/services/cfe_civil/components/other_income_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
let!(:maintenance_week_ago) { create(:bank_transaction, :maintenance_in, bank_account:, amount: 125.0, happened_at: 1.week.ago) }
let!(:friends_today) { create(:bank_transaction, :friends_or_family, bank_account:, amount: 60.0, happened_at: Time.zone.today) }
let!(:friends_week_ago) { create(:bank_transaction, :friends_or_family, bank_account:, amount: 60.0, happened_at: 1.week.ago) }
let!(:student_loan_today) { create(:bank_transaction, :student_loan, bank_account:, amount: 355.66, happened_at: Time.zone.today) }
let!(:student_loan_week_ago) { create(:bank_transaction, :student_loan, bank_account:, amount: 355.67, happened_at: 1.week.ago) }
let!(:student_loan_two_week_ago) { create(:bank_transaction, :student_loan, bank_account:, amount: 355.68, happened_at: 2.weeks.ago) }
let(:today) { Time.zone.today.strftime("%Y-%m-%d") }
let(:one_week_ago) { 1.week.ago.strftime("%Y-%m-%d") }
let(:two_weeks_ago) { 2.weeks.ago.strftime("%Y-%m-%d") }
Expand All @@ -51,14 +48,6 @@
{ date: today, amount: 250.0, client_id: maintenance_today.id },
],
},
{
source: "Student loan",
payments: [
{ date: two_weeks_ago, amount: 355.68, client_id: student_loan_two_week_ago.id },
{ date: one_week_ago, amount: 355.67, client_id: student_loan_week_ago.id },
{ date: today, amount: 355.66, client_id: student_loan_today.id },
],
},
],
}.to_json)
end
Expand Down
17 changes: 1 addition & 16 deletions spec/services/populators/transaction_type_populator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Populators
let(:credit_names) { names[:credit] }
let(:debit_names) { names[:debit] }
let(:total) { credit_names.length + debit_names.length }
let(:archived_credit_names) { %i[student_loan excluded_benefits] }
let(:archived_credit_names) { %i[excluded_benefits] }

it "creates instances from names" do
expect { call }.to change(TransactionType, :count).by(total)
Expand Down Expand Up @@ -45,16 +45,6 @@ module Populators
}.to change(TransactionType, :count).by(total)
end

it "does not set archived_at for aleady deactivated student_loan" do
travel_to(yesterday) do
described_class.call
expect(TransactionType.find_by(name: "student_loan").archived_at).to be_within(1.second).of(yesterday)
end

described_class.call
expect(TransactionType.find_by(name: "student_loan").archived_at).to be_within(1.second).of(yesterday)
end

it "does not set archived_at for aleady deactivated excluded_benefits" do
travel_to(yesterday) do
described_class.call
Expand All @@ -76,11 +66,6 @@ module Populators
expect(TransactionType.find_by(name: "council_tax").archived_at).not_to be_nil
end

it "explicitly sets the archived_at date for student_loan" do
call
expect(TransactionType.find_by(name: "student_loan").archived_at).not_to be_nil
end

it "explicitly sets the archived_at date for excluded_benefits" do
call
expect(TransactionType.find_by(name: "excluded_benefits").archived_at).not_to be_nil
Expand Down

0 comments on commit d0daace

Please sign in to comment.