Sha256: 51d22e1fea36324f24f4af050e9efa986e0f4da703b62e62abc58052caa5462f

Contents?: true

Size: 710 Bytes

Versions: 3

Compression:

Stored size: 710 Bytes

Contents

module Borutus
  # 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 Michael Bulat
  class Amount < ActiveRecord::Base
    belongs_to :entry, :class_name => 'Borutus::Entry'
    belongs_to :account, :class_name => 'Borutus::Account'

    validates_presence_of :type, :amount, :entry, :account
    # attr_accessible :account, :account_name, :amount, :entry

    delegate :name, to: :account, prefix: true, allow_nil: true

    # Assign an account by name
    def account_name=(name)
      self.account = Account.find_by_name!(name)
    end

    protected
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
borutus-0.2.1 app/models/borutus/amount.rb
borutus-0.2.0 app/models/borutus/amount.rb
borutus-0.1.0 app/models/borutus/amount.rb