diff --git a/app/controllers/spree/admin/reports_controller_decorator.rb b/app/controllers/spree/admin/reports_controller_decorator.rb index aed798827e..f148456813 100644 --- a/app/controllers/spree/admin/reports_controller_decorator.rb +++ b/app/controllers/spree/admin/reports_controller_decorator.rb @@ -7,7 +7,6 @@ require 'open_food_network/customers_report' require 'open_food_network/users_and_enterprises_report' require 'open_food_network/order_cycle_management_report' require 'open_food_network/sales_tax_report' -require 'open_food_network/xero_invoices_report' Spree::Admin::ReportsController.class_eval do @@ -15,10 +14,10 @@ Spree::Admin::ReportsController.class_eval do REPORT_TYPES = { 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], - ['Order Cycle Customer Totals', :order_cycle_customer_totals] + ['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], + ['Order Cycle Customer Totals',:order_cycle_customer_totals] ], products_and_inventory: [ ['All products', :all_products], @@ -31,16 +30,13 @@ Spree::Admin::ReportsController.class_eval do order_cycle_management: [ ["Payment Methods Report", :payment_methods], ["Delivery Report", :delivery] - ], - xero_invoices: [ - ["Xero Invoices Report", :xero_invoices] ] } # Fetches user's distributors, suppliers and order_cycles before_filter :load_data, only: [:customers, :products_and_inventory, :order_cycle_management] - # Render a partial for various section descriptions + # Render a partial for orders and fulfillment description respond_override :index => { :html => { :success => lambda { @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 @@ -676,13 +672,7 @@ Spree::Admin::ReportsController.class_eval do render_report(@report.header, @report.table, params[:csv], "users_and_enterprises_#{timestamp}.csv") end - def xero_invoices - @report = OpenFoodNetwork::XeroInvoicesReport.new params - render_report(@report.header, @report.table, params[:csv], "xero_invoices_#{timestamp}.csv") - end - - - def render_report(header, table, create_csv, csv_file_name) + def render_report (header, table, create_csv, csv_file_name) unless create_csv render :html => table else @@ -719,9 +709,7 @@ Spree::Admin::ReportsController.class_eval do :sales_total => { :name => "Sales Total", :description => "Sales Total For All Orders" }, :users_and_enterprises => { :name => "Users & Enterprises", :description => "Enterprise Ownership & Status" }, :order_cycle_management => {:name => "Order Cycle Management", :description => ''}, - :sales_tax => { :name => "Sales Tax", :description => "Sales Tax For Orders" }, - :xero_invoices => { :name => "Xero invoices", :description => 'Invoices for import into Xero' } - + :sales_tax => { :name => "Sales Tax", :description => "Sales Tax For Orders" } } # Return only reports the user is authorized to view. reports.select { |action| can? action, :report } diff --git a/app/views/spree/admin/reports/xero_invoices.html.haml b/app/views/spree/admin/reports/xero_invoices.html.haml deleted file mode 100644 index 0e9598125a..0000000000 --- a/app/views/spree/admin/reports/xero_invoices.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -%table#listing_invoices.index - %thead - %tr - - @report.header.each do |header| - %th= header - %tbody - - @report.table.each do |row| - %tr - - row.each do |column| - %td= column - - if @report.table.empty? - %tr - %td{:colspan => "2"}= t(:none) diff --git a/config/routes.rb b/config/routes.rb index 66805807ce..4621ee4a35 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -134,7 +134,6 @@ Spree::Core::Engine.routes.prepend do match '/admin/orders/bulk_management' => 'admin/orders#bulk_management', :as => "admin_bulk_order_management" match '/admin/reports/products_and_inventory' => 'admin/reports#products_and_inventory', :as => "products_and_inventory_admin_reports", :via => [:get, :post] match '/admin/reports/customers' => 'admin/reports#customers', :as => "customers_admin_reports", :via => [:get, :post] - match '/admin/reports/xero_invoices' => 'admin/reports#xero_invoices', :as => "xero_invoices_admin_reports", :via => [:get, :post] match '/admin', :to => 'admin/overview#index', :as => :admin match '/admin/payment_methods/show_provider_preferences' => 'admin/payment_methods#show_provider_preferences', :via => :get diff --git a/lib/open_food_network/xero_invoices_report.rb b/lib/open_food_network/xero_invoices_report.rb deleted file mode 100644 index 35c3dac73d..0000000000 --- a/lib/open_food_network/xero_invoices_report.rb +++ /dev/null @@ -1,15 +0,0 @@ -module OpenFoodNetwork - class XeroInvoicesReport - def initialize(params={}) - @params = params - end - - def header - %w(*ContactName EmailAddress POAddressLine1 POAddressLine2 POAddressLine3 POAddressLine4 POCity PORegion POPostalCode POCountry *InvoiceNumber Reference *InvoiceDate *DueDate InventoryItemCode *Description *Quantity *UnitAmount Discount *AccountCode *TaxType TrackingName1 TrackingOption1 TrackingName2 TrackingOption2 Currency BrandingTheme) - end - - def table - [[]] - end - end -end diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index 260c1885ce..b1685be6db 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -297,29 +297,4 @@ feature %q{ ].sort end end - - describe "Xero invoices report" do - let!(:enterprise1) { create( :enterprise, owner: create_enterprise_user ) } - let!(:enterprise2) { create( :enterprise, owner: create_enterprise_user ) } - let!(:enterprise3) { create( :enterprise, owner: create_enterprise_user ) } - - before do - enterprise3.enterprise_roles.build( user: enterprise1.owner ).save - - login_to_admin_section - click_link 'Reports' - - click_link 'Xero invoices' - end - - it "shows Xero invoices report" do - rows = find("table#listing_invoices").all("tr") - table = rows.map { |r| r.all("th,td").map { |c| c.text.strip } } - - table.should == [ - %w(*ContactName EmailAddress POAddressLine1 POAddressLine2 POAddressLine3 POAddressLine4 POCity PORegion POPostalCode POCountry *InvoiceNumber Reference *InvoiceDate *DueDate InventoryItemCode *Description *Quantity *UnitAmount Discount *AccountCode *TaxType TrackingName1 TrackingOption1 TrackingName2 TrackingOption2 Currency BrandingTheme), - [] - ] - end - end end