From 0aa32b370f2a922220238fa848afd2c35af88a92 Mon Sep 17 00:00:00 2001 From: Nat Dean-Lewis Date: Fri, 6 Feb 2026 12:16:05 +0000 Subject: [PATCH 1/5] CLDC-4177: remove redundant inferred CYA vals --- .../person_sex_registered_at_birth.rb | 6 ------ .../questions/sex_registered_at_birth2.rb | 6 ------ .../person_sex_registered_at_birth_spec.rb | 20 +++++-------------- .../sex_registered_at_birth1_spec.rb | 4 ++++ .../sex_registered_at_birth2_spec.rb | 4 +--- 5 files changed, 10 insertions(+), 30 deletions(-) diff --git a/app/models/form/sales/questions/person_sex_registered_at_birth.rb b/app/models/form/sales/questions/person_sex_registered_at_birth.rb index 86bef9acd..ff61f3ee0 100644 --- a/app/models/form/sales/questions/person_sex_registered_at_birth.rb +++ b/app/models/form/sales/questions/person_sex_registered_at_birth.rb @@ -4,12 +4,6 @@ class Form::Sales::Questions::PersonSexRegisteredAtBirth < ::Form::Question @type = "radio" @copy_key = "sales.household_characteristics.sexrab2.person" if person_index == 2 @check_answers_card_number = person_index - @inferred_check_answers_value = [{ - "condition" => { - id => "R", - }, - "value" => "Person prefers not to say", - }] @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/sex_registered_at_birth2.rb b/app/models/form/sales/questions/sex_registered_at_birth2.rb index 9a26d527a..6f9c77eb4 100644 --- a/app/models/form/sales/questions/sex_registered_at_birth2.rb +++ b/app/models/form/sales/questions/sex_registered_at_birth2.rb @@ -5,12 +5,6 @@ class Form::Sales::Questions::SexRegisteredAtBirth2 < ::Form::Question @type = "radio" @copy_key = "sales.household_characteristics.sexrab2.buyer" @check_answers_card_number = 2 - @inferred_check_answers_value = [{ - "condition" => { - "sexrab2" => "R", - }, - "value" => "Buyer prefers not to say", - }] @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb b/spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb index 2f51fa8c4..eb5f10687 100644 --- a/spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb +++ b/spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb @@ -49,9 +49,7 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model end it "has the correct inferred_check_answers_value" do - expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexrab2" => "R" }, "value" => "Person prefers not to say" }, - ]) + expect(question.inferred_check_answers_value).to be_nil end end @@ -68,9 +66,7 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model end it "has the correct inferred_check_answers_value" do - expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexrab3" => "R" }, "value" => "Person prefers not to say" }, - ]) + expect(question.inferred_check_answers_value).to be_nil end end @@ -87,9 +83,7 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model end it "has the correct inferred_check_answers_value" do - expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexrab4" => "R" }, "value" => "Person prefers not to say" }, - ]) + expect(question.inferred_check_answers_value).to be_nil end end @@ -106,9 +100,7 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model end it "has the correct inferred_check_answers_value" do - expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexrab5" => "R" }, "value" => "Person prefers not to say" }, - ]) + expect(question.inferred_check_answers_value).to be_nil end end @@ -125,9 +117,7 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model end it "has the correct inferred_check_answers_value" do - expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexrab6" => "R" }, "value" => "Person prefers not to say" }, - ]) + expect(question.inferred_check_answers_value).to be_nil end end end diff --git a/spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb b/spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb index 0b3661ad6..cc1f981cc 100644 --- a/spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb +++ b/spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb @@ -42,4 +42,8 @@ RSpec.describe Form::Sales::Questions::SexRegisteredAtBirth1, type: :model do it "has the correct check_answers_card_number" do expect(question.check_answers_card_number).to eq(1) end + + it "has the correct inferred_check_answers_value" do + expect(question.inferred_check_answers_value).to be_nil + end end diff --git a/spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb b/spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb index ed0d0bc61..99ded462a 100644 --- a/spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb +++ b/spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb @@ -44,8 +44,6 @@ RSpec.describe Form::Sales::Questions::SexRegisteredAtBirth2, type: :model do end it "has the correct inferred_check_answers_value" do - expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexrab2" => "R" }, "value" => "Buyer prefers not to say" }, - ]) + expect(question.inferred_check_answers_value).to be_nil end end From 01ac4f34dfd5ccbbdf793837da51a7fc1a067533 Mon Sep 17 00:00:00 2001 From: Nat Dean-Lewis Date: Fri, 6 Feb 2026 12:31:57 +0000 Subject: [PATCH 2/5] CLDC-4177: update bu files --- app/services/bulk_upload/sales/year2026/csv_parser.rb | 4 ++-- app/services/bulk_upload/sales/year2026/row_parser.rb | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/services/bulk_upload/sales/year2026/csv_parser.rb b/app/services/bulk_upload/sales/year2026/csv_parser.rb index a512e2f44..069ead551 100644 --- a/app/services/bulk_upload/sales/year2026/csv_parser.rb +++ b/app/services/bulk_upload/sales/year2026/csv_parser.rb @@ -4,8 +4,8 @@ class BulkUpload::Sales::Year2026::CsvParser include CollectionTimeHelper # TODO: CLDC-4162: Update when 2026 format is known - FIELDS = 121 - MAX_COLUMNS = 142 + FIELDS = 127 + MAX_COLUMNS = FIELDS FORM_YEAR = 2026 attr_reader :path diff --git a/app/services/bulk_upload/sales/year2026/row_parser.rb b/app/services/bulk_upload/sales/year2026/row_parser.rb index 8e3e2936c..adb7cc6a2 100644 --- a/app/services/bulk_upload/sales/year2026/row_parser.rb +++ b/app/services/bulk_upload/sales/year2026/row_parser.rb @@ -1041,23 +1041,23 @@ private end def person_2_present? - field_35.present? || field_36.present? || field_34.present? + field_35.present? || field_36.present? || field_34.present? || field_123.present? end def person_3_present? - field_43.present? || field_44.present? || field_42.present? + field_43.present? || field_44.present? || field_42.present? || field_124.present? end def person_4_present? - field_47.present? || field_48.present? || field_46.present? + field_47.present? || field_48.present? || field_46.present? || field_125.present? end def person_5_present? - field_51.present? || field_52.present? || field_50.present? + field_51.present? || field_52.present? || field_50.present? || field_126.present? end def person_6_present? - field_55.present? || field_56.present? || field_54.present? + field_55.present? || field_56.present? || field_54.present? || field_127.present? end def relationship_from_is_partner(is_partner) From d861e6feb90fa65738eb0189f2a1fa895a1b9e04 Mon Sep 17 00:00:00 2001 From: Nat Dean-Lewis Date: Fri, 6 Feb 2026 13:47:20 +0000 Subject: [PATCH 3/5] CLDC-4177: update sales log export service --- app/services/exports/sales_log_export_constants.rb | 14 +++++++------- app/services/exports/sales_log_export_service.rb | 12 ++++++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/services/exports/sales_log_export_constants.rb b/app/services/exports/sales_log_export_constants.rb index a901c1ebf..4dd3d15dc 100644 --- a/app/services/exports/sales_log_export_constants.rb +++ b/app/services/exports/sales_log_export_constants.rb @@ -7,7 +7,7 @@ module Exports::SalesLogExportConstants csv: 2, }.freeze - EXPORT_FIELDS = Set["ID", + ALL_YEAR_EXPORT_FIELDS = Set["ID", "STATUS", "DAY", "MONTH", @@ -135,18 +135,18 @@ module Exports::SalesLogExportConstants "SERVICECHARGES",] (1..6).each do |index| - EXPORT_FIELDS << "AGE#{index}" - EXPORT_FIELDS << "ECSTAT#{index}" - EXPORT_FIELDS << "SEX#{index}" + ALL_YEAR_EXPORT_FIELDS << "AGE#{index}" + ALL_YEAR_EXPORT_FIELDS << "ECSTAT#{index}" + ALL_YEAR_EXPORT_FIELDS << "SEX#{index}" end (2..6).each do |index| - EXPORT_FIELDS << "RELAT#{index}" + ALL_YEAR_EXPORT_FIELDS << "RELAT#{index}" end - POST_2026_EXPORT_FIELDS = Set[] + YEAR_2026_EXPORT_FIELDS = Set[] (1..6).each do |index| - POST_2026_EXPORT_FIELDS << "SEXRAB#{index}" + YEAR_2026_EXPORT_FIELDS << "SEXRAB#{index}" end end diff --git a/app/services/exports/sales_log_export_service.rb b/app/services/exports/sales_log_export_service.rb index cd9dd0a95..5b3f719e8 100644 --- a/app/services/exports/sales_log_export_service.rb +++ b/app/services/exports/sales_log_export_service.rb @@ -156,12 +156,16 @@ module Exports def get_included_fields(sales_log) included_fields = Set[] - included_fields.merge(EXPORT_FIELDS) + included_fields.merge(ALL_YEAR_EXPORT_FIELDS) - if sales_log.form.start_year_2026_or_later? - included_fields.merge(POST_2026_EXPORT_FIELDS) - end + year_fields = case sales_log.collection_start_year + when 2026 + YEAR_2026_EXPORT_FIELDS + else + Set[] + end + included_fields.merge(year_fields) included_fields end From 22eb0c5569a6d00e5b8ab78274ca84f9be464a7f Mon Sep 17 00:00:00 2001 From: Nat Dean-Lewis Date: Fri, 6 Feb 2026 16:05:15 +0000 Subject: [PATCH 4/5] CLDC-4177: update schema --- db/schema.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index c7325e491..6fd081249 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2026_01_23_150201) do +ActiveRecord::Schema[7.2].define(version: 2026_01_28_121417) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -376,6 +376,14 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_23_150201) do t.boolean "manual_address_entry_selected", default: false t.integer "referral_type" t.integer "working_situation_illness_check" + t.string "sexrab1" + t.string "sexrab2" + t.string "sexrab3" + t.string "sexrab4" + t.string "sexrab5" + t.string "sexrab6" + t.string "sexrab7" + t.string "sexrab8" t.index ["assigned_to_id"], name: "index_lettings_logs_on_assigned_to_id" t.index ["bulk_upload_id"], name: "index_lettings_logs_on_bulk_upload_id" t.index ["created_by_id"], name: "index_lettings_logs_on_created_by_id" @@ -788,6 +796,12 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_23_150201) do t.datetime "lasttransaction" t.datetime "initialpurchase" t.boolean "manual_address_entry_selected", default: false + t.string "sexrab1" + t.string "sexrab2" + t.string "sexrab3" + t.string "sexrab4" + t.string "sexrab5" + t.string "sexrab6" t.index ["assigned_to_id"], name: "index_sales_logs_on_assigned_to_id" t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" From c373eeb0cf4a666cb418355c65e56702daa93352 Mon Sep 17 00:00:00 2001 From: Nat Dean-Lewis Date: Fri, 6 Feb 2026 16:11:57 +0000 Subject: [PATCH 5/5] CLDC-4177: linting --- .../exports/sales_log_export_constants.rb | 265 +++++++++--------- 1 file changed, 133 insertions(+), 132 deletions(-) diff --git a/app/services/exports/sales_log_export_constants.rb b/app/services/exports/sales_log_export_constants.rb index 4dd3d15dc..442fe8695 100644 --- a/app/services/exports/sales_log_export_constants.rb +++ b/app/services/exports/sales_log_export_constants.rb @@ -7,146 +7,147 @@ module Exports::SalesLogExportConstants csv: 2, }.freeze - ALL_YEAR_EXPORT_FIELDS = Set["ID", - "STATUS", - "DAY", - "MONTH", - "YEAR", - "DUPLICATESET", - "CREATEDDATE", - "UPLOADDATE", - "OWNINGORGID", - "OWNINGORGNAME", - "MANINGORGID", - "MANINGORGNAME", - "USERNAME", - "USERNAMEID", - "PURCHID", - "TYPE", - "OWNERSHIP", - "COLLECTIONYEAR", - "JOINTMORE", - "JOINT", - "BEDS", - "ETHNIC", - "ETHNICGROUP1", - "LIVEINBUYER1", - "BUILTYPE", - "PROPTYPE", - "NOINT", - "LIVEINBUYER2", - "PRIVACYNOTICE", - "WHEEL", - "HHOLDCOUNT", - "LA", - "INCOME1", - "INC1NK", - "INC1MORT", - "INCOME2", - "INC2NK", - "SAVINGSNK", - "SAVINGS", - "PREVOWN", - "AMENDEDBY", - "AMENDEDBYID", - "MORTGAGE", - "INC2MORT", - "HB", - "FROMBEDS", - "STAIRCASE", - "STAIRBOUGHT", - "STAIROWNED", - "MRENT", - "MRENTPRESTAIRCASING", - "RESALE", - "DEPOSIT", - "CASHDIS", - "DISABLED", - "VALUE", - "EQUITY", - "DISCOUNT", - "GRANT", - "PPCODENK", - "PPOSTC1", - "PPOSTC2", - "PREVLOC", - "PREVLOCNAME", - "PREVIOUSLAKNOWN", - "HHREGRES", - "HHREGRESSTILL", - "PROPLEN", - "HASMSCHARGE", - "MSCHARGE", - "PREVTEN", - "MORTGAGEUSED", - "WCHAIR", - "ARMEDFORCESSPOUSE", - "HODAY", - "HOMONTH", - "HOYEAR", - "FROMPROP", - "SOCPREVTEN", - "MORTLEN1", - "EXTRABOR", - "HHTYPE", - "POSTCODE", - "ISLAINFERRED", - "BULKUPLOADID", - "VALUE_VALUE_CHECK", - "PREVSHARED", - "STAIRCASETOSALE", - "ETHNICGROUP2", - "ETHNIC2", - "BUY2LIVING", - "PREVTEN2", - "UPRN", - "ADDRESS1", - "ADDRESS2", - "TOWNCITY", - "COUNTY", - "LANAME", - "CREATIONMETHOD", - "NATIONALITYALL1", - "NATIONALITYALL2", - "MSCHARGE_VALUE_CHECK", - "ADDRESS1INPUT", - "POSTCODEINPUT", - "ADDRESS_SEARCH_VALUE_CHECK", - "UPRNSELECTED", - "BULKADDRESS1", - "BULKADDRESS2", - "BULKTOWNCITY", - "BULKCOUNTY", - "BULKPOSTCODE", - "BULKLA", - "CREATEDBY", - "CREATEDBYID", - "HASESTATEFEE", - "ESTATEFEE", - "FIRSTSTAIR", - "NUMSTAIR", - "STAIRLASTDAY", - "STAIRLASTMONTH", - "STAIRLASTYEAR", - "STAIRINITIALYEAR", - "STAIRINITIALMONTH", - "STAIRINITIALDAY", - "HASSERVICECHARGES", - "SERVICECHARGES",] + EXPORT_FIELDS = Set[ + "ID", + "STATUS", + "DAY", + "MONTH", + "YEAR", + "DUPLICATESET", + "CREATEDDATE", + "UPLOADDATE", + "OWNINGORGID", + "OWNINGORGNAME", + "MANINGORGID", + "MANINGORGNAME", + "USERNAME", + "USERNAMEID", + "PURCHID", + "TYPE", + "OWNERSHIP", + "COLLECTIONYEAR", + "JOINTMORE", + "JOINT", + "BEDS", + "ETHNIC", + "ETHNICGROUP1", + "LIVEINBUYER1", + "BUILTYPE", + "PROPTYPE", + "NOINT", + "LIVEINBUYER2", + "PRIVACYNOTICE", + "WHEEL", + "HHOLDCOUNT", + "LA", + "INCOME1", + "INC1NK", + "INC1MORT", + "INCOME2", + "INC2NK", + "SAVINGSNK", + "SAVINGS", + "PREVOWN", + "AMENDEDBY", + "AMENDEDBYID", + "MORTGAGE", + "INC2MORT", + "HB", + "FROMBEDS", + "STAIRCASE", + "STAIRBOUGHT", + "STAIROWNED", + "MRENT", + "MRENTPRESTAIRCASING", + "RESALE", + "DEPOSIT", + "CASHDIS", + "DISABLED", + "VALUE", + "EQUITY", + "DISCOUNT", + "GRANT", + "PPCODENK", + "PPOSTC1", + "PPOSTC2", + "PREVLOC", + "PREVLOCNAME", + "PREVIOUSLAKNOWN", + "HHREGRES", + "HHREGRESSTILL", + "PROPLEN", + "HASMSCHARGE", + "MSCHARGE", + "PREVTEN", + "MORTGAGEUSED", + "WCHAIR", + "ARMEDFORCESSPOUSE", + "HODAY", + "HOMONTH", + "HOYEAR", + "FROMPROP", + "SOCPREVTEN", + "MORTLEN1", + "EXTRABOR", + "HHTYPE", + "POSTCODE", + "ISLAINFERRED", + "BULKUPLOADID", + "VALUE_VALUE_CHECK", + "PREVSHARED", + "STAIRCASETOSALE", + "ETHNICGROUP2", + "ETHNIC2", + "BUY2LIVING", + "PREVTEN2", + "UPRN", + "ADDRESS1", + "ADDRESS2", + "TOWNCITY", + "COUNTY", + "LANAME", + "CREATIONMETHOD", + "NATIONALITYALL1", + "NATIONALITYALL2", + "MSCHARGE_VALUE_CHECK", + "ADDRESS1INPUT", + "POSTCODEINPUT", + "ADDRESS_SEARCH_VALUE_CHECK", + "UPRNSELECTED", + "BULKADDRESS1", + "BULKADDRESS2", + "BULKTOWNCITY", + "BULKCOUNTY", + "BULKPOSTCODE", + "BULKLA", + "CREATEDBY", + "CREATEDBYID", + "HASESTATEFEE", + "ESTATEFEE", + "FIRSTSTAIR", + "NUMSTAIR", + "STAIRLASTDAY", + "STAIRLASTMONTH", + "STAIRLASTYEAR", + "STAIRINITIALYEAR", + "STAIRINITIALMONTH", + "STAIRINITIALDAY", + "HASSERVICECHARGES", + "SERVICECHARGES",] (1..6).each do |index| - ALL_YEAR_EXPORT_FIELDS << "AGE#{index}" - ALL_YEAR_EXPORT_FIELDS << "ECSTAT#{index}" - ALL_YEAR_EXPORT_FIELDS << "SEX#{index}" + EXPORT_FIELDS << "AGE#{index}" + EXPORT_FIELDS << "ECSTAT#{index}" + EXPORT_FIELDS << "SEX#{index}" end (2..6).each do |index| - ALL_YEAR_EXPORT_FIELDS << "RELAT#{index}" + EXPORT_FIELDS << "RELAT#{index}" end - YEAR_2026_EXPORT_FIELDS = Set[] + POST_2026_EXPORT_FIELDS = Set[] (1..6).each do |index| - YEAR_2026_EXPORT_FIELDS << "SEXRAB#{index}" + POST_2026_EXPORT_FIELDS << "SEXRAB#{index}" end end