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



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

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

#lifetime_valueObject



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

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

#order_countObject



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

def order_count
  spree_orders.complete.count
end