Module: Valuation::LifetimeMemberships

Extended by:
ActiveSupport::Concern
Included in:
Person
Defined in:
app/models/valuation/lifetime_memberships.rb

Overview

Anything with a :lifetime_memberships column and has_many memberships can use this module.

Instance Method Summary collapse

Instance Method Details

#calculate_lifetime_membershipsObject

Calculate the lifetime memberships of this model by summing the price of all memberships attached to orders attached to this person. Save the memberships in lifetime_memberships. Return the total



18
19
20
21
22
# File 'app/models/valuation/lifetime_memberships.rb', line 18

def calculate_lifetime_memberships
  self.lifetime_memberships = Item.membership.where(:order_id => lifetime_orders).sum(Item.total_price_sql_sum).to_i
  self.save(:validate => false)
  self.lifetime_memberships
end

#lifetime_ordersObject



9
10
11
# File 'app/models/valuation/lifetime_memberships.rb', line 9

def lifetime_orders
  orders
end