Class: Spree::AdvancedReport::IncrementReport::Units

Inherits:
Spree::AdvancedReport::IncrementReport show all
Defined in:
lib/spree/advanced_report/increment_report/units.rb

Constant Summary

Constants inherited from Spree::AdvancedReport::IncrementReport

INCREMENTS

Instance Attribute Summary

Attributes inherited from Spree::AdvancedReport::IncrementReport

#all_data, #dates, #increments, #total

Attributes inherited from Spree::AdvancedReport

#data, #date_text, #orders, #params, #product, #product_in_taxon, #product_text, #ruportdata, #search, #taxon, #taxon_text, #unfiltered_params

Instance Method Summary collapse

Methods inherited from Spree::AdvancedReport::IncrementReport

#format_total, #generate_ruport_data, #get_bucket, #get_display

Methods inherited from Spree::AdvancedReport

#date_range, #download_url, #order_count, #profit, #revenue, #units

Constructor Details

#initialize(params) ⇒ Units

Returns a new instance of Units.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/spree/advanced_report/increment_report/units.rb', line 14

def initialize(params)
  super(params)
  self.total = 0
  self.orders.each do |order|
    date = {}
    INCREMENTS.each do |type|
      date[type] = get_bucket(type, order.completed_at)
      data[type][date[type]] ||= {
        :value => 0, 
        :display => get_display(type, order.completed_at),
      }
    end
    units = units(order)
    INCREMENTS.each { |type| data[type][date[type]][:value] += units }
    self.total += units
  end

  generate_ruport_data
end

Instance Method Details

#columnObject



6
7
8
# File 'lib/spree/advanced_report/increment_report/units.rb', line 6

def column
  I18n.t("adv_report.increment_report.units.column")
end

#descriptionObject



10
11
12
# File 'lib/spree/advanced_report/increment_report/units.rb', line 10

def description
  I18n.t("adv_report.increment_report.units.description")
end

#nameObject



2
3
4
# File 'lib/spree/advanced_report/increment_report/units.rb', line 2

def name
  I18n.t("adv_report.increment_report.units.name")
end