Sha256: 71e71998d104e62b487fa9cc53f95a8fa6b24a5d06e982cdc45cf74f58e4bc7e
Contents?: true
Size: 703 Bytes
Versions: 11
Compression:
Stored size: 703 Bytes
Contents
module Valuation # # Anything with a :lifetime_memberships column and has_many memberships can use this module. # module LifetimeMemberships extend ActiveSupport::Concern def lifetime_orders orders end # # 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 # 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 end end
Version data entries
11 entries across 11 versions & 1 rubygems