Skip to content

Commit

Permalink
[NUOPEN-214] [Tech task] Remove cross_core_projects and `cross_core…
Browse files Browse the repository at this point in the history
…_order_view` (#5056)

* Remove cross_core_projects

* Remove cross_core_order_view
  • Loading branch information
LeticiaErrandonea authored Feb 27, 2025
1 parent be6144c commit fafffbe
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 114 deletions.
5 changes: 1 addition & 4 deletions app/controllers/concerns/new_inprocess_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ def index
TransactionSearch::OrderedForSearcher,
TransactionSearch::OrderStatusSearcher,
TransactionSearch::DateRangeSearcher,
TransactionSearch::CrossCoreSearcher,
]

if SettingsHelper.feature_on?(:cross_core_order_view)
searchers << TransactionSearch::CrossCoreSearcher
end

@search = TransactionSearch::Searcher.new(*searchers).search(order_details, @search_form)
@order_details = @search.order_details.includes(:order_status).joins_assigned_users.reorder(sort_clause)
@date_range_field = @search_form.date_params[:field]
Expand Down
5 changes: 1 addition & 4 deletions app/controllers/concerns/problem_order_details_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ def show_problems
TransactionSearch::AccountSearcher,
TransactionSearch::OrderedForSearcher,
TransactionSearch::DateRangeSearcher,
TransactionSearch::CrossCoreSearcher,
]

if SettingsHelper.feature_on?(:cross_core_order_view)
searchers << TransactionSearch::CrossCoreSearcher
end

@search = TransactionSearch::Searcher.new(*searchers).search(order_details, @search_form)
@order_details = @search.order_details.preload(:order_status, :assigned_user)

Expand Down
4 changes: 1 addition & 3 deletions app/controllers/facility_orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def load_order
def load_merge_orders
missing_reservation_order_ids = []

if SettingsHelper.feature_on?(:cross_core_projects) && @order.cross_core_project_id.present?
if @order.cross_core_project_id.present?
project_order_ids = @order.cross_core_project.orders.pluck(:id)
missing_reservation_order_ids = missing_reservation_order_ids(project_order_ids)
else
Expand Down Expand Up @@ -138,8 +138,6 @@ def problem_order_details
end

def load_cross_core_order_details
return unless SettingsHelper.feature_on?(:cross_core_projects)

@cross_core_project = @order.cross_core_project

@cross_core_data_by_facility_id = {}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/order_detail_stored_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def ability_resource
end

def redirect_to_facility_order(consider_merge_order: false)
if SettingsHelper.feature_on?(:cross_core_projects) && @original_order_id.present?
if @original_order_id.present?
original_order = Order.find(@original_order_id)

order = consider_merge_order ? original_order.merge_order || original_order : original_order
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,6 @@ def duration_change_valid?
end

def set_accounts_for_cross_core_project
return unless SettingsHelper.feature_on?(:cross_core_projects)

return if @order.cross_core_project_id.nil?

@accounts_for_cross_core_project = AvailableAccountsFinder.new(original_project_order.user, @order.facility)
Expand All @@ -436,8 +434,6 @@ def original_project_order
end

def set_cross_core_cancel_path
return unless SettingsHelper.feature_on?(:cross_core_projects)

return if @order.cross_core_project_id.blank?

current_user_facilities = current_user.facilities
Expand Down
10 changes: 4 additions & 6 deletions app/forms/add_to_order_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ def save

if @original_order.facility.id == @facility_id
add_to_order!
elsif SettingsHelper.feature_on?(:cross_core_projects)
if order_for_selected_facility.nil?
create_cross_core_project_and_add_order!
else
add_to_order!
end
elsif order_for_selected_facility.nil?
create_cross_core_project_and_add_order!
else
add_to_order!
end

true
Expand Down
6 changes: 3 additions & 3 deletions app/lib/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def cross_core_abilities(user, resource, controller)
can :available_for_cross_core_ordering, Product
elsif controller.is_a?(FacilityAccountsController) && user.facility_staff_or_manager_of_any_facility?
can [:accounts_available_for_order], Account
elsif controller.is_a?(FacilityOrderDetailsController) && resource.is_a?(Facility) && SettingsHelper.feature_on?(:cross_core_projects)
elsif controller.is_a?(FacilityOrderDetailsController) && resource.is_a?(Facility)
can [:destroy], OrderDetail do |order_detail|
project = order_detail.order.cross_core_project

Expand All @@ -440,15 +440,15 @@ def cross_core_abilities(user, resource, controller)
end
end

if resource.is_a?(OrderDetail) && SettingsHelper.feature_on?(:cross_core_projects)
if resource.is_a?(OrderDetail)
project = resource.order.cross_core_project

if project.present?
can [:add_accessories, :new, :show, :update, :cancel, :template_results], OrderDetail if user.facility_staff_or_manager_of?(project.facility)
end
end

if controller.is_a?(FileUploadsController) && resource.is_a?(Facility) && SettingsHelper.feature_on?(:cross_core_projects)
if controller.is_a?(FileUploadsController) && resource.is_a?(Facility)
can [:upload_sample_results, :destroy], StoredFile do |fileupload|
project = fileupload.order_detail.project

Expand Down
6 changes: 0 additions & 6 deletions app/models/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ class Order < ApplicationRecord

attr_reader :project_id

def cross_core_project
return nil unless SettingsHelper.feature_on?(:cross_core_projects)

super
end

def self.created_by_user(user)
where(created_by: user.id)
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/facility_orders/_merge_order_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- if @merge_orders.blank?
.well
= simple_form_for [current_facility, @add_to_order_form], url: facility_order_path(current_facility, @order), method: :put, html: { class: "js--edit-order" } do |f|
- enable_cross_core_changes = SettingsHelper.feature_on?(:cross_core_projects) && can?(:available_for_cross_core_ordering, Product)
- enable_cross_core_changes = can?(:available_for_cross_core_ordering, Product)
- if enable_cross_core_changes
= f.label :facility_id, Facility.model_name.human
= f.input_field :facility_id,
Expand Down
19 changes: 6 additions & 13 deletions app/views/facility_orders/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
.span12
= render "shared/transactions/search"

- cross_core_order_view_enabled = SettingsHelper.feature_on?(:cross_core_order_view)
.span12
- if @order_details.any?
= link_to t("reports.account_transactions.export"), url_for(format: :csv), class: "js--exportSearchResults pull-right", data: { form: ".search_form" }
Expand All @@ -21,41 +20,35 @@
%th
%th.nowrap= sortable "order_number", Order.model_name.human
%th.nowrap= OrderDetail.model_name.human
- if cross_core_order_view_enabled
%th.nowrap= t("views.facility_orders.index.ordered_by")
%th.nowrap= t("views.facility_orders.index.ordered_by")
%th.nowrap= sortable "ordered_for", Order.human_attribute_name(:user)
%th.nowrap= sortable "ordered_at", Order.human_attribute_name(:ordered_at)
%th.nowrap= OrderDetail.human_attribute_name(:quantity)
%th.nowrap.order-note= sortable "product_name", OrderDetail.human_attribute_name(:product)
- if cross_core_order_view_enabled
%th.nowrap= Facility.model_name.human
%th.nowrap= Facility.model_name.human
%th.nowrap= sortable "assigned_to", OrderDetail.human_attribute_name(:assigned_user)
%th.nowrap= sortable "status"
- # OrderDetail.human_attribute_name(:actual_cost) returns "Price". Despite the :actual_ prefix, these order details are new/in process, so most will have estimated costs, but could be actual or unassigned.
%th.nowrap.currency= OrderDetail.human_attribute_name(:actual_cost)
- if cross_core_order_view_enabled
%th.nowrap= PriceGroup.model_name.human
%th.nowrap= PriceGroup.model_name.human
%tbody
- @order_details.each do |od|
%tr
- order_detail = OrderDetailPresenter.new(od)
%td.centered= check_box_tag("order_detail_ids[]", od.id, false, {class: "toggle", id: nil })
%td.centered= link_to od.order_id, facility_order_path(current_facility, od.order)
%td.centered= link_to od.id, manage_order_detail_path(od), class: "manage-order-detail"
- if cross_core_order_view_enabled
%td= od.order.created_by_user.full_name
%td= od.order.created_by_user.full_name
%td= od.order.user.full_name
%td= format_usa_datetime(od.ordered_at)
%td.centered= order_detail.wrapped_quantity
= render partial: "shared/order_detail_cell", locals: { od: od }
- if cross_core_order_view_enabled
%td= render "shared/cross_core_facility_abbreviation_order_details", order_detail: od, current_facility: current_facility
%td= render "shared/cross_core_facility_abbreviation_order_details", order_detail: od, current_facility: current_facility
%td= od.assigned_user
%td= od.order_status
%td.currency
= order_detail.wrapped_total
- if cross_core_order_view_enabled
%td= order_detail.price_group_name
%td= order_detail.price_group_name
= render partial: "table_controls"

= will_paginate(@order_details)
Expand Down
19 changes: 9 additions & 10 deletions app/views/facility_orders/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
= banner_date_label @order, :ordered_at
= banner_label @order, :user
= banner_label @order, :created_by_user
- if SettingsHelper.feature_on?(:cross_core_projects)
- if @cross_core_project.present?
%dl.span2
%dt= t("views.facility_orders.show.cross_core_project_id")
%dd
= link_to @cross_core_project.name, facility_project_path(current_facility, @cross_core_project.id)
%dl.span2
%dt= t("views.facility_orders.show.cross_core_project_total")
%dd= number_to_currency @gross_order_value
- if @cross_core_project.present?
%dl.span2
%dt= t("views.facility_orders.show.cross_core_project_id")
%dd
= link_to @cross_core_project.name, facility_project_path(current_facility, @cross_core_project.id)
%dl.span2
%dt= t("views.facility_orders.show.cross_core_project_total")
%dd= number_to_currency @gross_order_value
- if @merge_orders.blank? && current_ability.can?(:send_receipt, @order)
.pull-right= render "send_receipt"

Expand All @@ -30,7 +29,7 @@
- subheader_key = (@cross_core_project.present? ? "views.facility_orders.show.add_to_cross_core_order_header" : "views.facility_orders.show.add_to_order_header")

%h2= t(subheader_key)
- if SettingsHelper.feature_on?(:cross_core_projects) && @cross_core_data_by_facility_id.present?
- if @cross_core_data_by_facility_id.present?
#js--reportAnIssueModal.modal.hide.fade

#accordion
Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/_tabnav.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{ action: :index },
@active_tab == "index"

- if current_ability.can?(:cross_core_orders, Project) && SettingsHelper.feature_on?(:cross_core_order_view)
- if current_ability.can?(:cross_core_orders, Project)
%li
= tab t(".cross_core_orders"),
{ action: :cross_core_orders },
Expand Down
74 changes: 36 additions & 38 deletions app/views/projects/cross_core_orders.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,41 @@
.span12
= render "shared/transactions/search"

- cross_core_order_view_enabled = SettingsHelper.feature_on?(:cross_core_order_view)
- if cross_core_order_view_enabled
.span12
- if @order_details.any?
%table.table.table-striped.table-hover.old-table
%thead
.span12
- if @order_details.any?
%table.table.table-striped.table-hover.old-table
%thead
%tr
%th.nowrap= sortable "order_number", OrderDetail.model_name.human
%th.nowrap= t("views.facility_orders.index.ordered_by")
%th.nowrap= Order.human_attribute_name(:user)
%th.nowrap= sortable "ordered_at", Order.human_attribute_name(:ordered_at)
%th.nowrap= OrderDetail.human_attribute_name(:quantity)
%th.nowrap.order-note= OrderDetail.human_attribute_name(:product)
%th.nowrap= sortable "facility", Facility.model_name.human
%th.nowrap= Project.model_name.human
%th.nowrap= sortable "status"
%th.nowrap.currency= OrderDetail.human_attribute_name(:actual_cost)
%th.nowrap= PriceGroup.model_name.human
%tbody
- @order_details.each do |od|
%tr
%th.nowrap= sortable "order_number", OrderDetail.model_name.human
%th.nowrap= t("views.facility_orders.index.ordered_by")
%th.nowrap= Order.human_attribute_name(:user)
%th.nowrap= sortable "ordered_at", Order.human_attribute_name(:ordered_at)
%th.nowrap= OrderDetail.human_attribute_name(:quantity)
%th.nowrap.order-note= OrderDetail.human_attribute_name(:product)
%th.nowrap= sortable "facility", Facility.model_name.human
%th.nowrap= Project.model_name.human
%th.nowrap= sortable "status"
%th.nowrap.currency= OrderDetail.human_attribute_name(:actual_cost)
%th.nowrap= PriceGroup.model_name.human
%tbody
- @order_details.each do |od|
%tr
- order_detail = OrderDetailPresenter.new(od)
%td= od
%td= od.order.created_by_user.full_name
%td= od.order.user.full_name
%td= format_usa_datetime(od.ordered_at)
%td.centered= order_detail.wrapped_quantity
= render partial: "shared/order_detail_cell", locals: { od: od }
%td= od.order.facility.abbreviation.truncate(6)
-# TODO: This should be a link when we have the project page
%td= od.order.cross_core_project&.name
%td= od.order_status
%td.currency
= order_detail.wrapped_total
%td= order_detail.price_group_name
- order_detail = OrderDetailPresenter.new(od)
%td= od
%td= od.order.created_by_user.full_name
%td= od.order.user.full_name
%td= format_usa_datetime(od.ordered_at)
%td.centered= order_detail.wrapped_quantity
= render partial: "shared/order_detail_cell", locals: { od: od }
%td= od.order.facility.abbreviation.truncate(6)
-# TODO: This should be a link when we have the project page
%td= od.order.cross_core_project&.name
%td= od.order_status
%td.currency
= order_detail.wrapped_total
%td= order_detail.price_group_name

= will_paginate(@order_details)
= render partial: "/price_display_footnote", locals: { admin: true }
- else
%p.notice= t(".no_orders")
= will_paginate(@order_details)
= render partial: "/price_display_footnote", locals: { admin: true }
- else
%p.notice= t(".no_orders")
14 changes: 4 additions & 10 deletions app/views/shared/_problem_order_details.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
- cross_core_order_view_enabled = SettingsHelper.feature_on?(:cross_core_order_view)

%table.table.table-striped.table-hover
%thead
%tr.borderless
Expand All @@ -12,14 +10,12 @@
%tr
%th= Order.model_name.human
%th= OrderDetail.model_name.human
- if cross_core_order_view_enabled
%th.nowrap= t(".th.ordered_by")
%th.nowrap= t(".th.ordered_by")
%th= problem_order_date_header(local_assigns[:show_reservation_start_at])
%th= Order.human_attribute_name(:user)
%th{ colspan: 2 }= t(".th.quantity_and_product")
%th
- if cross_core_order_view_enabled
%th.nowrap= Facility.model_name.human
%th.nowrap= Facility.model_name.human
%th= Account.model_name.human
%th= t(".th.problem")
%tbody
Expand All @@ -35,8 +31,7 @@
%td.centered= link_to order_detail.id,
manage_order_detail_path(order_detail),
class: "manage-order-detail"
- if cross_core_order_view_enabled
%td= order_detail.order.created_by_user.full_name
%td= order_detail.order.created_by_user.full_name
%td= problem_order_date(order_detail, local_assigns[:show_reservation_start_at])
%td= order_detail.order.user
%td.centered= order_detail.quantity
Expand All @@ -45,8 +40,7 @@
- if order_detail.add_accessories?
= link_to new_facility_order_order_detail_accessory_path(current_facility, order_detail.order, order_detail), class: ["has_accessories", "persistent", "undecorated"] do
= tooltip_icon "fa fa-plus-square", t("product_accessories.pick_accessories.title")
- if cross_core_order_view_enabled
%td= render "shared/cross_core_facility_abbreviation_order_details", order_detail: order_detail, current_facility: current_facility
%td= render "shared/cross_core_facility_abbreviation_order_details", order_detail: order_detail, current_facility: current_facility
%td= order_detail.account
%td.centered
= order_detail_badges(order_detail)
Expand Down
2 changes: 0 additions & 2 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ feature:
facility_tile_list_admin: false
po_require_affiliate_account: true
walkup_reservations: true
cross_core_projects: true
cross_core_order_view: <%= ENV.fetch("CROSS_CORE_ORDER_VIEW", true) %>
show_reconciliation_deposit_number: <%= ENV.fetch("RECONCILIATION_DEPOSIT_NUMBER", false) %>
show_daily_rate_option: true
sanger_enabled_service: <%= ENV.fetch("SANGER_ENABLED_SERVICE", false) %>
Expand Down
4 changes: 2 additions & 2 deletions spec/system/admin/adding_to_a_cross_core_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rails_helper"

RSpec.describe "Adding to an existing order for cross core", :js, feature_setting: { cross_core_projects: true } do
RSpec.describe "Adding to an existing order for cross core", :js do
let(:facility) { product.facility }
let(:order) { create(:purchased_order, product: product, ordered_at: 1.week.ago) }
let(:user) { create(:user, :staff, facility: facility) }
Expand Down Expand Up @@ -96,7 +96,7 @@
end

describe "adding an instrument reservation" do
describe "from another facility", :js, feature_setting: { cross_core_projects: true } do
describe "from another facility", :js do
let(:product) { create(:setup_item, :with_facility_account) }
let!(:instrument) { create(:setup_instrument, facility: facility2, cross_core_ordering_available: true) }
let(:user) { create(:user, :facility_administrator, facility:) }
Expand Down
2 changes: 1 addition & 1 deletion spec/system/admin/adding_to_an_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
end
end

describe "from same facility (with feature flag on)", :js, feature_setting: { cross_core_projects: true } do
describe "from same facility (with feature flag on)", :js do
let(:product) { create(:setup_item, :with_facility_account) }
let!(:instrument) { create(:setup_instrument, facility: facility) }
let(:user) { create(:user, :facility_administrator, facility:) }
Expand Down
Loading

0 comments on commit fafffbe

Please sign in to comment.