|
|
|
@ -307,6 +307,7 @@ class BulkUpload::Lettings::Year2022::RowParser |
|
|
|
validate :validate_no_disabled_needs_conjunction, on: :after_log |
|
|
|
validate :validate_no_disabled_needs_conjunction, on: :after_log |
|
|
|
validate :validate_dont_know_disabled_needs_conjunction, on: :after_log |
|
|
|
validate :validate_dont_know_disabled_needs_conjunction, on: :after_log |
|
|
|
validate :validate_no_and_dont_know_disabled_needs_conjunction, on: :after_log |
|
|
|
validate :validate_no_and_dont_know_disabled_needs_conjunction, on: :after_log |
|
|
|
|
|
|
|
validate :validate_if_log_already_exists, on: :after_log |
|
|
|
|
|
|
|
|
|
|
|
validate :validate_owning_org_data_given, on: :after_log |
|
|
|
validate :validate_owning_org_data_given, on: :after_log |
|
|
|
validate :validate_owning_org_exists, on: :after_log |
|
|
|
validate :validate_owning_org_exists, on: :after_log |
|
|
|
@ -392,6 +393,10 @@ class BulkUpload::Lettings::Year2022::RowParser |
|
|
|
field_100 |
|
|
|
field_100 |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def log_already_exists? |
|
|
|
|
|
|
|
LettingsLog.exists?(duplicity_check_fields.index_with { |field| log.public_send(field) }) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def validate_declaration_acceptance |
|
|
|
def validate_declaration_acceptance |
|
|
|
@ -436,6 +441,18 @@ private |
|
|
|
@created_by ||= User.find_by(email: field_112) |
|
|
|
@created_by ||= User.find_by(email: field_112) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def duplicity_check_fields |
|
|
|
|
|
|
|
%w[ |
|
|
|
|
|
|
|
startdate |
|
|
|
|
|
|
|
age1 |
|
|
|
|
|
|
|
sex1 |
|
|
|
|
|
|
|
ecstat1 |
|
|
|
|
|
|
|
owning_organisation |
|
|
|
|
|
|
|
tcharge |
|
|
|
|
|
|
|
propcode |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def validate_location_related |
|
|
|
def validate_location_related |
|
|
|
return if scheme.blank? || location.blank? |
|
|
|
return if scheme.blank? || location.blank? |
|
|
|
|
|
|
|
|
|
|
|
@ -694,6 +711,25 @@ private |
|
|
|
log.form.setup_sections[0].subsections[0].questions.include?(question) |
|
|
|
log.form.setup_sections[0].subsections[0].questions.include?(question) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_if_log_already_exists |
|
|
|
|
|
|
|
if log_already_exists? |
|
|
|
|
|
|
|
error_message = "This is a duplicate log" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
errors.add(:field_12, error_message) # age1 |
|
|
|
|
|
|
|
errors.add(:field_20, error_message) # sex1 |
|
|
|
|
|
|
|
errors.add(:field_35, error_message) # ecstat1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
errors.add(:field_84, error_message) # tcharge |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
errors.add(:field_96, error_message) # startdate |
|
|
|
|
|
|
|
errors.add(:field_97, error_message) # startdate |
|
|
|
|
|
|
|
errors.add(:field_98, error_message) # startdate |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
errors.add(:field_100, error_message) # propcode |
|
|
|
|
|
|
|
errors.add(:field_111, error_message) # owning_organisation |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def field_mapping_for_errors |
|
|
|
def field_mapping_for_errors |
|
|
|
{ |
|
|
|
{ |
|
|
|
lettype: [:field_1], |
|
|
|
lettype: [:field_1], |
|
|
|
@ -893,18 +929,10 @@ private |
|
|
|
Organisation.find_by_id_on_multiple_fields(field_111) |
|
|
|
Organisation.find_by_id_on_multiple_fields(field_111) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def owning_organisation_id |
|
|
|
|
|
|
|
owning_organisation&.id |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def managing_organisation |
|
|
|
def managing_organisation |
|
|
|
Organisation.find_by_id_on_multiple_fields(field_113) |
|
|
|
Organisation.find_by_id_on_multiple_fields(field_113) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def managing_organisation_id |
|
|
|
|
|
|
|
managing_organisation&.id |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def attributes_for_log |
|
|
|
def attributes_for_log |
|
|
|
attributes = {} |
|
|
|
attributes = {} |
|
|
|
|
|
|
|
|
|
|
|
@ -913,8 +941,8 @@ private |
|
|
|
attributes["la"] = field_107 |
|
|
|
attributes["la"] = field_107 |
|
|
|
attributes["postcode_known"] = postcode_known |
|
|
|
attributes["postcode_known"] = postcode_known |
|
|
|
attributes["postcode_full"] = postcode_full |
|
|
|
attributes["postcode_full"] = postcode_full |
|
|
|
attributes["owning_organisation_id"] = owning_organisation_id |
|
|
|
attributes["owning_organisation"] = owning_organisation |
|
|
|
attributes["managing_organisation_id"] = managing_organisation_id |
|
|
|
attributes["managing_organisation"] = managing_organisation |
|
|
|
attributes["renewal"] = renewal |
|
|
|
attributes["renewal"] = renewal |
|
|
|
attributes["scheme"] = scheme |
|
|
|
attributes["scheme"] = scheme |
|
|
|
attributes["location"] = location |
|
|
|
attributes["location"] = location |
|
|
|
|