Module: Spree::UserReporting

Defined in:
app/models/concerns/spree/user_reporting.rb

Instance Method Summary collapse

Instance Method Details

#average_order_valueObject



15
16
17
18
19
20
21
# File 'app/models/concerns/spree/user_reporting.rb', line 15

def average_order_value
  if order_count.to_i > 0
    lifetime_value / order_count
  else
    BigDecimal("0.00")
  end
end

#display_average_order_valueObject



23
24
25
# File 'app/models/concerns/spree/user_reporting.rb', line 23

def display_average_order_value
  Spree::Money.new(average_order_value)
end

#display_lifetime_valueObject



7
8
9
# File 'app/models/concerns/spree/user_reporting.rb', line 7

def display_lifetime_value
  Spree::Money.new(lifetime_value)
end

#lifetime_valueObject



3
4
5
# File 'app/models/concerns/spree/user_reporting.rb', line 3

def lifetime_value
  spree_orders.complete.pluck(:total).sum
end

#order_countObject



11
12
13
# File 'app/models/concerns/spree/user_reporting.rb', line 11

def order_count
  BigDecimal(spree_orders.complete.count)
end