Browse Source

add postcode validation

pull/1148/head
Phil Lee 3 years ago
parent
commit
4cd70f5e68
  1. 14
      app/services/bulk_upload/lettings/row_parser.rb
  2. 2
      spec/services/bulk_upload/lettings/row_parser_spec.rb

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

@ -178,6 +178,18 @@ class BulkUpload::Lettings::RowParser
private
def postcode_full
"#{field_108} #{field_109}" if field_108 && field_109
end
def postcode_known
if postcode_full.present?
1
elsif field_107.present?
0
end
end
def questions
log.form.subsections.flat_map { |ss| ss.applicable_questions(log) }
end
@ -210,6 +222,8 @@ private
[
{ name: :field_1, attribute: :lettype },
{ name: :field_7, attribute: :tenancycode, question_id: "tenancycode" },
{ name: :field_108, attribute: :postcode_known, question_id: "postcode_known", value_method: :postcode_known },
{ name: :field_108, attribute: :postcode_full, question_id: "postcode_full", value_method: :postcode_full },
{ name: :field_111, attribute: :owning_organisation_id, question_id: "owning_organisation_id", value_method: :owning_organisation_id },
{ name: :field_113, attribute: :managing_organisation_id, question_id: "managing_organisation_id", value_method: :managing_organisation_id },
{ name: :field_134, attribute: :renewal },

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

@ -40,6 +40,8 @@ RSpec.describe BulkUpload::Lettings::RowParser do
field_96: "1",
field_97: "1",
field_98: "2023",
field_108: "EC1N",
field_109: "2TD",
field_111: owning_org.old_visible_id,
field_113: managing_org.old_visible_id,
field_130: "1",

Loading…
Cancel
Save