266: Updating with rohans suggestions to tidy up and 'rubify' the code. Thanks for the tips Rohan!

This commit is contained in:
Lynne Davis
2014-11-14 15:56:07 +00:00
parent 15f29f4c8e
commit 03b59eae75
3 changed files with 5 additions and 21 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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