mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Switch search filters from orders to line_items
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
= label_tag nil, t(:date_range)
|
||||
%br
|
||||
= label_tag nil, t(:start), :class => 'inline'
|
||||
= text_field_tag "q[completed_at_gt]", params.dig(:q, :completed_at_gt), :class => 'datetimepicker datepicker-from'
|
||||
= text_field_tag "q[order_completed_at_gt]", params.dig(:q, :order_completed_at_gt), :class => 'datetimepicker datepicker-from'
|
||||
%span.range-divider
|
||||
%i.icon-arrow-right
|
||||
= text_field_tag "q[completed_at_lt]", params.dig(:q, :completed_at_lt), :class => 'datetimepicker datepicker-to'
|
||||
= text_field_tag "q[order_completed_at_lt]", params.dig(:q, :order_completed_at_lt), :class => 'datetimepicker datepicker-to'
|
||||
= label_tag nil, t(:end), :class => 'inline'
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns
|
||||
= collection_select("q", "distributor_id_in", @distributors, :id, :name, {selected: params.dig(:q, :distributor_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
= collection_select("q", "order_distributor_id_in", @distributors, :id, :name, {selected: params.dig(:q, :order_distributor_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_producers)
|
||||
|
||||
@@ -35,6 +35,10 @@ module Reporting
|
||||
visible_orders_relation.ransack(ransack_params).result
|
||||
end
|
||||
|
||||
def ransacked_line_items_relation
|
||||
visible_line_items_relation.ransack(ransack_params).result
|
||||
end
|
||||
|
||||
def visible_orders_relation
|
||||
::Permissions::Order.new(current_user).
|
||||
visible_orders.complete.not_state(:canceled).
|
||||
|
||||
@@ -12,8 +12,8 @@ module Reporting
|
||||
|
||||
def report_query
|
||||
Queries::QueryBuilder.new(primary_model, grouping_fields).
|
||||
scoped_to_orders(ransacked_orders_relation).
|
||||
scoped_to_line_items(visible_line_items_relation).
|
||||
scoped_to_orders(visible_orders_relation).
|
||||
scoped_to_line_items(ransacked_line_items_relation).
|
||||
with_managed_orders(managed_orders_relation).
|
||||
joins_order_and_distributor.
|
||||
joins_order_customer.
|
||||
|
||||
@@ -6,7 +6,7 @@ describe Api::V0::ReportsController, type: :controller do
|
||||
let(:params) {
|
||||
{
|
||||
report_type: 'packing',
|
||||
q: { created_at_lt: Time.zone.now }
|
||||
q: { order_created_at_lt: Time.zone.now }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user