Browse Source

Only set address data in BU for general needs logs

pull/2540/head
Rachael Booth 2 years ago
parent
commit
ea9afeb0aa
  1. 43
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  2. 40
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

43
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -1131,10 +1131,6 @@ private
attributes["lettype"] = nil # should get this from rent_type attributes["lettype"] = nil # should get this from rent_type
attributes["tenancycode"] = field_13 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["owning_organisation"] = owning_organisation
attributes["managing_organisation"] = managing_organisation attributes["managing_organisation"] = managing_organisation
attributes["renewal"] = renewal attributes["renewal"] = renewal
@ -1305,22 +1301,29 @@ private
attributes["first_time_property_let_as_social_housing"] = first_time_property_let_as_social_housing attributes["first_time_property_let_as_social_housing"] = first_time_property_let_as_social_housing
attributes["uprn_known"] = field_16.present? ? 1 : 0 if general_needs?
attributes["uprn_confirmed"] = 1 if field_16.present? attributes["uprn_known"] = field_16.present? ? 1 : 0
attributes["skip_update_uprn_confirmed"] = true attributes["uprn_confirmed"] = 1 if field_16.present?
attributes["uprn"] = field_16 attributes["skip_update_uprn_confirmed"] = true
attributes["address_line1"] = field_17 attributes["uprn"] = field_16
attributes["address_line1_as_entered"] = field_17 attributes["address_line1"] = field_17
attributes["address_line2"] = field_18 attributes["address_line1_as_entered"] = field_17
attributes["address_line2_as_entered"] = field_18 attributes["address_line2"] = field_18
attributes["town_or_city"] = field_19 attributes["address_line2_as_entered"] = field_18
attributes["town_or_city_as_entered"] = field_19 attributes["town_or_city"] = field_19
attributes["county"] = field_20 attributes["town_or_city_as_entered"] = field_19
attributes["county_as_entered"] = field_20 attributes["county"] = field_20
attributes["address_line1_input"] = address_line1_input attributes["county_as_entered"] = field_20
attributes["postcode_full_input"] = postcode_full attributes["postcode_full"] = postcode_full
attributes["postcode_full_as_entered"] = postcode_full attributes["postcode_full_as_entered"] = postcode_full
attributes["select_best_address_match"] = true if field_16.blank? && !supported_housing? 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 attributes
end end

40
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -1855,7 +1855,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
describe "#uprn" do 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 it "sets to given value" do
expect(parser.log.uprn).to eql("12") expect(parser.log.uprn).to eql("12")
@ -1864,7 +1864,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
describe "#uprn_known" do describe "#uprn_known" do
context "when uprn specified" 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 it "sets to 1" do
expect(parser.log.uprn_known).to be(1) expect(parser.log.uprn_known).to be(1)
@ -1873,7 +1873,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
context "when uprn blank" do 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 it "sets to 0" do
expect(parser.log.uprn_known).to be(0) expect(parser.log.uprn_known).to be(0)
@ -1882,7 +1882,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
describe "#address_line1" do 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 it "sets to given value" do
expect(parser.log.address_line1).to eql("123 Sesame Street") expect(parser.log.address_line1).to eql("123 Sesame Street")
@ -1890,7 +1890,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
describe "#address_line2" do 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 it "sets to given value" do
expect(parser.log.address_line2).to eql("Cookie Town") expect(parser.log.address_line2).to eql("Cookie Town")
@ -1898,7 +1898,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
describe "#town_or_city" do 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 it "sets to given value" do
expect(parser.log.town_or_city).to eql("London") expect(parser.log.town_or_city).to eql("London")
@ -1906,13 +1906,39 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
describe "#county" do 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 it "sets to given value" do
expect(parser.log.county).to eql("Greater London") expect(parser.log.county).to eql("Greater London")
end end
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[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], %w[age2_known details_known_2 age2 field_48 field_47 field_49],

Loading…
Cancel
Save