|
|
|
@ -458,6 +458,7 @@ class BulkUpload::Sales::Year2024::RowParser |
|
|
|
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 |
|
|
|
validate :validate_owning_org_owns_stock, on: :after_log |
|
|
|
validate :validate_owning_org_owns_stock, on: :after_log |
|
|
|
|
|
|
|
validate :validate_owning_org_affiliated, on: :after_log |
|
|
|
validate :validate_owning_org_permitted, on: :after_log |
|
|
|
validate :validate_owning_org_permitted, on: :after_log |
|
|
|
|
|
|
|
|
|
|
|
validate :validate_assigned_to_exists, on: :after_log |
|
|
|
validate :validate_assigned_to_exists, on: :after_log |
|
|
|
@ -1302,8 +1303,6 @@ private |
|
|
|
|
|
|
|
|
|
|
|
def validate_owning_org_permitted |
|
|
|
def validate_owning_org_permitted |
|
|
|
return unless owning_organisation |
|
|
|
return unless owning_organisation |
|
|
|
|
|
|
|
|
|
|
|
bulk_upload_organisation = bulk_upload.user.support? ? Organisation.find(bulk_upload.organisation_id) : bulk_upload.user.organisation |
|
|
|
|
|
|
|
return if bulk_upload_organisation.affiliated_stock_owners.include?(owning_organisation) |
|
|
|
return if bulk_upload_organisation.affiliated_stock_owners.include?(owning_organisation) |
|
|
|
|
|
|
|
|
|
|
|
block_log_creation! |
|
|
|
block_log_creation! |
|
|
|
@ -1313,6 +1312,18 @@ private |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_owning_org_affiliated |
|
|
|
|
|
|
|
return unless owning_organisation |
|
|
|
|
|
|
|
return unless bulk_upload.user.support? |
|
|
|
|
|
|
|
return if bulk_upload_organisation.affiliated_stock_owners.include?(owning_organisation) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
block_log_creation! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if errors[:field_1].blank? |
|
|
|
|
|
|
|
errors.add(:field_1, "This owning organisation is not affiliated with #{bulk_upload_organisation.name}", category: :setup) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def validate_assigned_to_exists |
|
|
|
def validate_assigned_to_exists |
|
|
|
return if field_3.blank? |
|
|
|
return if field_3.blank? |
|
|
|
|
|
|
|
|
|
|
|
@ -1500,4 +1511,8 @@ private |
|
|
|
def valid_nationality_options |
|
|
|
def valid_nationality_options |
|
|
|
%w[0] + GlobalConstants::COUNTRIES_ANSWER_OPTIONS.keys # 0 is "Prefers not to say" |
|
|
|
%w[0] + GlobalConstants::COUNTRIES_ANSWER_OPTIONS.keys # 0 is "Prefers not to say" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def bulk_upload_organisation |
|
|
|
|
|
|
|
Organisation.find(bulk_upload.organisation_id) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|