Browse Source

CLDC-4141: replace sex with sexrab where relevant for 2026

CLDC-4140-remove-old-gender-question-lettings
Nat Dean-Lewis 6 days ago
parent
commit
b105572783
  1. 26
      app/helpers/bulk_upload/lettings_log_to_csv.rb
  2. 2
      app/models/derived_variables/lettings_log_variables.rb
  3. 8
      app/models/form/question.rb
  4. 6
      app/models/lettings_log.rb
  5. 2
      app/services/bulk_upload/lettings/year2026/csv_parser.rb
  6. 25
      app/services/bulk_upload/lettings/year2026/row_parser.rb
  7. 17
      app/services/exports/lettings_log_export_constants.rb
  8. 2
      spec/factories/lettings_log.rb
  9. 10
      spec/fixtures/variable_definitions/lettings_download_26_27.csv

26
app/helpers/bulk_upload/lettings_log_to_csv.rb

@ -144,40 +144,40 @@ class BulkUpload::LettingsLogToCsv
log.tenancylength,
log.age1 || overrides[:age1],
log.sex1,
log.sexrab1,
log.ethnic,
log.nationality_all_group,
log.ecstat1,
relat_number(log.relat2),
log.age2 || overrides[:age2],
log.sex2,
log.sexrab2,
log.ecstat2, # 50
relat_number(log.relat3),
log.age3 || overrides[:age3],
log.sex3,
log.sexrab3,
log.ecstat3,
relat_number(log.relat4),
log.age4 || overrides[:age4],
log.sex4,
log.sexrab4,
log.ecstat4,
relat_number(log.relat5),
log.age5 || overrides[:age5], # 60
log.sex5,
log.sexrab5,
log.ecstat5,
relat_number(log.relat6),
log.age6 || overrides[:age6],
log.sex6,
log.sexrab6,
log.ecstat6,
relat_number(log.relat7),
log.age7 || overrides[:age7],
log.sex7,
log.sexrab7,
log.ecstat7, # 70
relat_number(log.relat8),
log.age8 || overrides[:age8],
log.sex8,
log.sexrab8,
log.ecstat8,
log.armedforces,
log.leftreg,
@ -238,15 +238,7 @@ class BulkUpload::LettingsLogToCsv
log.pscharge,
log.supcharg,
log.hbrentshortfall,
log.tshortfall,
log.sexrab1, # 130
log.sexrab2,
log.sexrab3,
log.sexrab4,
log.sexrab5,
log.sexrab6,
log.sexrab7,
log.sexrab8, # 137
log.tshortfall, # 129
]
end

2
app/models/derived_variables/lettings_log_variables.rb

@ -270,7 +270,7 @@ private
end
def get_refused
return 1 if details_unknown? || age_refused? || sex_refused? || relat_refused? || ecstat_refused?
return 1 if details_unknown? || age_refused? || sex_refused? || sexrab_refused? || relat_refused? || ecstat_refused?
0
end

8
app/models/form/question.rb

@ -434,6 +434,14 @@ private
sex6: %w[R],
sex7: %w[R],
sex8: %w[R],
sexrab1: %w[R],
sexrab2: %w[R],
sexrab3: %w[R],
sexrab4: %w[R],
sexrab5: %w[R],
sexrab6: %w[R],
sexrab7: %w[R],
sexrab8: %w[R],
relat2: [3],
relat3: [3],
relat4: [3],

6
app/models/lettings_log.rb

@ -676,7 +676,7 @@ class LettingsLog < Log
end
def has_any_person_details?(person_index)
["sex#{person_index}", "relat#{person_index}", "ecstat#{person_index}"].any? { |field| public_send(field).present? } || public_send("age#{person_index}_known") == 1
["sex#{person_index}", "sexrab#{person_index}", "relat#{person_index}", "ecstat#{person_index}"].any? { |field| public_send(field).present? } || public_send("age#{person_index}_known") == 1
end
def details_not_known_for_person?(person_index)
@ -884,6 +884,10 @@ private
[sex1, sex2, sex3, sex4, sex5, sex6, sex7, sex8].any?("R")
end
def sexrab_refused?
[sexrab1, sexrab2, sexrab3, sexrab4, sexrab5, sexrab6, sexrab7, sexrab8].any?("R")
end
def relat_refused?
[relat2, relat3, relat4, relat5, relat6, relat7, relat8].any?("R")
end

2
app/services/bulk_upload/lettings/year2026/csv_parser.rb

@ -4,7 +4,7 @@ class BulkUpload::Lettings::Year2026::CsvParser
include CollectionTimeHelper
# TODO: CLDC-4162: Update when 2026 format is known
FIELDS = 137
FIELDS = 129
FORM_YEAR = 2026
attr_reader :path

25
app/services/bulk_upload/lettings/year2026/row_parser.rb

@ -47,37 +47,37 @@ class BulkUpload::Lettings::Year2026::RowParser
field_40: "If 'Other', what is the type of tenancy?",
field_41: "What is the length of the fixed-term tenancy to the nearest year?",
field_42: "What is the lead tenant’s age?",
field_43: "Which of these best describes the lead tenant’s gender identity?",
field_43: "Lead tenant's sex, as registered at birth",
field_44: "Which of these best describes the lead tenant’s ethnic background?",
field_45: "What is the lead tenant’s nationality?",
field_46: "Which of these best describes the lead tenant’s working situation?",
field_47: "Is person 2 the partner of the lead tenant?",
field_48: "What is person 2’s age?",
field_49: "Which of these best describes person 2’s gender identity?",
field_49: "Person 2's sex, as registered at birth",
field_50: "Which of these best describes person 2’s working situation?",
field_51: "Is person 3 the partner of the lead tenant?",
field_52: "What is person 3’s age?",
field_53: "Which of these best describes person 3’s gender identity?",
field_53: "Person 3's sex, as registered at birth",
field_54: "Which of these best describes person 3’s working situation?",
field_55: "Is person 4 the partner of the lead tenant?",
field_56: "What is person 4’s age?",
field_57: "Which of these best describes person 4’s gender identity?",
field_57: "Person 4's sex, as registered at birth",
field_58: "Which of these best describes person 4’s working situation?",
field_59: "Is person 5 the partner of the lead tenant?",
field_60: "What is person 5’s age?",
field_61: "Which of these best describes person 5’s gender identity?",
field_61: "Person 5's sex, as registered at birth",
field_62: "Which of these best describes person 5’s working situation?",
field_63: "Is person 6 the partner of the lead tenant?",
field_64: "What is person 6’s age?",
field_65: "Which of these best describes person 6’s gender identity?",
field_65: "Person 6's sex, as registered at birth",
field_66: "Which of these best describes person 6’s working situation?",
field_67: "Is person 7 the partner of the lead tenant?",
field_68: "What is person 7’s age?",
field_69: "Which of these best describes person 7’s gender identity?",
field_69: "Person 7's sex, as registered at birth",
field_70: "Which of these best describes person 7’s working situation?",
field_71: "Is person 8 the partner of the lead tenant?",
field_72: "What is person 8’s age?",
field_73: "Which of these best describes person 8’s gender identity?",
field_73: "Person 8's sex, as registered at birth",
field_74: "Which of these best describes person 8’s working situation?",
field_75: "Does anybody in the household have links to the UK armed forces?",
field_76: "Is this person still serving in the UK armed forces?",
@ -134,15 +134,6 @@ class BulkUpload::Lettings::Year2026::RowParser
field_127: "What is the support charge?",
field_128: "After the household has received any housing-related benefits, will they still need to pay for rent and charges?",
field_129: "What do you expect the outstanding amount to be?",
field_130: "Lead tenant's sex, as registered at birth",
field_131: "Person 2's sex, as registered at birth",
field_132: "Person 3's sex, as registered at birth",
field_133: "Person 4's sex, as registered at birth",
field_134: "Person 5's sex, as registered at birth",
field_135: "Person 6's sex, as registered at birth",
field_136: "Person 7's sex, as registered at birth",
field_137: "Person 8's sex, as registered at birth",
}.freeze
RENT_TYPE_BU_MAPPING = {

17
app/services/exports/lettings_log_export_constants.rb

@ -141,7 +141,6 @@ module Exports::LettingsLogExportConstants
(1..8).each do |index|
ALL_YEAR_EXPORT_FIELDS << "age#{index}"
ALL_YEAR_EXPORT_FIELDS << "ecstat#{index}"
ALL_YEAR_EXPORT_FIELDS << "sex#{index}"
end
(2..8).each do |index|
ALL_YEAR_EXPORT_FIELDS << "relat#{index}"
@ -159,6 +158,9 @@ module Exports::LettingsLogExportConstants
"national",
"offered",
]
(1..8).each do |index|
YEAR_2021_EXPORT_FIELDS << "sex#{index}"
end
YEAR_2022_EXPORT_FIELDS = Set[
"builtype",
@ -166,6 +168,9 @@ module Exports::LettingsLogExportConstants
"national",
"offered",
]
(1..8).each do |index|
YEAR_2022_EXPORT_FIELDS << "sex#{index}"
end
YEAR_2023_EXPORT_FIELDS = Set[
"builtype",
@ -173,6 +178,9 @@ module Exports::LettingsLogExportConstants
"national",
"offered",
]
(1..8).each do |index|
YEAR_2023_EXPORT_FIELDS << "sex#{index}"
end
YEAR_2024_EXPORT_FIELDS = Set[
"builtype",
@ -193,6 +201,9 @@ module Exports::LettingsLogExportConstants
"supcharg_value_check",
"carehome_charges_value_check",
]
(1..8).each do |index|
YEAR_2024_EXPORT_FIELDS << "sex#{index}"
end
YEAR_2025_EXPORT_FIELDS = Set[
"builtype",
@ -211,6 +222,9 @@ module Exports::LettingsLogExportConstants
"pscharge_value_check",
"supcharg_value_check",
]
(1..8).each do |index|
YEAR_2025_EXPORT_FIELDS << "sex#{index}"
end
YEAR_2026_EXPORT_FIELDS = Set[
"accessible_register",
@ -228,7 +242,6 @@ module Exports::LettingsLogExportConstants
"pscharge_value_check",
"supcharg_value_check",
]
(1..8).each do |index|
YEAR_2026_EXPORT_FIELDS << "sexrab#{index}"
end

2
spec/factories/lettings_log.rb

@ -60,7 +60,6 @@ FactoryBot.define do
age1_known { 0 }
age1 { Faker::Number.within(range: 25..45) }
sexrab1 { %w[F M R].sample }
sex1 { %w[F M X R].sample }
ethnic_group { 0 }
ethnic { 2 }
national { 13 }
@ -72,7 +71,6 @@ FactoryBot.define do
details_known_2 { 0 }
age2 { Faker::Number.within(range: 25..45) }
sexrab2 { %w[F M R].sample }
sex2 { %w[F M X R].sample }
ecstat2 { 6 }
homeless { 1 }
underoccupation_benefitcap { 0 }

10
spec/fixtures/variable_definitions/lettings_download_26_27.csv vendored

@ -65,14 +65,13 @@ sheltered,Is this letting in sheltered accommodation?
declaration,Has the tenant seen the MHCLG privacy notice?
hhmemb,How many people live in the household at this letting?
pregnancy_value_check,The following soft validation was confirmed: You told us somebody in the household is pregnant. You also told us there are no female tenants living at the property.
refused,Where household characteristics have a 'Refused' option for some or all of: AGE1-AGE8, SEX1-SEX8, RELAT2-RELAT8, ECSTAT1-ECSTAT8
refused,Where household characteristics have a 'Refused' option for some or all of: AGE1-AGE8, SEXRAB1-SEXRAB8, RELAT2-RELAT8, ECSTAT1-ECSTAT8
hhtype,Type of household 1 = 1 elder; 2 = 2 adults, including elder(s); 3 = 1 adult; 4 = 2 adults; 5 = 1 adult & 1+ children; 6 = 2+ adults & 1+ children; 9 = Other
totchild,Total number of dependent children in the household (Sum of when RELAT2-8 = C)
totelder,Total number of elders in household (Sum of when AGE1-8 >= 60)
totadult,Total number of adults in household
age1,What is the lead tenant's age?
retirement_value_check,The following soft validation was confirmed: You told us this person is aged %{age} years and retired. The minimum expected retirement age for %{gender} in England is %{age}.
sex1,Which of these best describes the lead tenant's gender identity?
ethnic_group,What is the lead tenant's ethnic group?
ethnic,Which of these best describes the lead tenant's ethnic background?
nationality_all,What is the lead tenant's nationality?
@ -82,37 +81,30 @@ relat2,What is person 2's relationship to the lead tenant?
partner_under_16_value_check,The following soft validation was confirmed: You said that [person X]'s relationship to lead tenant is partner, and that their age is [AGEX]. Are you sure this is correct?
multiple_partners_value_check,The following soft validation was confirmed: You said that more than one person in the household is the partner of the lead tenant. Are you sure this is correct?
age2,What is person 2's age?
sex2,Which of these best describes person 2's gender identity?
ecstat2,Which of these best describes person 2's working situation?
details_known_3,Are the details of tenant 3 known?
relat3,What is person 3's relationship to the lead tenant?
age3,What is person 3's age?
sex3,Which of these best describes person 3's gender identity?
ecstat3,Which of these best describes person 3's working situation?
details_known_4,Are the details of tenant 4 known?
relat4,What is person 4's relationship to the lead tenant?
age4,What is person 4's age?
sex4,Which of these best describes person 4's gender identity?
ecstat4,Which of these best describes person 4's working situation?
details_known_5,Are the details of tenant 5 known?
relat5,What is person 5's relationship to the lead tenant?
age5,What is person 5's age?
sex5,Which of these best describes person 5's gender identity?
ecstat5,Which of these best describes person 5's working situation?
details_known_6,Are the details of tenant 6 known?
relat6,What is person 6's relationship to the lead tenant?
age6,What is person 6's age?
sex6,Which of these best describes person 6's gender identity?
ecstat6,Which of these best describes person 6's working situation?
details_known_7,Are the details of tenant 7 known?
relat7,What is person 7's relationship to the lead tenant?
age7,What is person 7's age?
sex7,Which of these best describes person 7's gender identity?
ecstat7,Which of these best describes person 7's working situation?
details_known_8,Are the details of tenant 8 known?
relat8,What is person 8's relationship to the lead tenant?
age8,What is person 8's age?
sex8,Which of these best describes person 8's gender identity?
ecstat8,Which of these best describes person 8's working situation?
armedforces,Does anybody in the household have links to the UK armed forces?
leftreg,Is this person still serving in the UK armed forces?

Can't render this file because it has a wrong number of fields in line 25.
Loading…
Cancel
Save