diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb index 097ecbba9..bcfadd047 100644 --- a/app/services/bulk_upload/lettings/row_parser.rb +++ b/app/services/bulk_upload/lettings/row_parser.rb @@ -545,7 +545,7 @@ private attributes["hhmemb"] = hhmemb attributes["unitletas"] = field_105 - attributes["rsnvac"] = field_106 + attributes["rsnvac"] = rsnvac attributes["sheltered"] = field_117 attributes["illness_type_1"] = field_119 @@ -571,9 +571,22 @@ private attributes["voiddate"] = voiddate + attributes["first_time_property_let_as_social_housing"] = first_time_property_let_as_social_housing + attributes end + def first_time_property_let_as_social_housing + case rsnvac + when 15, 16, 17 + 1 + end + end + + def rsnvac + field_106 + end + def voiddate Date.new(field_91 + 2000, field_90, field_89) if field_91.present? && field_90.present? && field_89.present? end diff --git a/spec/services/bulk_upload/lettings/row_parser_spec.rb b/spec/services/bulk_upload/lettings/row_parser_spec.rb index 4235048bc..f8c49c5fb 100644 --- a/spec/services/bulk_upload/lettings/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/row_parser_spec.rb @@ -723,5 +723,15 @@ RSpec.describe BulkUpload::Lettings::RowParser do end end end + + describe "#first_time_property_let_as_social_housing" do + context "when field_106 is 15, 16, or 17" do + let(:attributes) { { bulk_upload:, field_106: %w[15 16 17].sample } } + + it "sets to 1" do + expect(parser.log.first_time_property_let_as_social_housing).to eq(1) + end + end + end end end