Browse Source

Correctly set previous postcode known (#1658)

pull/1664/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
e27b6fa9a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/services/bulk_upload/sales/year2022/row_parser.rb
  2. 8
      app/services/bulk_upload/sales/year2023/row_parser.rb
  3. 28
      spec/services/bulk_upload/sales/year2022/row_parser_spec.rb
  4. 28
      spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

8
app/services/bulk_upload/sales/year2022/row_parser.rb

@ -625,7 +625,7 @@ private
attributes["prevten"] = buyer_not_interviewed? && field_39.blank? ? 0 : field_39
attributes["prevloc"] = field_40
attributes["previous_la_known"] = previous_la_known
attributes["ppcodenk"] = field_43
attributes["ppcodenk"] = previous_postcode_known
attributes["ppostcode_full"] = ppostcode_full
attributes["pregyrha"] = field_44
@ -907,6 +907,12 @@ private
field_40.present? ? 1 : 0
end
def previous_postcode_known
return 1 if field_43.blank?
0 if field_43 == 1
end
def soctenant
return unless field_39 && field_113

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

@ -819,7 +819,7 @@ private
attributes["prevten"] = field_62
attributes["prevloc"] = field_66
attributes["previous_la_known"] = previous_la_known
attributes["ppcodenk"] = field_63
attributes["ppcodenk"] = previous_postcode_known
attributes["ppostcode_full"] = ppostcode_full
attributes["pregyrha"] = field_67
@ -1107,6 +1107,12 @@ private
field_66.present? ? 1 : 0
end
def previous_postcode_known
return 1 if field_63 == 2
0 if field_63 == 1
end
def block_log_creation!
self.block_log_creation = true
end

28
spec/services/bulk_upload/sales/year2022/row_parser_spec.rb

@ -144,6 +144,34 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
end
end
describe "previous postcode known" do
context "when field_43 is 1" do
let(:attributes) do
{
bulk_upload:,
field_43: 1,
}
end
it "sets previous postcode known to yes" do
expect(parser.log.ppcodenk).to eq(0)
end
end
context "when field_43 is nil" do
let(:attributes) do
{
bulk_upload:,
field_43: nil,
}
end
it "sets previous postcode known to no" do
expect(parser.log.ppcodenk).to eq(1)
end
end
end
describe "validations" do
before do
stub_request(:get, /api.postcodes.io/)

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

@ -147,6 +147,34 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
end
end
describe "previous postcode known" do
context "when field_63 is 1" do
let(:attributes) do
{
bulk_upload:,
field_63: 1,
}
end
it "sets previous postcode known to yes" do
expect(parser.log.ppcodenk).to eq(0)
end
end
context "when field_63 is 2" do
let(:attributes) do
{
bulk_upload:,
field_63: 2,
}
end
it "sets previous postcode known to no" do
expect(parser.log.ppcodenk).to eq(1)
end
end
end
describe "validations" do
before do
stub_request(:get, /api.postcodes.io/)

Loading…
Cancel
Save