Module: Spree::UserReporting
- Defined in:
- app/models/concerns/spree/user_reporting.rb
Instance Method Summary collapse
- #average_order_value ⇒ Object
- #display_average_order_value ⇒ Object
- #display_lifetime_value ⇒ Object
- #lifetime_value ⇒ Object
- #order_count ⇒ Object
Instance Method Details
#average_order_value ⇒ Object
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_value ⇒ Object
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_value ⇒ Object
7 8 9 |
# File 'app/models/concerns/spree/user_reporting.rb', line 7 def display_lifetime_value Spree::Money.new(lifetime_value) end |
#lifetime_value ⇒ Object
3 4 5 |
# File 'app/models/concerns/spree/user_reporting.rb', line 3 def lifetime_value spree_orders.complete.pluck(:total).sum end |
#order_count ⇒ Object
11 12 13 |
# File 'app/models/concerns/spree/user_reporting.rb', line 11 def order_count BigDecimal(spree_orders.complete.count) end |