diff --git a/app/controllers/spree/admin/reports_controller_decorator.rb b/app/controllers/spree/admin/reports_controller_decorator.rb index 7a2167b142..75e9fb7c40 100644 --- a/app/controllers/spree/admin/reports_controller_decorator.rb +++ b/app/controllers/spree/admin/reports_controller_decorator.rb @@ -9,18 +9,18 @@ Spree::Admin::ReportsController.class_eval do # Render a partial for orders and fulfillment description respond_override :index => { :html => { :success => lambda { - @reports[:order_cycles][:description] = - render_to_string(partial: 'orders_and_fulfillment_description', layout: false, locals: {report_types: REPORT_TYPES[:order_cycles]}).html_safe + @reports[:orders_and_fulfillment][:description] = + render_to_string(partial: 'orders_and_fulfillment_description', layout: false, locals: {report_types: REPORT_TYPES[:orders_and_fulfillment]}).html_safe } } } Spree::Admin::ReportsController::AVAILABLE_REPORTS.merge!({:orders_and_distributors => {:name => "Orders And Distributors", :description => "Orders with distributor details"}}) Spree::Admin::ReportsController::AVAILABLE_REPORTS.merge!({:group_buys => {:name => "Group Buys", :description => "Orders by supplier and variant"}}) Spree::Admin::ReportsController::AVAILABLE_REPORTS.merge!({:bulk_coop => {:name => "Bulk Co-Op", :description => "Reports for Bulk Co-Op orders"}}) Spree::Admin::ReportsController::AVAILABLE_REPORTS.merge!({:payments => {:name => "Payment Reports", :description => "Reports for Payments"}}) - Spree::Admin::ReportsController::AVAILABLE_REPORTS.merge!({:order_cycles => {:name => "Order Cycle Reports", :description => ''}}) + Spree::Admin::ReportsController::AVAILABLE_REPORTS.merge!({:orders_and_fulfillment => {:name => "Orders & Fulfillment Reports", :description => ''}}) REPORT_TYPES = { - order_cycles: [ + orders_and_fulfillment: [ ['Order Cycle Supplier Totals',:order_cycle_supplier_totals], ['Order Cycle Supplier Totals by Distributor',:order_cycle_supplier_totals_by_distributor], ['Order Cycle Distributor Totals by Supplier',:order_cycle_distributor_totals_by_supplier], @@ -347,7 +347,7 @@ Spree::Admin::ReportsController.class_eval do end - def order_cycles + def orders_and_fulfillment params[:q] = {} unless params[:q] if params[:q][:completed_at_gt].blank? @@ -370,7 +370,7 @@ Spree::Admin::ReportsController.class_eval do @distributors = Enterprise.is_distributor.managed_by(spree_current_user) #@suppliers = Enterprise.is_primary_producer @order_cycles = OrderCycle.active_or_complete.order('orders_close_at DESC') - @report_types = REPORT_TYPES[:order_cycles] + @report_types = REPORT_TYPES[:orders_and_fulfillment] @report_type = params[:report_type] case params[:report_type] @@ -532,7 +532,7 @@ Spree::Admin::ReportsController.class_eval do @header = header @table = order_grouper.table(table_items) - csv_file_name = "order_cycles.csv" + csv_file_name = "#{__method__}.csv" render_report(@header, @table, params[:csv], csv_file_name) diff --git a/app/models/spree/ability_decorator.rb b/app/models/spree/ability_decorator.rb index a2e82c138a..618edcae3d 100644 --- a/app/models/spree/ability_decorator.rb +++ b/app/models/spree/ability_decorator.rb @@ -61,7 +61,7 @@ class AbilityDecorator end # Enterprise User can access reports page - can [:admin, :index, :orders_and_distributors, :group_buys, :bulk_coop, :payments, :order_cycles], :report + can [:admin, :index, :orders_and_distributors, :group_buys, :bulk_coop, :payments, :orders_and_fulfillment], :report end end end diff --git a/app/views/spree/admin/reports/_orders_and_fulfillment_description.html.haml b/app/views/spree/admin/reports/_orders_and_fulfillment_description.html.haml index 281ef7bd24..a813492cac 100644 --- a/app/views/spree/admin/reports/_orders_and_fulfillment_description.html.haml +++ b/app/views/spree/admin/reports/_orders_and_fulfillment_description.html.haml @@ -1,5 +1,5 @@ %ul{style: "margin-left: 12pt"} - report_types.each do |report_type| %li - = link_to report_type[0], "#{order_cycles_admin_reports_url}?report_type=#{report_type[1]}" + = link_to report_type[0], "#{orders_and_fulfillment_admin_reports_url}?report_type=#{report_type[1]}" \ No newline at end of file diff --git a/app/views/spree/admin/reports/order_cycles.html.haml b/app/views/spree/admin/reports/orders_and_fulfillment.html.haml similarity index 94% rename from app/views/spree/admin/reports/order_cycles.html.haml rename to app/views/spree/admin/reports/orders_and_fulfillment.html.haml index 6b06199459..3ce0285a7a 100644 --- a/app/views/spree/admin/reports/order_cycles.html.haml +++ b/app/views/spree/admin/reports/orders_and_fulfillment.html.haml @@ -1,4 +1,4 @@ -= form_for @search, :url => spree.order_cycles_admin_reports_path do |f| += form_for @search, :url => spree.orders_and_fulfillment_admin_reports_path do |f| = label_tag nil, t(:date_range) %br .date-range-filter diff --git a/config/routes.rb b/config/routes.rb index e6a3f17e22..9c002ff43c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -50,7 +50,7 @@ Spree::Core::Engine.routes.prepend do match '/admin/reports/group_buys' => 'admin/reports#group_buys', :as => "group_buys_admin_reports", :via => [:get, :post] match '/admin/reports/bulk_coop' => 'admin/reports#bulk_coop', :as => "bulk_coop_admin_reports", :via => [:get, :post] match '/admin/reports/payments' => 'admin/reports#payments', :as => "payments_admin_reports", :via => [:get, :post] - match '/admin/reports/order_cycles' => 'admin/reports#order_cycles', :as => "order_cycles_admin_reports", :via => [:get, :post] + match '/admin/reports/orders_and_fulfillment' => 'admin/reports#orders_and_fulfillment', :as => "orders_and_fulfillment_admin_reports", :via => [:get, :post] match '/admin/products/bulk_edit' => 'admin/products#bulk_edit', :as => "bulk_edit_admin_products" diff --git a/spec/controllers/spree/admin/reports_controller_spec.rb b/spec/controllers/spree/admin/reports_controller_spec.rb index 9446524873..743b72cb4e 100644 --- a/spec/controllers/spree/admin/reports_controller_spec.rb +++ b/spec/controllers/spree/admin/reports_controller_spec.rb @@ -107,9 +107,9 @@ describe Spree::Admin::ReportsController do end end - describe 'Order Cycles' do + describe 'Orders & Fulfillment' do it "only shows orders that I have access to" do - spree_get :order_cycles + spree_get :orders_and_fulfillment assigns(:search).result.should include(orderA1, orderB1) assigns(:search).result.should_not include(orderA2) @@ -117,7 +117,7 @@ describe Spree::Admin::ReportsController do end it "only shows the selected order cycle" do - spree_get :order_cycles, q: {order_cycle_id_eq: ocA.id} + spree_get :orders_and_fulfillment, q: {order_cycle_id_eq: ocA.id} assigns(:search).result.should include(orderA1) assigns(:search).result.should_not include(orderB1) @@ -148,9 +148,9 @@ describe Spree::Admin::ReportsController do end end - describe 'Order Cycles' do + describe 'Orders & Fulfillment' do it "only shows product line items that I am supplying" do - spree_get :order_cycles + spree_get :orders_and_fulfillment assigns(:line_items).map(&:product).should include(p1) assigns(:line_items).map(&:product).should_not include(p2) @@ -158,7 +158,7 @@ describe Spree::Admin::ReportsController do end it "only shows the selected order cycle" do - spree_get :order_cycles, q: {order_cycle_id_eq: ocA.id} + spree_get :orders_and_fulfillment, q: {order_cycle_id_eq: ocA.id} assigns(:search).result.should include(orderA1) assigns(:search).result.should_not include(orderB1) diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index 7345a527b0..1abd0636ea 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -40,15 +40,15 @@ feature %q{ page.should have_content 'Payment State' end - scenario "order cycle reports" do + scenario "orders & fulfillment reports" do login_to_admin_section click_link 'Reports' - click_link 'Order Cycle Reports' + click_link 'Orders & Fulfillment Reports' page.should have_content 'Supplier' end - scenario "order cycle reports are precise to time of day, not just date" do + scenario "orders & fulfillment reports are precise to time of day, not just date" do # Given two orders on the same day at different times @bill_address = create(:address) @distributor_address = create(:address, :address1 => "distributor address", :city => 'The Shire', :zipcode => "1234") @@ -68,7 +68,7 @@ feature %q{ # When I generate a customer report with a timeframe that includes one order but not the other login_to_admin_section click_link 'Reports' - click_link 'Order Cycle Reports' + click_link 'Orders & Fulfillment Reports' fill_in 'q_completed_at_gt', with: '2013-04-25 13:00:00' fill_in 'q_completed_at_lt', with: '2013-04-25 15:00:00'