Sha256: e5619ad0366a65919fef28a3286001cbcbd1beda17dcfa8a843c0a86e7070eaf

Contents?: true

Size: 412 Bytes

Versions: 43

Compression:

Stored size: 412 Bytes

Contents

module Spree
  module UserReporting
    extend DisplayMoney
    money_methods :lifetime_value, :average_order_value

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

    def order_count
      BigDecimal(orders.complete.size)
    end

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

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
spree_core-3.2.9 app/models/concerns/spree/user_reporting.rb
spree_core-3.1.14 app/models/concerns/spree/user_reporting.rb
spree_core-3.3.6 app/models/concerns/spree/user_reporting.rb
spree_core-3.2.8 app/models/concerns/spree/user_reporting.rb
spree_core-3.1.13 app/models/concerns/spree/user_reporting.rb
spree_core-3.3.5 app/models/concerns/spree/user_reporting.rb
spree_core-3.3.4 app/models/concerns/spree/user_reporting.rb
spree_core-3.2.7 app/models/concerns/spree/user_reporting.rb
spree_core-3.1.12 app/models/concerns/spree/user_reporting.rb
spree_core-3.3.3 app/models/concerns/spree/user_reporting.rb
spree_core-3.2.6 app/models/concerns/spree/user_reporting.rb
spree_core-3.1.11 app/models/concerns/spree/user_reporting.rb
spree_core-3.1.10 app/models/concerns/spree/user_reporting.rb
spree_core-3.3.2 app/models/concerns/spree/user_reporting.rb
spree_core-3.2.5 app/models/concerns/spree/user_reporting.rb
spree_core-3.1.9 app/models/concerns/spree/user_reporting.rb
spree_core-3.3.1 app/models/concerns/spree/user_reporting.rb
spree_core-3.2.4 app/models/concerns/spree/user_reporting.rb
spree_core-3.1.8 app/models/concerns/spree/user_reporting.rb
spree_core-3.3.0 app/models/concerns/spree/user_reporting.rb