Browse Source

Correctly set hhregres and hhregresstill (#1660)

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

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

@ -702,7 +702,7 @@ private
owning_organisation_id: %i[field_1], owning_organisation_id: %i[field_1],
created_by: %i[field_2], created_by: %i[field_2],
hhregres: %i[field_73], hhregres: %i[field_73],
hhregresstill: %i[field_73], hhregresstill: %i[field_74],
armedforcesspouse: %i[field_75], armedforcesspouse: %i[field_75],
mortgagelender: %i[field_107 field_121 field_130], mortgagelender: %i[field_107 field_121 field_130],
@ -868,8 +868,8 @@ private
attributes["owning_organisation"] = owning_organisation attributes["owning_organisation"] = owning_organisation
attributes["created_by"] = created_by || bulk_upload.user attributes["created_by"] = created_by || bulk_upload.user
attributes["hhregres"] = hhregres attributes["hhregres"] = field_73
attributes["hhregresstill"] = hhregresstill attributes["hhregresstill"] = field_74
attributes["armedforcesspouse"] = field_75 attributes["armedforcesspouse"] = field_75
attributes["mortgagelender"] = mortgagelender attributes["mortgagelender"] = mortgagelender
@ -912,8 +912,6 @@ private
attributes["buy2living"] = field_71 attributes["buy2living"] = field_71
attributes["prevtenbuy2"] = prevtenbuy2 attributes["prevtenbuy2"] = prevtenbuy2
attributes["hhregresstill"] = field_74
attributes["prevshared"] = field_85 attributes["prevshared"] = field_85
attributes["staircasesale"] = field_90 attributes["staircasesale"] = field_90
@ -1088,21 +1086,6 @@ private
@created_by ||= User.find_by(email: field_2) @created_by ||= User.find_by(email: field_2)
end end
def hhregres
case field_73
when 3 then 3
when 4, 5, 6 then 1
when 7 then 7
when 8 then 8
end
end
def hhregresstill
return unless hhregres == 1
field_73
end
def previous_la_known def previous_la_known
field_66.present? ? 1 : 0 field_66.present? ? 1 : 0
end end

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

@ -964,6 +964,14 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
end end
end end
describe "#hhregres" do
let(:attributes) { setup_section_params.merge({ field_73: "1" }) }
it "is correctly set" do
expect(parser.log.hhregres).to be(1)
end
end
describe "#hhregresstill" do describe "#hhregresstill" do
let(:attributes) { setup_section_params.merge({ field_74: "4" }) } let(:attributes) { setup_section_params.merge({ field_74: "4" }) }

Loading…
Cancel
Save