Browse Source

add bulk upload sales 23 buyer2 ethnic fields

pull/1603/head
Phil Lee 2 years ago
parent
commit
f603758194
  1. 20
      app/services/bulk_upload/sales/year2023/row_parser.rb
  2. 16
      spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

20
app/services/bulk_upload/sales/year2023/row_parser.rb

@ -407,6 +407,23 @@ class BulkUpload::Sales::Year2023::RowParser
private
def infer_buyer2_ethnic_group_from_ethnic
case field_40
when 1, 2, 3, 18
0
when 4, 5, 6, 7
1
when 8, 9, 10, 11, 15
2
when 12, 13, 14
3
when 16, 19
4
else
field_40
end
end
def validate_uprn_exists_if_any_key_adddress_fields_are_blank
if field_19.blank? && (field_20.blank? || field_22.blank? || field_24.blank? || field_25.blank?)
errors.add(:field_19, I18n.t("validations.not_answered", question: "UPRN"))
@ -735,6 +752,9 @@ private
attributes["town_or_city"] = field_22
attributes["county"] = field_23
attributes["ethnic_group2"] = infer_buyer2_ethnic_group_from_ethnic
attributes["ethnicbuy2"] = field_40
attributes
end

16
spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

@ -627,5 +627,21 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
expect(parser.log.county).to eql("some county")
end
end
describe "#ethnic_group2" do
let(:attributes) { setup_section_params.merge({ field_40: "1" }) }
it "is correctly set" do
expect(parser.log.ethnic_group2).to be(0)
end
end
describe "#ethnicbuy2" do
let(:attributes) { setup_section_params.merge({ field_40: "1" }) }
it "is correctly set" do
expect(parser.log.ethnicbuy2).to be(1)
end
end
end
end

Loading…
Cancel
Save