Sha256: b94e6d60531d9854f62a929ac5914b59d764c6bc2d98f6d48206a2b26c0191fd

Contents?: true

Size: 702 Bytes

Versions: 9

Compression:

Stored size: 702 Bytes

Contents

module ESA
  # The Amount class represents debit and credit amounts in the system.
  #
  # @abstract
  #   An amount must be a subclass as either a debit or a credit to be saved to the database. 
  #
  # @author Lenno Nagel, Michael Bulat
  class Amount < ActiveRecord::Base
    attr_accessible :type, :account, :amount, :transaction

    belongs_to :transaction
    belongs_to :account

    validates_presence_of :type, :amount, :transaction, :account

    scope :credits, lambda { where(type: Amounts::Credit) }
    scope :debits, lambda { where(type: Amounts::Debit) }

    def is_credit?
      self.is_a? Amounts::Credit
    end

    def is_debit?
      self.is_a? Amounts::Debit
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
event_sourced_accounting-0.2.6 app/models/esa/amount.rb
event_sourced_accounting-0.2.4 app/models/esa/amount.rb
event_sourced_accounting-0.2.3 app/models/esa/amount.rb
event_sourced_accounting-0.2.2 app/models/esa/amount.rb
event_sourced_accounting-0.1.6 app/models/esa/amount.rb
event_sourced_accounting-0.1.4 app/models/esa/amount.rb
event_sourced_accounting-0.1.3 app/models/esa/amount.rb
event_sourced_accounting-0.1.1 app/models/esa/amount.rb
event_sourced_accounting-0.1.0 app/models/esa/amount.rb