Class: Spree::ShippingCostReport

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

Defined Under Namespace

Classes: Result, ShippingCostDistributionChart

Constant Summary collapse

HEADERS =
{ name: :string, shipping_charge: :integer, revenue: :integer, shipping_cost_percentage: :integer }
SEARCH_ATTRIBUTES =
{ start_date: :start_date, end_date: :end_date }
SORTABLE_ATTRIBUTES =
[]

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



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/reports/spree/shipping_cost_report.rb', line 38

def report_query
  ar_shipping_methods = Arel::Table.new(:spree_shipping_methods)
  ar_subquery_with_rates = Arel::Table.new(:shipment_with_rates)

  Spree::Report::QueryFragments
    .from_subquery(shipment_with_rates, as: 'shipment_with_rates')
    .join(ar_shipping_methods)
    .on(ar_shipping_methods[:id].eq(ar_subquery_with_rates[:shipping_method_id]))
    .project(
      *time_scale_columns,
      ar_shipping_methods[:id],
      'revenue',
      'shipping_charge',
      'shipping_method_id',
      'name'
    )
end