|
|
@ -324,8 +324,8 @@ class BulkUpload::Lettings::Year2024::RowParser |
|
|
|
category: :setup, |
|
|
|
category: :setup, |
|
|
|
}, |
|
|
|
}, |
|
|
|
format: { |
|
|
|
format: { |
|
|
|
with: /\A\d{2}\z/, |
|
|
|
with: /\A(\d{2}|\d{4})\z/, |
|
|
|
message: I18n.t("validations.setup.startdate.year_not_two_digits"), |
|
|
|
message: I18n.t("validations.setup.startdate.year_not_two_or_four_digits"), |
|
|
|
category: :setup, |
|
|
|
category: :setup, |
|
|
|
unless: -> { field_10.blank? }, |
|
|
|
unless: -> { field_10.blank? }, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -686,14 +686,6 @@ private |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def start_date |
|
|
|
|
|
|
|
return if field_8.blank? || field_9.blank? || field_10.blank? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date.parse("20#{field_10.to_s.rjust(2, '0')}-#{field_9}-#{field_8}") |
|
|
|
|
|
|
|
rescue StandardError |
|
|
|
|
|
|
|
nil |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_no_and_dont_know_disabled_needs_conjunction |
|
|
|
def validate_no_and_dont_know_disabled_needs_conjunction |
|
|
|
if field_83 == 1 && field_84 == 1 |
|
|
|
if field_83 == 1 && field_84 == 1 |
|
|
|
errors.add(:field_83, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction")) |
|
|
|
errors.add(:field_83, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction")) |
|
|
@ -790,9 +782,9 @@ private |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def validate_relevant_collection_window |
|
|
|
def validate_relevant_collection_window |
|
|
|
return if start_date.blank? || bulk_upload.form.blank? |
|
|
|
return if startdate.blank? || bulk_upload.form.blank? |
|
|
|
|
|
|
|
|
|
|
|
unless bulk_upload.form.valid_start_date_for_form?(start_date) |
|
|
|
unless bulk_upload.form.valid_start_date_for_form?(startdate) |
|
|
|
errors.add(:field_8, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) |
|
|
|
errors.add(:field_8, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) |
|
|
|
errors.add(:field_9, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) |
|
|
|
errors.add(:field_9, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) |
|
|
|
errors.add(:field_10, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) |
|
|
|
errors.add(:field_10, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) |
|
|
@ -1394,7 +1386,8 @@ private |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def startdate |
|
|
|
def startdate |
|
|
|
Date.new(field_10 + 2000, field_9, field_8) if field_10.present? && field_9.present? && field_8.present? |
|
|
|
year = field_10.to_s.strip.length.between?(1, 2) ? field_10 + 2000 : field_10 |
|
|
|
|
|
|
|
Date.new(year, field_9, field_8) if field_10.present? && field_9.present? && field_8.present? |
|
|
|
rescue Date::Error |
|
|
|
rescue Date::Error |
|
|
|
Date.new |
|
|
|
Date.new |
|
|
|
end |
|
|
|
end |
|
|
@ -1599,13 +1592,15 @@ private |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def mrcdate |
|
|
|
def mrcdate |
|
|
|
Date.new(field_35 + 2000, field_34, field_33) if field_35.present? && field_34.present? && field_33.present? |
|
|
|
year = field_35.to_s.strip.length.between?(1, 2) ? field_35 + 2000 : field_35 |
|
|
|
|
|
|
|
Date.new(year, field_34, field_33) if field_35.present? && field_34.present? && field_33.present? |
|
|
|
rescue Date::Error |
|
|
|
rescue Date::Error |
|
|
|
Date.new |
|
|
|
Date.new |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def voiddate |
|
|
|
def voiddate |
|
|
|
Date.new(field_32 + 2000, field_31, field_30) if field_32.present? && field_31.present? && field_30.present? |
|
|
|
year = field_32.to_s.strip.length.between?(1, 2) ? field_32 + 2000 : field_32 |
|
|
|
|
|
|
|
Date.new(year, field_31, field_30) if field_32.present? && field_31.present? && field_30.present? |
|
|
|
rescue Date::Error |
|
|
|
rescue Date::Error |
|
|
|
Date.new |
|
|
|
Date.new |
|
|
|
end |
|
|
|
end |
|
|
|