Browse Source

Set uprn confirmed (#1624)

pull/1629/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
f32dfd6d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/models/log.rb
  2. 2
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  3. 2
      app/services/bulk_upload/sales/year2023/row_parser.rb
  4. 1
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
  5. 6
      spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

4
app/models/log.rb

@ -41,7 +41,7 @@ class Log < ApplicationRecord
} }
scope :created_by, ->(user) { where(created_by: user) } scope :created_by, ->(user) { where(created_by: user) }
attr_accessor :skip_update_status attr_accessor :skip_update_status, :skip_update_uprn_confirmed
def process_uprn_change! def process_uprn_change!
if uprn.present? if uprn.present?
@ -53,7 +53,7 @@ class Log < ApplicationRecord
presenter = UprnDataPresenter.new(service.result) presenter = UprnDataPresenter.new(service.result)
self.uprn_known = 1 self.uprn_known = 1
self.uprn_confirmed = nil self.uprn_confirmed = nil unless skip_update_uprn_confirmed
self.address_line1 = presenter.address_line1 self.address_line1 = presenter.address_line1
self.address_line2 = presenter.address_line2 self.address_line2 = presenter.address_line2
self.town_or_city = presenter.town_or_city self.town_or_city = presenter.town_or_city

2
app/services/bulk_upload/lettings/year2023/row_parser.rb

@ -1153,6 +1153,8 @@ 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_18.present? ? 1 : 0 attributes["uprn_known"] = field_18.present? ? 1 : 0
attributes["uprn_confirmed"] = 1 if field_18.present?
attributes["skip_update_uprn_confirmed"] = true
attributes["uprn"] = field_18 attributes["uprn"] = field_18
attributes["address_line1"] = field_19 attributes["address_line1"] = field_19
attributes["address_line2"] = field_20 attributes["address_line2"] = field_20

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

@ -824,6 +824,8 @@ private
attributes["uprn"] = field_19 attributes["uprn"] = field_19
attributes["uprn_known"] = field_19.present? ? 1 : 0 attributes["uprn_known"] = field_19.present? ? 1 : 0
attributes["uprn_confirmed"] = 1 if field_19.present?
attributes["skip_update_uprn_confirmed"] = true
attributes["address_line1"] = field_20 attributes["address_line1"] = field_20
attributes["address_line2"] = field_21 attributes["address_line2"] = field_21
attributes["town_or_city"] = field_22 attributes["town_or_city"] = field_22

1
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -1077,6 +1077,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
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)
expect(parser.log.uprn_confirmed).to be(1)
end end
end end

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

@ -539,6 +539,12 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
it "is valid" do it "is valid" do
expect(parser.errors[:field_19]).to be_blank expect(parser.errors[:field_19]).to be_blank
end end
it "sets UPRN and UPRN known" do
expect(parser.log.uprn).to eq("100023336956")
expect(parser.log.uprn_known).to eq(1)
expect(parser.log.uprn_confirmed).to eq(1)
end
end end
context "when UPRN not known but address known" do context "when UPRN not known but address known" do

Loading…
Cancel
Save