Browse Source

feat: add error message if org doesn't own stock

CLDC-1730-stock-owning-validation2
natdeanlewissoftwire 2 years ago
parent
commit
5aff30e8d9
  1. 5
      app/controllers/organisation_relationships_controller.rb
  2. 2
      db/schema.rb

5
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:)

2
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"

Loading…
Cancel
Save