From c59326743b7f3ab09e7d1fb0fb90606ff5bb4887 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 13 Dec 2019 16:05:10 +0000 Subject: [PATCH] Remove sales total report --- .../spree/admin/reports_controller.rb | 43 ------------------- .../spree/admin/reports/sales_total.html.haml | 26 ----------- config/locales/en.yml | 3 -- spec/features/admin/reports_spec.rb | 6 +-- spec/models/spree/ability_spec.rb | 4 +- 5 files changed, 4 insertions(+), 78 deletions(-) delete mode 100644 app/views/spree/admin/reports/sales_total.html.haml diff --git a/app/controllers/spree/admin/reports_controller.rb b/app/controllers/spree/admin/reports_controller.rb index 9693ba1161..ec08bca29c 100644 --- a/app/controllers/spree/admin/reports_controller.rb +++ b/app/controllers/spree/admin/reports_controller.rb @@ -39,48 +39,6 @@ module Spree respond_with(@reports) end - def sales_total - params[:q] = {} unless params[:q] - - if params[:q][:created_at_gt].blank? - params[:q][:created_at_gt] = Time.zone.now.beginning_of_month - else - params[:q][:created_at_gt] = begin - Time.zone. - parse(params[:q][:created_at_gt]).beginning_of_day - rescue - Time.zone.now.beginning_of_month - end - end - - if params[:q] && params[:q][:created_at_lt].present? - params[:q][:created_at_lt] = begin - Time.zone.parse(params[:q][:created_at_lt]).end_of_day - rescue - "" - end - end - - params[:q][:completed_at_not_null] = (params[:q].delete(:completed_at_not_null) == "1") - - params[:q][:s] ||= "created_at desc" - - @search = Order.complete.ransack(params[:q]) - @orders = @search.result - - @totals = {} - @orders.each do |order| - unless @totals[order.currency] - @totals[order.currency] = { item_total: ::Money.new(0, order.currency), - adjustment_total: ::Money.new(0, order.currency), - sales_total: ::Money.new(0, order.currency) } - end - @totals[order.currency][:item_total] += order.display_item_total.money - @totals[order.currency][:adjustment_total] += order.display_adjustment_total.money - @totals[order.currency][:sales_total] += order.display_total.money - end - end - def customers @report_types = report_types[:customers] @report_type = params[:report_type] @@ -314,7 +272,6 @@ module Spree :orders_and_fulfillment, :customers, :products_and_inventory, - :sales_total, :users_and_enterprises, :enterprise_fee_summary, :order_cycle_management, diff --git a/app/views/spree/admin/reports/sales_total.html.haml b/app/views/spree/admin/reports/sales_total.html.haml deleted file mode 100644 index ccfd2d7926..0000000000 --- a/app/views/spree/admin/reports/sales_total.html.haml +++ /dev/null @@ -1,26 +0,0 @@ -- content_for :page_title do - = Spree.t(:sales_totals) - -- content_for :page_actions do - %li= link_to_with_icon 'icon-arrow-left', Spree.t(:back_to_reports_list), spree.admin_reports_url, class: 'button' - -- content_for :table_filter_title do - = Spree.t(:date_range) - -- content_for :table_filter do - = render partial: 'spree/admin/shared/report_criteria', locals: {} - -%table.admin-report - %thead - %tr - %th= Spree.t(:currency) - %th= Spree.t(:item_total) - %th= Spree.t(:adjustment_total) - %th= Spree.t(:sales_total) - %tbody - - @totals.each do |key, row| - %tr.align-center - %td= key - %td= row[:item_total].format - %td= row[:adjustment_total].format - %td= row[:sales_total].format diff --git a/config/locales/en.yml b/config/locales/en.yml index f1945520a0..876c755dfd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1046,9 +1046,6 @@ en: products_and_inventory: name: Products & Inventory description: - sales_total: - name: Sales Total - description: Sales Total For All Orders users_and_enterprises: name: Users & Enterprises description: Enterprise Ownership & Status diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index 4d1f6b36d9..97b677ed98 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -14,18 +14,16 @@ feature ' create(:distributor_enterprise) ]) end - it "does not show super admin only reports" do + it "does not show super admin only report" do login_to_admin_as user click_link "Reports" - expect(page).not_to have_content "Sales Total" expect(page).not_to have_content "Users & Enterprises" end end context "As an admin user" do - it "shows the super admin only reports" do + it "shows the super admin only report" do login_to_admin_section click_link "Reports" - expect(page).to have_content "Sales Total" expect(page).to have_content "Users & Enterprises" end end diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb index d66d0091dd..4710f18743 100644 --- a/spec/models/spree/ability_spec.rb +++ b/spec/models/spree/ability_spec.rb @@ -219,7 +219,7 @@ module Spree include_examples "allows access to Enterprise Fee Summary" it "should not be able to read other reports" do - is_expected.not_to have_ability([:sales_total, :group_buys, :payments, :orders_and_distributors, :users_and_enterprises, :xero_invoices], for: Spree::Admin::ReportsController) + is_expected.not_to have_ability([:group_buys, :payments, :orders_and_distributors, :users_and_enterprises, :xero_invoices], for: Spree::Admin::ReportsController) end it "should not be able to access customer actions" do @@ -412,7 +412,7 @@ module Spree include_examples "allows access to Enterprise Fee Summary" it "should not be able to read other reports" do - is_expected.not_to have_ability([:sales_total, :users_and_enterprises], for: Spree::Admin::ReportsController) + is_expected.not_to have_ability([:users_and_enterprises], for: Spree::Admin::ReportsController) end it "should be able to access customer actions" do