14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/controllers/admin/reports_controller.rb', line 14
def sales_total
params[:search] = {} unless params[:search]
if params[:search][:created_at_greater_than].blank?
params[:search][:created_at_greater_than] = Time.zone.now.beginning_of_month
else
params[:search][:created_at_greater_than] = Time.zone.parse(params[:search][:created_at_greater_than]).beginning_of_day rescue Time.zone.now.beginning_of_month
end
if params[:search] && !params[:search][:created_at_less_than].blank?
params[:search][:created_at_less_than] =
Time.zone.parse(params[:search][:created_at_less_than]).end_of_day rescue ""
end
if params[:search].delete(:completed_at_is_not_null) == "1"
params[:search][:completed_at_is_not_null] = true
else
params[:search][:completed_at_is_not_null] = false
end
params[:search][:meta_sort] ||= "created_at.desc"
@search = Order.metasearch(params[:search])
@orders = @search
@item_total = @search.sum(:item_total)
@adjustment_total = @search.sum(:adjustment_total)
@sales_total = @search.sum(:total)
respond_with
end
|