Class: Spree::PromotionalCostReport

Inherits:
Report
  • Object
show all
Defined in:
app/reports/spree/promotional_cost_report.rb

Defined Under Namespace

Classes: PromotionalCostChart, Result, UsageCountChart

Constant Summary collapse

DEFAULT_SORTABLE_ATTRIBUTE =
:promotion_name
HEADERS =
{ promotion_name: :string, usage_count: :integer, promotion_discount: :integer, promotion_code: :string, promotion_start_date: :date, promotion_end_date: :date }
SEARCH_ATTRIBUTES =
{ start_date: :promotion_created_from, end_date: :promotion_created_till }
SORTABLE_ATTRIBUTES =
[:promotion_name, :usage_count, :promotion_discount, :promotion_code, :promotion_start_date, :promotion_end_date]

Constants inherited from Report

Report::TIME_SCALES

Instance Attribute Summary

Attributes inherited from Report

#current_page, #paginate, #records_per_page, #reporting_period, #search, #sortable_attribute, #sortable_type, #total_records

Instance Method Summary collapse

Methods inherited from Report

#active_record_sort, deeplink, #deeplink_properties, #generate, #get_results, #header_sorted?, #initialize, #name, #paginated?, #pagination_required?, #set_sortable_attributes, #time_scale_columns, #time_scale_columns_to_s, #time_scale_selects, #total_pages

Constructor Details

This class inherits a constructor from Spree::Report

Instance Method Details

#report_queryObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/reports/spree/promotional_cost_report.rb', line 49

def report_query
  Spree::Report::QueryFragments
    .from_subquery(eligible_promotions)
    .group(*time_scale_columns, :promotion_id, :promotion_name,
           :promotion_code, :promotion_start_date, :promotion_end_date)
    .order(*time_scale_columns_to_s)
    .project(
      *time_scale_columns,
      'promotion_name',
      'promotion_code',
      'promotion_start_date',
      'promotion_end_date',
      'SUM(promotion_discount)  as promotion_discount',
      'COUNT(promotion_id)      as usage_count',
      'promotion_id'
    )
end