diff --git a/app/controllers/organisation_relationships_controller.rb b/app/controllers/organisation_relationships_controller.rb index e7a6a7856..95678e852 100644 --- a/app/controllers/organisation_relationships_controller.rb +++ b/app/controllers/organisation_relationships_controller.rb @@ -51,6 +51,11 @@ class OrganisationRelationshipsController < ApplicationController @organisations = Organisation.where.not(id: child_organisation.id).pluck(:id, :name) render "organisation_relationships/add_housing_provider" return + elsif !parent_organisation.holds_own_stock + @organisation.errors.add :related_organisation_id, I18n.t("validations.scheme.owning_organisation.does_not_own_stock") + @organisations = Organisation.where.not(id: child_organisation.id).pluck(:id, :name) + render "organisation_relationships/add_housing_provider" + return end end create!(child_organisation:, parent_organisation:) diff --git a/db/schema.rb b/db/schema.rb index 4f7d267ce..5fb6b5088 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -398,9 +398,9 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_06_081127) do t.integer "inc1mort" t.integer "income2" t.integer "income2nk" - t.integer "prevown" t.integer "savingsnk" t.integer "savings" + t.integer "prevown" t.string "sex3" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"