|
|
|
|
@ -21,7 +21,7 @@ class Scheme < ApplicationRecord
|
|
|
|
|
scope :order_by_completion, -> { order("confirmed ASC NULLS FIRST") } |
|
|
|
|
scope :order_by_service_name, -> { order(service_name: :asc) } |
|
|
|
|
|
|
|
|
|
validate :validate_confirmed |
|
|
|
|
validate :validate_confirmed, :validate_owning_organisation |
|
|
|
|
|
|
|
|
|
auto_strip_attributes :service_name |
|
|
|
|
|
|
|
|
|
@ -212,6 +212,13 @@ class Scheme < ApplicationRecord
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def validate_owning_organisation |
|
|
|
|
if !owning_organisation.holds_own_stock? |
|
|
|
|
errors.add(:owning_organisation_id, :does_not_own_stock, message: I18n.t("validations.scheme.owning_organisation.does_not_own_stock")) |
|
|
|
|
owning_organisation = nil |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def available_from |
|
|
|
|
FormHandler.instance.collection_start_date(created_at) |
|
|
|
|
end |
|
|
|
|
|