diff --git a/app/services/permissions/order.rb b/app/services/permissions/order.rb index f71e46024f..8dbbca41be 100644 --- a/app/services/permissions/order.rb +++ b/app/services/permissions/order.rb @@ -63,36 +63,28 @@ module Permissions # Any orders placed through any hub that I manage def managed_orders_where_values - query = Spree::Order. - where(distributor_id: @permissions.managed_enterprises.select("enterprises.id")) - - apply_where_clause(query).reduce(:and) + Spree::Order. + where(distributor_id: @permissions.managed_enterprises.select("enterprises.id")). + where_clause.__send__(:predicates). + reduce(:and) end # Any order that is placed through an order cycle one of my managed enterprises coordinates def coordinated_orders_where_values - query = Spree::Order. - where(order_cycle_id: @permissions.coordinated_order_cycles.select(:id)) - - apply_where_clause(query).reduce(:and) + Spree::Order. + where(order_cycle_id: @permissions.coordinated_order_cycles.select(:id)). + where_clause.__send__(:predicates). + reduce(:and) end def produced_orders_where_values - query = Spree::Order.with_line_items_variants_and_products_outer. + Spree::Order.with_line_items_variants_and_products_outer. where( distributor_id: granted_distributor_ids, spree_products: { supplier_id: enterprises_with_associated_orders } - ) - - apply_where_clause(query).reduce(:and) - end - - def apply_where_clause(query) - if ENV['DEPENDENCIES_NEXT'] - query.where_clause.__send__(:predicates) - else - query.where_values - end + ). + where_clause.__send__(:predicates). + reduce(:and) end def enterprises_with_associated_orders