Browse Source

Remove propcode from dedulication checks

pull/1763/head
Kat 3 years ago
parent
commit
5ae990d973
  1. 4
      app/models/lettings_log.rb
  2. 3
      app/services/bulk_upload/lettings/year2022/row_parser.rb
  3. 3
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  4. 12
      spec/models/lettings_log_spec.rb
  5. 3
      spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb
  6. 2
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

4
app/models/lettings_log.rb

@ -56,7 +56,7 @@ class LettingsLog < Log
scope :duplicate_logs, lambda { |log| scope :duplicate_logs, lambda { |log|
visible.where(log.slice(*DUPLICATE_LOG_ATTRIBUTES)) visible.where(log.slice(*DUPLICATE_LOG_ATTRIBUTES))
.where.not(id: log.id) .where.not(id: log.id)
.where.not("startdate IS NULL OR age1 IS NULL OR sex1 IS NULL OR ecstat1 IS NULL OR tcharge IS NULL OR postcode_full IS NULL OR propcode IS NULL OR needstype IS NULL") .where.not("startdate IS NULL OR age1 IS NULL OR sex1 IS NULL OR ecstat1 IS NULL OR tcharge IS NULL OR postcode_full IS NULL OR needstype IS NULL")
.where("location_id = ? OR needstype = 1", log.location_id) .where("location_id = ? OR needstype = 1", log.location_id)
} }
@ -67,7 +67,7 @@ class LettingsLog < Log
NUM_OF_WEEKS_FROM_PERIOD = { 2 => 26, 3 => 13, 4 => 12, 5 => 50, 6 => 49, 7 => 48, 8 => 47, 9 => 46, 1 => 52, 10 => 53 }.freeze NUM_OF_WEEKS_FROM_PERIOD = { 2 => 26, 3 => 13, 4 => 12, 5 => 50, 6 => 49, 7 => 48, 8 => 47, 9 => 46, 1 => 52, 10 => 53 }.freeze
SUFFIX_FROM_PERIOD = { 2 => "every 2 weeks", 3 => "every 4 weeks", 4 => "every month" }.freeze SUFFIX_FROM_PERIOD = { 2 => "every 2 weeks", 3 => "every 4 weeks", 4 => "every month" }.freeze
RETIREMENT_AGES = { "M" => 67, "F" => 60, "X" => 67 }.freeze RETIREMENT_AGES = { "M" => 67, "F" => 60, "X" => 67 }.freeze
DUPLICATE_LOG_ATTRIBUTES = %w[tenancycode propcode startdate age1 sex1 ecstat1 tcharge postcode_full].freeze DUPLICATE_LOG_ATTRIBUTES = %w[tenancycode startdate age1 sex1 ecstat1 tcharge postcode_full].freeze
def form def form
FormHandler.instance.get_form(form_name) || FormHandler.instance.current_lettings_form FormHandler.instance.get_form(form_name) || FormHandler.instance.current_lettings_form

3
app/services/bulk_upload/lettings/year2022/row_parser.rb

@ -450,7 +450,6 @@ class BulkUpload::Lettings::Year2022::RowParser
"field_96", # startdate "field_96", # startdate
"field_97", # startdate "field_97", # startdate
"field_98", # startdate "field_98", # startdate
"field_100", # propcode
bulk_upload.needstype != 2 ? "field_108" : nil, # postcode bulk_upload.needstype != 2 ? "field_108" : nil, # postcode
bulk_upload.needstype != 2 ? "field_109" : nil, # postcode bulk_upload.needstype != 2 ? "field_109" : nil, # postcode
"field_111", # owning org "field_111", # owning org
@ -525,7 +524,6 @@ private
"ecstat1", "ecstat1",
"owning_organisation", "owning_organisation",
"tcharge", "tcharge",
"propcode",
bulk_upload.needstype != 2 ? "postcode_full" : nil, bulk_upload.needstype != 2 ? "postcode_full" : nil,
bulk_upload.needstype != 1 ? "location" : nil, bulk_upload.needstype != 1 ? "location" : nil,
].compact ].compact
@ -862,7 +860,6 @@ private
errors.add(:field_96, error_message) # startdate errors.add(:field_96, error_message) # startdate
errors.add(:field_97, error_message) # startdate errors.add(:field_97, error_message) # startdate
errors.add(:field_98, error_message) # startdate errors.add(:field_98, error_message) # startdate
errors.add(:field_100, error_message) # propcode
errors.add(:field_108, error_message) if bulk_upload.needstype != 2 # postcode_full errors.add(:field_108, error_message) if bulk_upload.needstype != 2 # postcode_full
errors.add(:field_109, error_message) if bulk_upload.needstype != 2 # postcode_full errors.add(:field_109, error_message) if bulk_upload.needstype != 2 # postcode_full
errors.add(:field_111, error_message) # owning_organisation errors.add(:field_111, error_message) # owning_organisation

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

@ -464,7 +464,6 @@ class BulkUpload::Lettings::Year2023::RowParser
"field_8", # startdate "field_8", # startdate
"field_9", # startdate "field_9", # startdate
"field_13", # tenancycode "field_13", # tenancycode
"field_14", # propcode
field_4 != 1 ? "field_17" : nil, # location field_4 != 1 ? "field_17" : nil, # location
field_4 != 2 ? "field_23" : nil, # postcode field_4 != 2 ? "field_23" : nil, # postcode
field_4 != 2 ? "field_24" : nil, # postcode field_4 != 2 ? "field_24" : nil, # postcode
@ -561,7 +560,6 @@ private
"ecstat1", "ecstat1",
"owning_organisation", "owning_organisation",
"tcharge", "tcharge",
"propcode",
field_4 != 2 ? "postcode_full" : nil, field_4 != 2 ? "postcode_full" : nil,
field_4 != 1 ? "location" : nil, field_4 != 1 ? "location" : nil,
"tenancycode", "tenancycode",
@ -856,7 +854,6 @@ private
errors.add(:field_8, error_message) # startdate errors.add(:field_8, error_message) # startdate
errors.add(:field_9, error_message) # startdate errors.add(:field_9, error_message) # startdate
errors.add(:field_13, error_message) # tenancycode errors.add(:field_13, error_message) # tenancycode
errors.add(:field_14, error_message) # propcode
errors.add(:field_17, error_message) if field_4 != 1 # location errors.add(:field_17, error_message) if field_4 != 1 # location
errors.add(:field_23, error_message) if field_4 != 2 # postcode_full errors.add(:field_23, error_message) if field_4 != 2 # postcode_full
errors.add(:field_24, error_message) if field_4 != 2 # postcode_full errors.add(:field_24, error_message) if field_4 != 2 # postcode_full

12
spec/models/lettings_log_spec.rb

@ -2862,14 +2862,6 @@ RSpec.describe LettingsLog do
end end
end end
context "when there is a log with a different propcode" do
let!(:different_propcode) { create(:lettings_log, :duplicate, propcode: "different") }
it "does not return a log with a different propcode as a duplicate" do
expect(described_class.duplicate_logs(log)).not_to include(different_propcode)
end
end
context "when there is a log with a different tenancycode" do context "when there is a log with a different tenancycode" do
let!(:different_tenancycode) { create(:lettings_log, :duplicate, tenancycode: "different") } let!(:different_tenancycode) { create(:lettings_log, :duplicate, tenancycode: "different") }
@ -2887,10 +2879,10 @@ RSpec.describe LettingsLog do
end end
context "when there is a log with nil values for duplicate check fields" do context "when there is a log with nil values for duplicate check fields" do
let!(:duplicate_check_fields_not_given) { create(:lettings_log, :duplicate, age1: nil, sex1: nil, ecstat1: nil, propcode: nil, postcode_known: 2, postcode_full: nil) } let!(:duplicate_check_fields_not_given) { create(:lettings_log, :duplicate, age1: nil, sex1: nil, ecstat1: nil, postcode_known: 2, postcode_full: nil) }
it "does not return a log with nil values as a duplicate" do it "does not return a log with nil values as a duplicate" do
log.update!(age1: nil, sex1: nil, ecstat1: nil, propcode: nil, postcode_known: 2, postcode_full: nil) log.update!(age1: nil, sex1: nil, ecstat1: nil, postcode_known: 2, postcode_full: nil)
expect(described_class.duplicate_logs(log)).not_to include(duplicate_check_fields_not_given) expect(described_class.duplicate_logs(log)).not_to include(duplicate_check_fields_not_given)
end end
end end

3
spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb

@ -258,7 +258,6 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
field_96: [error_message], # startdate field_96: [error_message], # startdate
field_97: [error_message], # startdate field_97: [error_message], # startdate
field_98: [error_message], # startdate field_98: [error_message], # startdate
field_100: [error_message], # propcode
field_108: [error_message], # postcode_full field_108: [error_message], # postcode_full
field_109: [error_message], # postcode_full field_109: [error_message], # postcode_full
field_111: [error_message], # owning_organisation field_111: [error_message], # owning_organisation
@ -295,7 +294,6 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
:field_96, # startdate :field_96, # startdate
:field_97, # startdate :field_97, # startdate
:field_98, # startdate :field_98, # startdate
:field_100, # propcode
:field_111, # owning_organisation :field_111, # owning_organisation
].each do |field| ].each do |field|
expect(parser.errors[field]).to include("This is a duplicate log") expect(parser.errors[field]).to include("This is a duplicate log")
@ -329,7 +327,6 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
:field_96, # startdate :field_96, # startdate
:field_97, # startdate :field_97, # startdate
:field_98, # startdate :field_98, # startdate
:field_100, # propcode
:field_108, # postcode_full :field_108, # postcode_full
:field_109, # postcode_full :field_109, # postcode_full
:field_111, # owning_organisation :field_111, # owning_organisation

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

@ -328,7 +328,6 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
:field_8, # startdate :field_8, # startdate
:field_9, # startdate :field_9, # startdate
:field_13, # tenancycode :field_13, # tenancycode
:field_14, # propcode
:field_17, # location :field_17, # location
:field_46, # age1 :field_46, # age1
:field_47, # sex1 :field_47, # sex1
@ -363,7 +362,6 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
:field_7, # startdate :field_7, # startdate
:field_8, # startdate :field_8, # startdate
:field_9, # startdate :field_9, # startdate
:field_14, # propcode
:field_17, # location :field_17, # location
:field_23, # postcode_full :field_23, # postcode_full
:field_24, # postcode_full :field_24, # postcode_full

Loading…
Cancel
Save