Browse Source

added stock owning org

pull/671/head
JG 3 years ago
parent
commit
65f659535e
  1. 3
      app/models/scheme.rb
  2. 2
      db/migrate/20220616130451_add_reference_to_case_log.rb
  3. 5
      db/schema.rb

3
app/models/scheme.rb

@ -1,5 +1,6 @@
class Scheme < ApplicationRecord class Scheme < ApplicationRecord
belongs_to :organisation belongs_to :organisation
belongs_to :stock_owning_organisation, optional: true, class_name: "Organisation", foreign_key: "stock_owning_organisation_id"
has_many :locations has_many :locations
has_many :case_logs has_many :case_logs
@ -94,6 +95,7 @@ class Scheme < ApplicationRecord
{ name: "Service code", value: id_to_display }, { name: "Service code", value: id_to_display },
{ name: "Name", value: service_name }, { name: "Name", value: service_name },
{ name: "Confidential information", value: sensitive }, { name: "Confidential information", value: sensitive },
{ name: "Housing stock owned by", value: stock_owning_organisation&.name },
{ name: "Managed by", value: organisation.name }, { name: "Managed by", value: organisation.name },
{ name: "Type of scheme", value: scheme_type }, { name: "Type of scheme", value: scheme_type },
{ name: "Registered under Care Standards Act 2000", value: registered_under_care_act }, { name: "Registered under Care Standards Act 2000", value: registered_under_care_act },
@ -131,6 +133,7 @@ class Scheme < ApplicationRecord
{ name: "Service code", value: id_to_display }, { name: "Service code", value: id_to_display },
{ name: "Name", value: service_name }, { name: "Name", value: service_name },
{ name: "Confidential information", value: sensitive }, { name: "Confidential information", value: sensitive },
{ name: "Housing stock owned by", value: stock_owning_organisation&.name },
{ name: "Managed by", value: organisation.name }, { name: "Managed by", value: organisation.name },
{ name: "Type of scheme", value: scheme_type }, { name: "Type of scheme", value: scheme_type },
{ name: "Registered under Care Standards Act 2000", value: registered_under_care_act }, { name: "Registered under Care Standards Act 2000", value: registered_under_care_act },

2
db/migrate/20220616130451_add_reference_to_case_log.rb

@ -1,5 +1,5 @@
class AddReferenceToCaseLog < ActiveRecord::Migration[7.0] class AddReferenceToCaseLog < ActiveRecord::Migration[7.0]
def change def change
add_reference :case_logs, :scheme, foreign_key: true add_reference :case_logs, :scheme, foreign_key: true, null: true
end end
end end

5
db/schema.rb

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2022_06_29_100324) do ActiveRecord::Schema[7.0].define(version: 2022_06_29_105452) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -311,7 +311,9 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_29_100324) do
t.string "intended_stay" t.string "intended_stay"
t.datetime "end_date" t.datetime "end_date"
t.string "has_other_client_group" t.string "has_other_client_group"
t.bigint "stock_owning_organisation_id"
t.index ["organisation_id"], name: "index_schemes_on_organisation_id" t.index ["organisation_id"], name: "index_schemes_on_organisation_id"
t.index ["stock_owning_organisation_id"], name: "index_schemes_on_stock_owning_organisation_id"
end end
create_table "users", force: :cascade do |t| create_table "users", force: :cascade do |t|
@ -370,4 +372,5 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_29_100324) do
add_foreign_key "case_logs", "schemes" add_foreign_key "case_logs", "schemes"
add_foreign_key "locations", "schemes" add_foreign_key "locations", "schemes"
add_foreign_key "schemes", "organisations" add_foreign_key "schemes", "organisations"
add_foreign_key "schemes", "organisations", column: "stock_owning_organisation_id"
end end

Loading…
Cancel
Save