|
|
|
|
@ -462,6 +462,7 @@ class BulkUpload::Sales::Year2024::RowParser
|
|
|
|
|
|
|
|
|
|
validate :validate_assigned_to_exists, on: :after_log |
|
|
|
|
validate :validate_assigned_to_related, on: :after_log |
|
|
|
|
validate :validate_assigned_to_when_support, on: :after_log |
|
|
|
|
validate :validate_managing_org_related, on: :after_log |
|
|
|
|
validate :validate_relevant_collection_window, on: :after_log |
|
|
|
|
validate :validate_incomplete_soft_validations, on: :after_log |
|
|
|
|
@ -1302,12 +1303,13 @@ private
|
|
|
|
|
def validate_owning_org_permitted |
|
|
|
|
return unless owning_organisation |
|
|
|
|
|
|
|
|
|
if (bulk_upload.user.support? && !bulk_upload.organisation.affiliated_stock_owners.include?(bulk_upload.organisation)) || (!bulk_upload.user.support? && !bulk_upload.user.organisation.affiliated_stock_owners.include?(owning_organisation)) |
|
|
|
|
block_log_creation! |
|
|
|
|
return if (bulk_upload.user.support? && bulk_upload.organisation.affiliated_stock_owners.include?(bulk_upload.organisation)) || |
|
|
|
|
(!bulk_upload.user.support? && bulk_upload.user.organisation.affiliated_stock_owners.include?(owning_organisation)) |
|
|
|
|
|
|
|
|
|
if errors[:field_1].blank? |
|
|
|
|
errors.add(:field_1, "You do not have permission to add logs for this owning organisation", category: :setup) |
|
|
|
|
end |
|
|
|
|
block_log_creation! |
|
|
|
|
|
|
|
|
|
if errors[:field_1].blank? |
|
|
|
|
errors.add(:field_1, "You do not have permission to add logs for this owning organisation", category: :setup) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@ -1319,6 +1321,13 @@ private
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def validate_assigned_to_when_support |
|
|
|
|
if field_3.blank? && bulk_upload.user.support? |
|
|
|
|
block_log_creation! |
|
|
|
|
errors.add(:field_3, :setup, message: "User was not provided") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def validate_assigned_to_related |
|
|
|
|
return unless assigned_to |
|
|
|
|
return if assigned_to.organisation == owning_organisation || assigned_to.organisation == managing_organisation |
|
|
|
|
|