|
|
|
@ -407,9 +407,7 @@ class BulkUpload::Sales::Year2023::RowParser |
|
|
|
validate :validate_relevant_collection_window, on: :after_log |
|
|
|
validate :validate_relevant_collection_window, on: :after_log |
|
|
|
|
|
|
|
|
|
|
|
validate :validate_uprn_exists_if_any_key_address_fields_are_blank, on: :after_log |
|
|
|
validate :validate_uprn_exists_if_any_key_address_fields_are_blank, on: :after_log |
|
|
|
validate :validate_address_line_1, on: :after_log |
|
|
|
validate :validate_address_fields, on: :after_log |
|
|
|
validate :validate_town_or_city, on: :after_log |
|
|
|
|
|
|
|
validate :validate_postcode, on: :after_log |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def self.question_for_field(field) |
|
|
|
def self.question_for_field(field) |
|
|
|
QUESTIONS[field] |
|
|
|
QUESTIONS[field] |
|
|
|
@ -500,27 +498,25 @@ private |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def validate_address_line_1 |
|
|
|
def validate_address_fields |
|
|
|
if field_19.blank? && field_20.blank? |
|
|
|
if field_19.blank? || log.errors.attribute_names.include?(:uprn) |
|
|
|
|
|
|
|
if field_20.blank? |
|
|
|
errors.add(:field_20, I18n.t("validations.not_answered", question: "address line 1")) |
|
|
|
errors.add(:field_20, I18n.t("validations.not_answered", question: "address line 1")) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_town_or_city |
|
|
|
if field_22.blank? |
|
|
|
if field_19.blank? && field_22.blank? |
|
|
|
|
|
|
|
errors.add(:field_22, I18n.t("validations.not_answered", question: "town or city")) |
|
|
|
errors.add(:field_22, I18n.t("validations.not_answered", question: "town or city")) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_postcode |
|
|
|
if field_24.blank? |
|
|
|
if field_19.blank? && field_24.blank? |
|
|
|
|
|
|
|
errors.add(:field_24, I18n.t("validations.not_answered", question: "part 1 of the property's postcode")) |
|
|
|
errors.add(:field_24, I18n.t("validations.not_answered", question: "part 1 of the property's postcode")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if field_19.blank? && field_25.blank? |
|
|
|
if field_25.blank? |
|
|
|
errors.add(:field_25, I18n.t("validations.not_answered", question: "part 2 of the property's postcode")) |
|
|
|
errors.add(:field_25, I18n.t("validations.not_answered", question: "part 2 of the property's postcode")) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def shared_ownership? |
|
|
|
def shared_ownership? |
|
|
|
field_7 == 1 |
|
|
|
field_7 == 1 |
|
|
|
|