From ea9afeb0aa340601dde92cbe3a156c9c42b7a07c Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Wed, 31 Jul 2024 12:01:29 +0100 Subject: [PATCH] Only set address data in BU for general needs logs --- .../lettings/year2024/row_parser.rb | 43 ++++++++++--------- .../lettings/year2024/row_parser_spec.rb | 40 ++++++++++++++--- 2 files changed, 56 insertions(+), 27 deletions(-) diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index b912c167b..670162575 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -1131,10 +1131,6 @@ private attributes["lettype"] = nil # should get this from rent_type attributes["tenancycode"] = field_13 - attributes["la"] = field_23 - attributes["la_as_entered"] = field_23 - attributes["postcode_known"] = postcode_known - attributes["postcode_full"] = postcode_full attributes["owning_organisation"] = owning_organisation attributes["managing_organisation"] = managing_organisation attributes["renewal"] = renewal @@ -1305,22 +1301,29 @@ private attributes["first_time_property_let_as_social_housing"] = first_time_property_let_as_social_housing - attributes["uprn_known"] = field_16.present? ? 1 : 0 - attributes["uprn_confirmed"] = 1 if field_16.present? - attributes["skip_update_uprn_confirmed"] = true - attributes["uprn"] = field_16 - attributes["address_line1"] = field_17 - attributes["address_line1_as_entered"] = field_17 - attributes["address_line2"] = field_18 - attributes["address_line2_as_entered"] = field_18 - attributes["town_or_city"] = field_19 - attributes["town_or_city_as_entered"] = field_19 - attributes["county"] = field_20 - attributes["county_as_entered"] = field_20 - attributes["address_line1_input"] = address_line1_input - attributes["postcode_full_input"] = postcode_full - attributes["postcode_full_as_entered"] = postcode_full - attributes["select_best_address_match"] = true if field_16.blank? && !supported_housing? + if general_needs? + attributes["uprn_known"] = field_16.present? ? 1 : 0 + attributes["uprn_confirmed"] = 1 if field_16.present? + attributes["skip_update_uprn_confirmed"] = true + attributes["uprn"] = field_16 + attributes["address_line1"] = field_17 + attributes["address_line1_as_entered"] = field_17 + attributes["address_line2"] = field_18 + attributes["address_line2_as_entered"] = field_18 + attributes["town_or_city"] = field_19 + attributes["town_or_city_as_entered"] = field_19 + attributes["county"] = field_20 + attributes["county_as_entered"] = field_20 + attributes["postcode_full"] = postcode_full + attributes["postcode_full_as_entered"] = postcode_full + attributes["postcode_known"] = postcode_known + attributes["la"] = field_23 + attributes["la_as_entered"] = field_23 + + attributes["address_line1_input"] = address_line1_input + attributes["postcode_full_input"] = postcode_full + attributes["select_best_address_match"] = true if field_16.blank? + end attributes end diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb index fbff000fd..18139b63b 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb @@ -1855,7 +1855,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end describe "#uprn" do - let(:attributes) { { bulk_upload:, field_16: "12" } } + let(:attributes) { { bulk_upload:, field_4: 1, field_16: "12" } } it "sets to given value" do expect(parser.log.uprn).to eql("12") @@ -1864,7 +1864,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do describe "#uprn_known" do context "when uprn specified" do - let(:attributes) { { bulk_upload:, field_16: "12" } } + let(:attributes) { { bulk_upload:, field_4: 1, field_16: "12" } } it "sets to 1" do expect(parser.log.uprn_known).to be(1) @@ -1873,7 +1873,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end context "when uprn blank" do - let(:attributes) { { bulk_upload:, field_16: "", field_4: 1 } } + let(:attributes) { { bulk_upload:, field_4: 1, field_16: "" } } it "sets to 0" do expect(parser.log.uprn_known).to be(0) @@ -1882,7 +1882,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end describe "#address_line1" do - let(:attributes) { { bulk_upload:, field_17: "123 Sesame Street" } } + let(:attributes) { { bulk_upload:, field_4: 1, field_17: "123 Sesame Street" } } it "sets to given value" do expect(parser.log.address_line1).to eql("123 Sesame Street") @@ -1890,7 +1890,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end describe "#address_line2" do - let(:attributes) { { bulk_upload:, field_18: "Cookie Town" } } + let(:attributes) { { bulk_upload:, field_4: 1, field_18: "Cookie Town" } } it "sets to given value" do expect(parser.log.address_line2).to eql("Cookie Town") @@ -1898,7 +1898,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end describe "#town_or_city" do - let(:attributes) { { bulk_upload:, field_19: "London" } } + let(:attributes) { { bulk_upload:, field_4: 1, field_19: "London" } } it "sets to given value" do expect(parser.log.town_or_city).to eql("London") @@ -1906,13 +1906,39 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end describe "#county" do - let(:attributes) { { bulk_upload:, field_20: "Greater London" } } + let(:attributes) { { bulk_upload:, field_4: 1, field_20: "Greater London" } } it "sets to given value" do expect(parser.log.county).to eql("Greater London") end end + describe "address related fields for supported housing logs" do + context "when address data is provided for a supported housing log" do + let(:attributes) { { bulk_upload:, field_4: 2, field_16: nil, field_17: "Flat 1", field_18: "Example Place", field_19: "London", field_20: "Greater London", field_21: "SW1A", field_22: "1AA" } } + + it "is not set on the log" do + expect(parser.log.uprn).to be_nil + expect(parser.log.uprn_known).to be_nil + expect(parser.log.address_line1).to be_nil + expect(parser.log.address_line1_as_entered).to be_nil + expect(parser.log.address_line2).to be_nil + expect(parser.log.address_line2_as_entered).to be_nil + expect(parser.log.town_or_city).to be_nil + expect(parser.log.town_or_city_as_entered).to be_nil + expect(parser.log.county).to be_nil + expect(parser.log.county_as_entered).to be_nil + expect(parser.log.postcode_full).to be_nil + expect(parser.log.postcode_full_as_entered).to be_nil + expect(parser.log.la).to be_nil + expect(parser.log.la_as_entered).to be_nil + expect(parser.log.address_line1_input).to be_nil + expect(parser.log.postcode_full_input).to be_nil + expect(parser.log.select_best_address_match).to be_nil + end + end + end + [ %w[age1_known details_known_1 age1 field_42 field_47 field_49], %w[age2_known details_known_2 age2 field_48 field_47 field_49],