Sha256: e5a1d504de88898db87ab101bbc84420c8ce5d95f4941467cfb93a9b9d4d600e

Contents?: true

Size: 419 Bytes

Versions: 14

Compression:

Stored size: 419 Bytes

Contents

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

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

    def order_count
      BigDecimal(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

14 entries across 14 versions & 1 rubygems

Version Path
spree_core-3.0.10 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.9 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.8 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.7 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.6.1 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.6 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.5 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.4 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.3 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.2 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.1 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.0 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.0.rc4 app/models/concerns/spree/user_reporting.rb
spree_core-3.0.0.rc3 app/models/concerns/spree/user_reporting.rb