Sha256: 137d178e9f23c9074ab1826729276f4bde46f2e0afc3abd7e82593b3c538754a

Contents?: true

Size: 666 Bytes

Versions: 1

Compression:

Stored size: 666 Bytes

Contents

class Membership < MLS::Model
  self.inheritance_column = nil
  
  has_many :accounts
  has_many :invoices
  has_many :subscriptions
  belongs_to :organization
  belongs_to :billing_contact, class_name: "Account"
  belongs_to :credit_card
  belongs_to :sourced_by, class_name: "Account"
  has_and_belongs_to_many     :invoice_recipients, class_name: 'EmailAddress'
  
  accepts_nested_attributes_for :subscriptions
  
  def rate
    subscriptions.select{|x| !x.ends_at}.map(&:cost).compact.sum
  end
  
  def costs
    (read_attribute(:costs) || {}).with_indifferent_access
  end
  
  def value
    read_attribute(:value) / 100.0 if read_attribute(:value)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mls-1.5.1 lib/mls/membership.rb