Class: Spina::Shop::Admin::ReportsController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/spina/shop/admin/reports_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/spina/shop/admin/reports_controller.rb', line 9

def create
  start_date = Date.parse(params[:start_date])
  end_date = Date.parse(params[:end_date])
  case params[:report_type]
  when "invoices"
    invoice_ids = Invoice.where(date: start_date..end_date).ids
    InvoiceReportJob.perform_later(invoice_ids, params[:email])
  when "payments"
    order_ids = Order.paid.where(paid_at: start_date..end_date).ids
    PaymentsReportJob.perform_later(order_ids, params[:email])
  end

  flash[:success] = t('spina.shop.reports.start_exporting_html')
  redirect_to spina.shop_admin_reports_path
end

#indexObject



6
7
# File 'app/controllers/spina/shop/admin/reports_controller.rb', line 6

def index
end