Module: Spree::UserReporting

Extended by:
DisplayMoney
Included in:
UserMethods
Defined in:
app/models/concerns/spree/user_reporting.rb

Instance Method Summary collapse

Methods included from DisplayMoney

money_methods

Instance Method Details

#average_order_valueObject


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

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

#lifetime_valueObject


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

def lifetime_value
  orders.complete.sum(:total)
end

#order_countObject


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

def order_count
  BigDecimal(orders.complete.size)
end