Sha256: 8c10210da950ecb7457bc8fdc3e960a8759d29573b30cce41ad5a478c8354f85

Contents?: true

Size: 412 Bytes

Versions: 9

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

9 entries across 9 versions & 1 rubygems

Version Path
spree_core-3.4.6 app/models/concerns/spree/user_reporting.rb
spree_core-3.4.5 app/models/concerns/spree/user_reporting.rb
spree_core-3.4.4 app/models/concerns/spree/user_reporting.rb
spree_core-3.4.3 app/models/concerns/spree/user_reporting.rb
spree_core-3.4.2 app/models/concerns/spree/user_reporting.rb
spree_core-3.4.1 app/models/concerns/spree/user_reporting.rb
spree_core-3.4.0 app/models/concerns/spree/user_reporting.rb
spree_core-3.4.0.rc2 app/models/concerns/spree/user_reporting.rb
spree_core-3.4.0.rc1 app/models/concerns/spree/user_reporting.rb