Sha256: a253f085018feeaee52745f2b2ea17bf0e598d40652b234000c9cd9afe301dfb

Contents?: true

Size: 431 Bytes

Versions: 72

Compression:

Stored size: 431 Bytes

Contents

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

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

    def order_count
      BigDecimal(spree_orders.complete.count)
    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

72 entries across 72 versions & 2 rubygems

Version Path
solidus_core-1.1.0.pre2 app/models/concerns/spree/user_reporting.rb
solidus_core-1.1.0.pre1 app/models/concerns/spree/user_reporting.rb
solidus_core-1.1.0.beta1 app/models/concerns/spree/user_reporting.rb
solidus_core-1.0.2 app/models/concerns/spree/user_reporting.rb
solidus_core-1.0.1 app/models/concerns/spree/user_reporting.rb
solidus_core-1.0.0 app/models/concerns/spree/user_reporting.rb
solidus_core-1.0.0.rc2 app/models/concerns/spree/user_reporting.rb
solidus_core-1.0.0.rc1 app/models/concerns/spree/user_reporting.rb
solidus_core-1.0.0.pre3 app/models/concerns/spree/user_reporting.rb
solidus_core-1.0.0.pre2 app/models/concerns/spree/user_reporting.rb
solidus_core-1.0.0.pre app/models/concerns/spree/user_reporting.rb
spree_core-3.0.0.rc1 app/models/concerns/spree/user_reporting.rb