diff --git a/app/components/log_summary_component.html.erb b/app/components/log_summary_component.html.erb index 65d2fc045..8093c65c3 100644 --- a/app/components/log_summary_component.html.erb +++ b/app/components/log_summary_component.html.erb @@ -37,16 +37,18 @@ <% end %> <% if current_user.support? %> - <% if log.owning_organisation or log.managing_organisation %> + <% if log.owning_organisation %>
<% end %> <% end %> diff --git a/app/models/organisation.rb b/app/models/organisation.rb index 0bf47eb76..395287f25 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -3,7 +3,6 @@ class Organisation < ApplicationRecord has_many :owned_lettings_logs, class_name: "LettingsLog", foreign_key: "owning_organisation_id", dependent: :delete_all has_many :managed_lettings_logs, class_name: "LettingsLog", foreign_key: "managing_organisation_id" has_many :owned_sales_logs, class_name: "SalesLog", foreign_key: "owning_organisation_id", dependent: :delete_all - has_many :managed_sales_logs, class_name: "SalesLog", foreign_key: "managing_organisation_id" has_many :data_protection_confirmations has_many :organisation_rent_periods has_many :owned_schemes, class_name: "Scheme", foreign_key: "owning_organisation_id", dependent: :delete_all diff --git a/app/models/user.rb b/app/models/user.rb index 6126e7004..2eaa16df6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,7 +10,6 @@ class User < ApplicationRecord has_many :owned_lettings_logs, through: :organisation has_many :managed_lettings_logs, through: :organisation has_many :owned_sales_logs, through: :organisation - has_many :managed_sales_logs, through: :organisation has_many :legacy_users validates :name, presence: true diff --git a/db/migrate/20230110094518_remove_managing_organisation_id_from_sales_logs.rb b/db/migrate/20230110094518_remove_managing_organisation_id_from_sales_logs.rb new file mode 100644 index 000000000..b2aa71d76 --- /dev/null +++ b/db/migrate/20230110094518_remove_managing_organisation_id_from_sales_logs.rb @@ -0,0 +1,13 @@ +class RemoveManagingOrganisationIdFromSalesLogs < ActiveRecord::Migration[7.0] + def up + change_table :sales_logs, bulk: true do |t| + t.remove :managing_organisation_id + end + end + + def down + change_table :sales_logs, bulk: true do |t| + t.column :managing_organisation_id, :bigint + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 31f16f79d..2d5e6502f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_01_09_160738) do +ActiveRecord::Schema[7.0].define(version: 2023_01_10_094518) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -352,7 +352,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_09_160738) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.bigint "owning_organisation_id" - t.bigint "managing_organisation_id" t.bigint "created_by_id" t.string "purchid" t.integer "type" @@ -471,8 +470,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_09_160738) do t.integer "hoday" t.integer "homonth" t.integer "hoyear" + t.integer "extrabor" 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" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" t.index ["updated_by_id"], name: "index_sales_logs_on_updated_by_id" end diff --git a/spec/requests/sales_logs_controller_spec.rb b/spec/requests/sales_logs_controller_spec.rb index 65b3f94ef..150997423 100644 --- a/spec/requests/sales_logs_controller_spec.rb +++ b/spec/requests/sales_logs_controller_spec.rb @@ -119,7 +119,7 @@ RSpec.describe SalesLogsController, type: :request do it "does have organisation values" do get "/sales-logs", headers: headers, params: {} expect(page).to have_content("Owned by") - expect(page).to have_content("Managed by") + expect(page).not_to have_content("Managed by") end it "shows sales logs for all organisations" do