Class: Plutus::Entry

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/plutus/entry.rb

Overview

Entries 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 entries

Examples:

cash = Plutus::Asset.find_by_name('Cash')
accounts_receivable = Plutus::Asset.find_by_name('Accounts Receivable')

debit_amount = Plutus::DebitAmount.new(:account => cash, :amount => 1000)
credit_amount = Plutus::CreditAmount.new(:account => accounts_receivable, :amount => 1000)

entry = Plutus::Entry.new(:description => "Receiving payment on an invoice")
entry.debit_amounts << debit_amount
entry.credit_amounts << credit_amount
entry.save

See Also:

Author:

  • Michael Bulat

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(hash) ⇒ Object

Support the deprecated .build method



55
56
57
58
# File 'app/models/plutus/entry.rb', line 55

def self.build(hash)
  ActiveSupport::Deprecation.warn('Plutus::Transaction.build() is deprecated (use new instead)', caller)
  new(hash)
end

Instance Method Details

#default_dateObject

attr_accessible :credits, :debits



49
50
51
52
# File 'app/models/plutus/entry.rb', line 49

def default_date
  todays_date = ActiveRecord.default_timezone == :utc ? Time.now.utc : Time.now
  self.date ||= todays_date
end