Browse Source

CLDC-4178: add gender same as sex question for sales service updates

pull/3188/head
Nat Dean-Lewis 1 month ago
parent
commit
a69595469f
  1. 14
      app/models/derived_variables/sales_log_variables.rb
  2. 52
      app/services/bulk_upload/sales/year2026/row_parser.rb
  3. 1
      app/services/csv/sales_log_csv_service.rb
  4. 2
      app/services/exports/sales_log_export_constants.rb

14
app/models/derived_variables/sales_log_variables.rb

@ -98,6 +98,8 @@ module DerivedVariables::SalesLogVariables
self.numstair = is_firststair? ? 1 : nil if numstair == 1 && firststair_changed?
self.mrent = 0 if stairowned_100?
clear_gender_description_unless_gender_not_same_as_sex! if form.start_year_2026_or_later?
set_encoded_derived_values!(DEPENDENCIES)
end
@ -254,6 +256,18 @@ private
[1, 2].include?(prevten) || [1, 2].include?(prevtenbuy2)
end
def clear_gender_description_unless_gender_not_same_as_sex!
# we do this as the gender same as sex page always contains the gender description box that's hidden
# default submit will send a "" for gender description. this ensure it's nil in this case
# as well as blanking it if the user writes it in mistakenly in bulk upload
(1..6).each do |person_index|
gender_same_as_sex = public_send("gender_same_as_sex#{person_index}")
if gender_same_as_sex.present? && gender_same_as_sex != 2
self["gender_description#{person_index}"] = nil
end
end
end
def reset_address_fields!
self.uprn = nil
self.uprn_known = nil

52
app/services/bulk_upload/sales/year2026/row_parser.rb

@ -142,6 +142,19 @@ class BulkUpload::Sales::Year2026::RowParser
field_125: "Person 4's sex, as registered at birth",
field_126: "Person 5's sex, as registered at birth",
field_127: "Person 6's sex, as registered at birth",
field_128: "Is the gender buyer 1 identifies with the same as their sex registered at birth?",
field_129: "If 'No', enter buyer 1's gender identity",
field_130: "Is the gender buyer/person 2 identifies with the same as their sex registered at birth?",
field_131: "If 'No', enter buyer/person 2's gender identity",
field_132: "Is the gender person 3 identifies with the same as their sex registered at birth?",
field_133: "If 'No', enter person 3's gender identity",
field_134: "Is the gender person 4 identifies with the same as their sex registered at birth?",
field_135: "If 'No', enter person 4's gender identity",
field_136: "Is the gender person 5 identifies with the same as their sex registered at birth?",
field_137: "If 'No', enter person 5's gender identity",
field_138: "Is the gender person 6 identifies with the same as their sex registered at birth?",
field_139: "If 'No', enter person 6's gender identity",
}.freeze
ERROR_BASE_KEY = "validations.sales.2026.bulk_upload".freeze
@ -289,6 +302,19 @@ class BulkUpload::Sales::Year2026::RowParser
attribute :field_126, :string
attribute :field_127, :string
attribute :field_128, :integer
attribute :field_129, :string
attribute :field_130, :integer
attribute :field_131, :string
attribute :field_132, :integer
attribute :field_133, :string
attribute :field_134, :integer
attribute :field_135, :string
attribute :field_136, :integer
attribute :field_137, :string
attribute :field_138, :integer
attribute :field_139, :string
validates :field_1,
presence: {
message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (day)."),
@ -801,6 +827,19 @@ private
sexrab4: %i[field_125],
sexrab5: %i[field_126],
sexrab6: %i[field_127],
gender_same_as_sex1: %i[field_128],
gender_description1: %i[field_129],
gender_same_as_sex2: %i[field_130],
gender_description2: %i[field_131],
gender_same_as_sex3: %i[field_132],
gender_description3: %i[field_133],
gender_same_as_sex4: %i[field_134],
gender_description4: %i[field_135],
gender_same_as_sex5: %i[field_136],
gender_description5: %i[field_137],
gender_same_as_sex6: %i[field_138],
gender_description6: %i[field_139],
}
end
@ -843,6 +882,19 @@ private
attributes["sexrab5"] = field_126
attributes["sexrab6"] = field_127
attributes["gender_same_as_sex1"] = field_128
attributes["gender_description1"] = field_129
attributes["gender_same_as_sex2"] = field_130
attributes["gender_description2"] = field_131
attributes["gender_same_as_sex3"] = field_132
attributes["gender_description3"] = field_133
attributes["gender_same_as_sex4"] = field_134
attributes["gender_description4"] = field_135
attributes["gender_same_as_sex5"] = field_136
attributes["gender_description5"] = field_137
attributes["gender_same_as_sex6"] = field_138
attributes["gender_description6"] = field_139
attributes["relat2"] = relationship_from_is_partner(field_34)
attributes["relat3"] = relationship_from_is_partner(field_42)
attributes["relat4"] = relationship_from_is_partner(field_46)

1
app/services/csv/sales_log_csv_service.rb

@ -115,6 +115,7 @@ module Csv
(2..6).each do |i|
hash["age#{i}"] = { "refused_code" => "-9", "refused_label" => "Not known", "details_known_field" => "details_known_#{i}", "age_known_field" => "age#{i}_known" }
hash["sexrab#{i}"] = { "refused_code" => "R", "refused_label" => "Prefers not to say", "details_known_field" => "details_known_#{i}" }
hash["gender_same_as_sex#{i}"] = { "refused_code" => "3", "refused_label" => "Prefers not to say", "details_known_field" => "details_known_#{i}" }
hash["sex#{i}"] = { "refused_code" => "R", "refused_label" => "Prefers not to say", "details_known_field" => "details_known_#{i}" }
hash["relat#{i}"] = { "refused_code" => "R", "refused_label" => "Prefers not to say", "details_known_field" => "details_known_#{i}" }
hash["ecstat#{i}"] = { "refused_code" => "10", "refused_label" => "Prefers not to say", "details_known_field" => "details_known_#{i}" }

2
app/services/exports/sales_log_export_constants.rb

@ -150,5 +150,7 @@ module Exports::SalesLogExportConstants
(1..6).each do |index|
YEAR_2026_EXPORT_FIELDS << "SEXRAB#{index}"
YEAR_2026_EXPORT_FIELDS << "GENDER_SAME_AS_SEX#{index}"
YEAR_2026_EXPORT_FIELDS << "GENDER_DESCRIPTION#{index}"
end
end

Loading…
Cancel
Save