Browse Source

CLDC-4176: Remove sexn from BU

replace fields with sexrabn ones
pull/3201/head
samyou-softwire 3 weeks ago
parent
commit
12732c327a
  1. 20
      app/helpers/bulk_upload/sales_log_to_csv.rb
  2. 4
      app/services/bulk_upload/sales/year2026/csv_parser.rb
  3. 88
      app/services/bulk_upload/sales/year2026/row_parser.rb
  4. 24
      spec/fixtures/files/2026_27_sales_bulk_upload.csv
  5. 14
      spec/services/bulk_upload/sales/year2026/row_parser_spec.rb

20
app/helpers/bulk_upload/sales_log_to_csv.rb

@ -565,14 +565,14 @@ class BulkUpload::SalesLogToCsv
log.wchair,
log.age1,
log.sex1,
log.sexrab1,
log.ethnic, # 30
log.nationality_all_group,
log.ecstat1,
log.buy1livein,
{ "P" => 1, "X" => 2, "R" => 3 }[log.relat2],
log.age2,
log.sex2,
log.sexrab2,
log.ethnic_group2,
log.nationality_all_buyer2_group,
log.ecstat2,
@ -581,19 +581,19 @@ class BulkUpload::SalesLogToCsv
{ "P" => 1, "X" => 2, "R" => 3 }[log.relat3],
log.age3,
log.sex3,
log.sexrab3,
log.ecstat3,
{ "P" => 1, "X" => 2, "R" => 3 }[log.relat4],
log.age4,
log.sex4,
log.sexrab4,
log.ecstat4,
{ "P" => 1, "X" => 2, "R" => 3 }[log.relat5], # 50
log.age5,
log.sex5,
log.sexrab5,
log.ecstat5,
{ "P" => 1, "X" => 2, "R" => 3 }[log.relat6],
log.age6,
log.sex6,
log.sexrab6,
log.ecstat6,
log.prevten,
@ -665,13 +665,7 @@ class BulkUpload::SalesLogToCsv
log.extrabor,
log.deposit, # 120
log.mscharge,
log.sexrab1,
log.sexrab2,
log.sexrab3,
log.sexrab4,
log.sexrab5,
log.sexrab6,
log.buildheightclass, # 128
log.buildheightclass, # 122
]
end

4
app/services/bulk_upload/sales/year2026/csv_parser.rb

@ -4,7 +4,7 @@ class BulkUpload::Sales::Year2026::CsvParser
include CollectionTimeHelper
# TODO: CLDC-4162: Update when 2026 format is known
FIELDS = 128
FIELDS = 122
FORM_YEAR = 2026
attr_reader :path
@ -27,7 +27,7 @@ class BulkUpload::Sales::Year2026::CsvParser
def cols
# TODO: CLDC-4162: Update when 2026 format is known
@cols ||= ("A".."DS").to_a
@cols ||= ("A".."DP").to_a
end
def row_parsers

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

@ -35,14 +35,14 @@ class BulkUpload::Sales::Year2026::RowParser
field_27: "Is the property built or adapted to wheelchair user standards?",
field_28: "Age of buyer 1",
field_29: "Gender identity of buyer 1",
field_29: "Buyer 1's sex, as registered at birth",
field_30: "What is buyer 1’s ethnic group?",
field_31: "What is buyer 1’s nationality?",
field_32: "Working situation of buyer 1",
field_33: "Will buyer 1 live in the property?",
field_34: "Is buyer 2 or person 2 the partner of buyer 1?",
field_35: "Age of person 2",
field_36: "Gender identity of person 2",
field_36: "Buyer/Person 2's sex, as registered at birth",
field_37: "Which of the following best describes buyer 2’s ethnic background?",
field_38: "What is buyer 2’s nationality?",
field_39: "What is buyer 2 or person 2’s working situation?",
@ -51,19 +51,19 @@ class BulkUpload::Sales::Year2026::RowParser
field_42: "Is person 3 the partner of buyer 1?",
field_43: "Age of person 3",
field_44: "Gender identity of person 3",
field_44: "Person 3's sex, as registered at birth",
field_45: "Working situation of person 3",
field_46: "Is person 4 the partner of buyer 1?",
field_47: "Age of person 4",
field_48: "Gender identity of person 4",
field_48: "Person 4's sex, as registered at birth",
field_49: "Working situation of person 4",
field_50: "Is person 5 the partner of buyer 1?",
field_51: "Age of person 5",
field_52: "Gender identity of person 5",
field_52: "Person 5's sex, as registered at birth",
field_53: "Working situation of person 5",
field_54: "Is person 6 the partner of buyer 1?",
field_55: "Age of person 6",
field_56: "Gender identity of person 6",
field_56: "Person 6's sex, as registered at birth",
field_57: "Working situation of person 6",
field_58: "What was buyer 1’s previous tenure?",
@ -136,13 +136,7 @@ class BulkUpload::Sales::Year2026::RowParser
field_120: "How much was the cash deposit paid on the property?",
field_121: "What are the total monthly leasehold charges for the property?",
field_122: "Buyer 1's sex, as registered at birth",
field_123: "Buyer/Person 2's sex, as registered at birth",
field_124: "Person 3's sex, as registered at birth",
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: "What is the building height classification?",
field_122: "What is the building height classification?",
}.freeze
ERROR_BASE_KEY = "validations.sales.2026.bulk_upload".freeze
@ -304,14 +298,7 @@ class BulkUpload::Sales::Year2026::RowParser
attribute :field_119, :integer
attribute :field_120, :decimal
attribute :field_121, :decimal
attribute :field_122, :string
attribute :field_123, :string
attribute :field_124, :string
attribute :field_125, :string
attribute :field_126, :string
attribute :field_127, :string
attribute :field_128, :integer
attribute :field_122, :integer
validates :field_1,
presence: {
@ -552,8 +539,7 @@ class BulkUpload::Sales::Year2026::RowParser
"field_21", # postcode
"field_22", # postcode
"field_28", # age1
"field_29", # sex1
"field_122", # sexrab1
"field_29", # sexrab1
"field_32", # ecstat1
)
end
@ -709,13 +695,6 @@ private
age5: %i[field_51],
age6_known: %i[field_55],
age6: %i[field_55],
sex1: %i[field_29],
sex2: %i[field_36],
sex3: %i[field_44],
sex4: %i[field_48],
sex5: %i[field_52],
sex6: %i[field_56],
relat2: %i[field_34],
relat3: %i[field_42],
relat4: %i[field_46],
@ -828,13 +807,13 @@ private
lasttransaction: %i[field_104 field_105 field_106],
initialpurchase: %i[field_100 field_101 field_102],
sexrab1: %i[field_122],
sexrab2: %i[field_123],
sexrab3: %i[field_124],
sexrab4: %i[field_125],
sexrab5: %i[field_126],
sexrab6: %i[field_127],
buildheightclass: %i[field_128],
sexrab1: %i[field_29],
sexrab2: %i[field_36],
sexrab3: %i[field_44],
sexrab4: %i[field_48],
sexrab5: %i[field_52],
sexrab6: %i[field_56],
buildheightclass: %i[field_122],
}
end
@ -863,20 +842,13 @@ private
attributes["age6_known"] = age6_known?
attributes["age6"] = field_55 if attributes["age6_known"]&.zero? && field_55&.match(/\A\d{1,3}\z|\AR\z/)
attributes["sex1"] = field_29
attributes["sex2"] = field_36
attributes["sex3"] = field_44
attributes["sex4"] = field_48
attributes["sex5"] = field_52
attributes["sex6"] = field_56
attributes["sexrab1"] = field_122
attributes["sexrab2"] = field_123
attributes["sexrab3"] = field_124
attributes["sexrab4"] = field_125
attributes["sexrab5"] = field_126
attributes["sexrab6"] = field_127
attributes["buildheightclass"] = field_128
attributes["sexrab1"] = field_29
attributes["sexrab2"] = field_36
attributes["sexrab3"] = field_44
attributes["sexrab4"] = field_48
attributes["sexrab5"] = field_52
attributes["sexrab6"] = field_56
attributes["buildheightclass"] = field_122
attributes["relat2"] = relationship_from_is_partner(field_34)
attributes["relat3"] = relationship_from_is_partner(field_42)
@ -1077,23 +1049,23 @@ private
end
def person_2_present?
field_35.present? || field_36.present? || field_34.present? || field_123.present?
field_35.present? || field_36.present? || field_34.present?
end
def person_3_present?
field_43.present? || field_44.present? || field_42.present? || field_124.present?
field_43.present? || field_44.present? || field_42.present?
end
def person_4_present?
field_47.present? || field_48.present? || field_46.present? || field_125.present?
field_47.present? || field_48.present? || field_46.present?
end
def person_5_present?
field_51.present? || field_52.present? || field_50.present? || field_126.present?
field_51.present? || field_52.present? || field_50.present?
end
def person_6_present?
field_55.present? || field_56.present? || field_54.present? || field_127.present?
field_55.present? || field_56.present? || field_54.present?
end
def relationship_from_is_partner(is_partner)
@ -1316,7 +1288,6 @@ private
saledate
age1
sexrab1
sex1
ecstat1
owning_organisation
postcode_full
@ -1493,8 +1464,7 @@ private
errors.add(:field_21, error_message) # Postcode
errors.add(:field_22, error_message) # Postcode
errors.add(:field_28, error_message) # Buyer 1 age
errors.add(:field_29, error_message) # Buyer 1 gender
errors.add(:field_122, error_message) # Buyer 1 sex registered at birth
errors.add(:field_29, error_message) # Buyer 1 sex registered at birth
errors.add(:field_32, error_message) # Buyer 1 working situation
errors.add(:field_7, error_message) # Purchaser code
end

24
spec/fixtures/files/2026_27_sales_bulk_upload.csv vendored

File diff suppressed because one or more lines are too long

14
spec/services/bulk_upload/sales/year2026/row_parser_spec.rb

@ -112,13 +112,7 @@ RSpec.describe BulkUpload::Sales::Year2026::RowParser do
field_105: "07",
field_106: "2023",
field_110: "900",
field_122: "F",
field_123: "F",
field_124: "M",
field_125: "M",
field_126: "R",
field_127: "R",
field_128: "1",
field_122: "1",
}
end
@ -321,7 +315,7 @@ RSpec.describe BulkUpload::Sales::Year2026::RowParser do
it "fetches the question's check_answer_label if it exists" do
parser.valid?
expect(parser.errors[:field_29]).to eql([I18n.t("validations.not_answered", question: "buyer 1’s gender identity.")])
expect(parser.errors[:field_29]).to eql([I18n.t("validations.not_answered", question: "buyer 1’s sex registered at birth.")])
end
end
@ -794,7 +788,7 @@ RSpec.describe BulkUpload::Sales::Year2026::RowParser do
:field_21, # Postcode
:field_22, # Postcode
:field_28, # Buyer 1 age
:field_29, # Buyer 1 gender
:field_29, # Buyer 1 sex registered at birth
:field_32, # Buyer 1 working situation
:field_7, # Purchaser code
].each do |field|
@ -824,7 +818,7 @@ RSpec.describe BulkUpload::Sales::Year2026::RowParser do
:field_21, # Postcode
:field_22, # Postcode
:field_28, # Buyer 1 age
:field_29, # Buyer 1 gender
:field_29, # Buyer 1 sex registered at birth
:field_32, # Buyer 1 working situation
:field_7, # Purchaser code
].each do |field|

Loading…
Cancel
Save