Browse Source

feat: start adding scheme validation for when owning org doesn't hold stock

pull/1027/head
Sam Seed 4 years ago
parent
commit
191f727e4f
  1. 9
      app/models/scheme.rb
  2. 2
      config/locales/en.yml

9
app/models/scheme.rb

@ -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

2
config/locales/en.yml

@ -341,6 +341,8 @@ en:
before_deactivation: "This scheme was deactivated on %{date}. The reactivation date must be on or after deactivation date"
deactivation:
during_deactivated_period: "The scheme is already deactivated during this date, please enter a different date"
owning_organisation:
does_not_own_stock: "Enter an organisation that owns housing stock"

Loading…
Cancel
Save