Sha256: 3ec00cab90b4ee208fb0411d781b1d22c52a2693cf722fe9199a6934e817b32d

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

# Transactions are the recording of debits and credits to various accounts. 
# This table can be thought of as a traditional accounting Journal. 
#
# Posting to a Ledger can be considered to happen automatically, since 
# Accounts have the reverse 'has_many' relationship to either it's credit or
# debit transactions 
#
# @example
#   cash = Asset.find_by_name('Cash')
#   accounts_receivable = Asset.find_by_name('Accounts Receivable')
#
#   Transaction.create(:description => "Receiving payment on an invoice" , 
#                      :debit_account => cash, 
#                      :credit_account => accounts_receivable, 
#                      :amount => 1000)
#
# @see http://en.wikipedia.org/wiki/Journal_entry Journal Entry
# 
# @author Michael Bulat
class Transaction < ActiveRecord::Base
  belongs_to :commercial_document, :polymorphic => true
  belongs_to :credit_account, :class_name => "Account"
  belongs_to :debit_account, :class_name => "Account"
  
  validates_presence_of :credit_account, :debit_account, :amount, :description
  validates_associated :credit_account, :debit_account
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
blawzoo-plutus-0.5.3 app/models/transaction.rb
plutus-0.5.2 app/models/transaction.rb
plutus-0.5.1 app/models/transaction.rb
plutus-0.4.2 app/models/transaction.rb