Sha256: a9ac88ade4fd9afc71619a5e83e47bbdf7ee24762f6e835e48dbed04940676e8

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

class Spree::AdvancedReport::IncrementReport::Revenue < Spree::AdvancedReport::IncrementReport
  def name
    I18n.t("adv_report.increment_report.revenue.name")
  end

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

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

  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 || order.updated_at))
        data[type][date[type]] ||= {
          :value => 0,
          :display => get_display(type, (order.completed_at || order.updated_at)),
        }
      end
      rev = revenue(order)
      INCREMENTS.each { |type| data[type][date[type]][:value] += rev }
      self.total += rev
    end

    generate_ruport_data

    INCREMENTS.each { |type| ruportdata[type].replace_column(name) { |r| "$%0.2f" % r[name] } }
  end

  def format_total
    '$' + ((self.total*100).round.to_f / 100).to_s
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_advanced_reporting-2.1.0 lib/spree/advanced_report/increment_report/revenue.rb