Browse Source

add #voiddate to bulk upload

remotes/origin/bulk-upload-errors-integration
Phil Lee 3 years ago
parent
commit
69d7dfd8df
  1. 9
      app/services/bulk_upload/lettings/row_parser.rb
  2. 8
      spec/services/bulk_upload/lettings/row_parser_spec.rb

9
app/services/bulk_upload/lettings/row_parser.rb

@ -353,6 +353,8 @@ private
majorrepairs: %i[field_92 field_93 field_94], majorrepairs: %i[field_92 field_93 field_94],
mrcdate: %i[field_92 field_93 field_94], mrcdate: %i[field_92 field_93 field_94],
voiddate: %i[field_89 field_90 field_91],
} }
end end
@ -558,11 +560,18 @@ private
attributes["propcode"] = field_100 attributes["propcode"] = field_100
attributes["majorrepairs"] = majorrepairs attributes["majorrepairs"] = majorrepairs
attributes["mrcdate"] = mrcdate attributes["mrcdate"] = mrcdate
attributes["voiddate"] = voiddate
attributes attributes
end end
def voiddate
Date.new(field_91 + 2000, field_90, field_89) if field_91.present? && field_90.present? && field_89.present?
end
def majorrepairs def majorrepairs
mrcdate.present? ? 1 : 0 mrcdate.present? ? 1 : 0
end end

8
spec/services/bulk_upload/lettings/row_parser_spec.rb

@ -663,5 +663,13 @@ RSpec.describe BulkUpload::Lettings::RowParser do
end end
end end
end end
describe "#voiddate" do
let(:attributes) { { bulk_upload:, field_89: "13", field_90: "12", field_91: "22" } }
it "sets value given" do
expect(parser.log.voiddate).to eq(Date.new(2022, 12, 13))
end
end
end end
end end

Loading…
Cancel
Save