mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
266: Updating with rohans suggestions to tidy up and 'rubify' the code. Thanks for the tips Rohan!
This commit is contained in:
@@ -631,7 +631,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
:orders_and_fulfillment => {:name => "Orders & Fulfillment Reports", :description => ''},
|
||||
:customers => {:name => "Customers", :description => 'Customer details'},
|
||||
:products_and_inventory => {:name => "Products & Inventory", :description => ''},
|
||||
:order_cycle_management => {:name => "UK Order Cycle Management", :description => ''}
|
||||
:order_cycle_management => {:name => "Order Cycle Management", :description => ''}
|
||||
|
||||
}
|
||||
# Return only reports the user is authorized to view.
|
||||
|
||||
@@ -8,28 +8,12 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
#lin-d-hop
|
||||
#Find the payment methods options for reporting.
|
||||
#I don't like that this is done in two loops, but redundant list entries
|
||||
# were created otherwise...
|
||||
def report_payment_method_options(orders)
|
||||
payment_method_list = []
|
||||
orders.map do |o|
|
||||
payment_method_list << o.payments.first.payment_method.andand.name
|
||||
end
|
||||
payment_method_list.uniq.each do |pm|
|
||||
[ "#{pm}".html_safe, pm]
|
||||
end
|
||||
orders.map { |o| o.payments.first.payment_method.andand.name }.uniq
|
||||
end
|
||||
|
||||
def report_distribution_options(orders)
|
||||
distribution_list = []
|
||||
orders.map do |o|
|
||||
distribution_list << o.shipping_method.andand.name
|
||||
end
|
||||
distribution_list.uniq.each do |pm|
|
||||
[ "#{pm}".html_safe, pm]
|
||||
end
|
||||
orders.map { |o| o.shipping_method.andand.name }.uniq
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def filter_to_payment_method (orders)
|
||||
if params.has_key? (:payment_method_name)
|
||||
if params[:payment_method_name].present?
|
||||
orders.with_payment_method_name(params[:payment_method_name])
|
||||
else
|
||||
orders
|
||||
@@ -52,7 +52,7 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def filter_to_distribution (orders)
|
||||
if params.has_key? (:distribution_name)
|
||||
if params[:distribution_name].present?
|
||||
orders.joins(:shipping_method).where("spree_shipping_methods.name = ?", params[:distribution_name])
|
||||
else
|
||||
orders
|
||||
|
||||
Reference in New Issue
Block a user