Browse Source

Merge branch 'CLDC-4177-sales-sab-question' into CLDC-4141-lettings-sab-question

pull/3156/head
Nat Dean-Lewis 2 weeks ago
parent
commit
855528e5ab
  1. 6
      app/models/form/sales/questions/person_sex_registered_at_birth.rb
  2. 6
      app/models/form/sales/questions/sex_registered_at_birth2.rb
  3. 4
      app/services/bulk_upload/sales/year2026/csv_parser.rb
  4. 10
      app/services/bulk_upload/sales/year2026/row_parser.rb
  5. 12
      app/services/exports/sales_log_export_service.rb
  6. 20
      spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb
  7. 4
      spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb
  8. 4
      spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb

6
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

6
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

4
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

10
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)

12
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

20
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

4
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

4
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

Loading…
Cancel
Save