From 4acc942100a80c2048aa970e0a2e1beb80c07323 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Tue, 27 Jul 2021 18:06:30 +0200 Subject: [PATCH] Add appropriate distributors and suppliers to the packing report ie. the ones that are distributing/supplying products the current user is distributing/supplying - As the orders_and_fullfillment reports already had the right filled distributors and suppliers, use the same method: add_appropriate_distributors_and_suppliers --- .../spree/admin/reports_controller.rb | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/controllers/spree/admin/reports_controller.rb b/app/controllers/spree/admin/reports_controller.rb index f0976ca4c1..807b04160c 100644 --- a/app/controllers/spree/admin/reports_controller.rb +++ b/app/controllers/spree/admin/reports_controller.rb @@ -75,6 +75,9 @@ module Spree @report_types = report_types[:packing] @report_type = params[:report_type] + # Add distributors/suppliers distributing/supplying products I distribute/supply + add_appropriate_distributors_and_suppliers + # -- Build Report with Order Grouper @report = OpenFoodNetwork::PackingReport.new spree_current_user, raw_params, render_content? @table = order_grouper_table @@ -116,12 +119,8 @@ module Spree def orders_and_fulfillment raw_params[:q] ||= orders_and_fulfillment_default_filters - # -- Prepare Form Options - permissions = OpenFoodNetwork::Permissions.new(spree_current_user) - # My distributors and any distributors distributing products I supply - @distributors = permissions.visible_enterprises_for_order_reports.is_distributor - # My suppliers and any suppliers supplying products I distribute - @suppliers = permissions.visible_enterprises_for_order_reports.is_primary_producer + # Add distributors/suppliers distributing/supplying products I distribute/supply + add_appropriate_distributors_and_suppliers @order_cycles = my_order_cycles @@ -219,6 +218,15 @@ module Spree # Rendering HTML is the default. end + def add_appropriate_distributors_and_suppliers + # -- Prepare Form Options + permissions = OpenFoodNetwork::Permissions.new(spree_current_user) + # My distributors and any distributors distributing products I supply + @distributors = permissions.visible_enterprises_for_order_reports.is_distributor + # My suppliers and any suppliers supplying products I distribute + @suppliers = permissions.visible_enterprises_for_order_reports.is_primary_producer + end + def csv_report(header, table) CSV.generate do |csv| csv << header