|
|
@ -308,14 +308,14 @@ class BulkUpload::Lettings::Year2022::RowParser |
|
|
|
validate :validate_dont_know_disabled_needs_conjunction |
|
|
|
validate :validate_dont_know_disabled_needs_conjunction |
|
|
|
validate :validate_no_and_dont_know_disabled_needs_conjunction |
|
|
|
validate :validate_no_and_dont_know_disabled_needs_conjunction |
|
|
|
|
|
|
|
|
|
|
|
validate :validate_owning_org_permitted |
|
|
|
|
|
|
|
validate :validate_owning_org_owns_stock |
|
|
|
|
|
|
|
validate :validate_owning_org_exists |
|
|
|
|
|
|
|
validate :validate_owning_org_data_given |
|
|
|
validate :validate_owning_org_data_given |
|
|
|
|
|
|
|
validate :validate_owning_org_exists |
|
|
|
|
|
|
|
validate :validate_owning_org_owns_stock |
|
|
|
|
|
|
|
validate :validate_owning_org_permitted |
|
|
|
|
|
|
|
|
|
|
|
validate :validate_managing_org_related |
|
|
|
|
|
|
|
validate :validate_managing_org_exists |
|
|
|
|
|
|
|
validate :validate_managing_org_data_given |
|
|
|
validate :validate_managing_org_data_given |
|
|
|
|
|
|
|
validate :validate_managing_org_exists |
|
|
|
|
|
|
|
validate :validate_managing_org_related |
|
|
|
|
|
|
|
|
|
|
|
validate :validate_scheme_related |
|
|
|
validate :validate_scheme_related |
|
|
|
validate :validate_scheme_exists |
|
|
|
validate :validate_scheme_exists |
|
|
@ -436,19 +436,26 @@ private |
|
|
|
def validate_managing_org_related |
|
|
|
def validate_managing_org_related |
|
|
|
if owning_organisation && managing_organisation && !owning_organisation.can_be_managed_by?(organisation: managing_organisation) |
|
|
|
if owning_organisation && managing_organisation && !owning_organisation.can_be_managed_by?(organisation: managing_organisation) |
|
|
|
block_log_creation! |
|
|
|
block_log_creation! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if errors[:field_113].blank? |
|
|
|
errors.add(:field_113, "This managing organisation does not have a relationship with the owning organisation") |
|
|
|
errors.add(:field_113, "This managing organisation does not have a relationship with the owning organisation") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def validate_managing_org_exists |
|
|
|
def validate_managing_org_exists |
|
|
|
if managing_organisation.nil? |
|
|
|
if managing_organisation.nil? |
|
|
|
errors.delete(:field_113) |
|
|
|
block_log_creation! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if errors[:field_113].blank? |
|
|
|
errors.add(:field_113, "The managing organisation code is incorrect") |
|
|
|
errors.add(:field_113, "The managing organisation code is incorrect") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def validate_managing_org_data_given |
|
|
|
def validate_managing_org_data_given |
|
|
|
if field_113.blank? |
|
|
|
if field_113.blank? |
|
|
|
|
|
|
|
block_log_creation! |
|
|
|
errors.add(:field_113, "The managing organisation code is incorrect", category: :setup) |
|
|
|
errors.add(:field_113, "The managing organisation code is incorrect", category: :setup) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -456,31 +463,42 @@ private |
|
|
|
def validate_owning_org_owns_stock |
|
|
|
def validate_owning_org_owns_stock |
|
|
|
if owning_organisation && !owning_organisation.holds_own_stock? |
|
|
|
if owning_organisation && !owning_organisation.holds_own_stock? |
|
|
|
block_log_creation! |
|
|
|
block_log_creation! |
|
|
|
errors.delete(:field_111) |
|
|
|
|
|
|
|
|
|
|
|
if errors[:field_111].blank? |
|
|
|
errors.add(:field_111, "The owning organisation code provided is for an organisation that does not own stock") |
|
|
|
errors.add(:field_111, "The owning organisation code provided is for an organisation that does not own stock") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def validate_owning_org_exists |
|
|
|
def validate_owning_org_exists |
|
|
|
if owning_organisation.nil? |
|
|
|
if owning_organisation.nil? |
|
|
|
errors.delete(:field_111) |
|
|
|
block_log_creation! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if errors[:field_111].blank? |
|
|
|
errors.add(:field_111, "The owning organisation code is incorrect") |
|
|
|
errors.add(:field_111, "The owning organisation code is incorrect") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def validate_owning_org_data_given |
|
|
|
def validate_owning_org_data_given |
|
|
|
if field_111.blank? |
|
|
|
if field_111.blank? |
|
|
|
|
|
|
|
block_log_creation! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if errors[:field_111].blank? |
|
|
|
errors.add(:field_111, "The owning organisation code is incorrect", category: :setup) |
|
|
|
errors.add(:field_111, "The owning organisation code is incorrect", category: :setup) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def validate_owning_org_permitted |
|
|
|
def validate_owning_org_permitted |
|
|
|
if owning_organisation && !bulk_upload.user.organisation.affiliated_stock_owners.include?(owning_organisation) |
|
|
|
if owning_organisation && !bulk_upload.user.organisation.affiliated_stock_owners.include?(owning_organisation) |
|
|
|
block_log_creation! |
|
|
|
block_log_creation! |
|
|
|
errors.delete(:field_111) |
|
|
|
|
|
|
|
|
|
|
|
if errors[:field_111].blank? |
|
|
|
errors.add(:field_111, "You do not have permission to add logs for this owning organisation") |
|
|
|
errors.add(:field_111, "You do not have permission to add logs for this owning organisation") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def validate_no_and_dont_know_disabled_needs_conjunction |
|
|
|
def validate_no_and_dont_know_disabled_needs_conjunction |
|
|
|
if field_59 == 1 && field_60 == 1 |
|
|
|
if field_59 == 1 && field_60 == 1 |
|
|
|