Class: ESA::Account
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ESA::Account
- Extended by:
- Enumerize
- Defined in:
- app/models/esa/account.rb
Overview
The Account class represents accounts in the system. Each account must be subclassed as one of the following types:
TYPE | NORMAL BALANCE | DESCRIPTION
--------------------------------------------------------------------------
Asset | Debit | Resources owned by the Business Entity
Liability | Credit | Debts owed to outsiders
Equity | Credit | Owners rights to the Assets
Revenue | Credit | Increases in owners equity
Expense | Debit | Assets or services consumed in the generation of revenue
Each account can also be marked as a “Contra Account”. A contra account will have it’s normal balance swapped. For example, to remove equity, a “Drawing” account may be created as a contra equity account as follows:
ESA::Equity.create(:name => "Drawing", contra => true)
Direct Known Subclasses
ESA::Accounts::Asset, ESA::Accounts::Equity, ESA::Accounts::Expense, ESA::Accounts::Liability, ESA::Accounts::Revenue
Class Method Summary collapse
Instance Method Summary collapse
-
#balance ⇒ BigDecimal
The balance of the account.
Class Method Details
.namespaced_type(type) ⇒ Object
62 63 64 65 66 67 68 |
# File 'app/models/esa/account.rb', line 62 def self.namespaced_type(type) if valid_type?(type) "ESA::Accounts::#{type}" else type end end |
.valid_type?(type) ⇒ Boolean
58 59 60 |
# File 'app/models/esa/account.rb', line 58 def self.valid_type?(type) type.in? ["Asset", "Liability", "Equity", "Revenue", "Expense"] end |
Instance Method Details
#balance ⇒ BigDecimal
The balance of the account.
48 49 50 51 52 53 54 55 56 |
# File 'app/models/esa/account.rb', line 48 def balance if self.normal_balance.debit? self.amounts.balance elsif self.normal_balance.credit? - self.amounts.balance else nil end end |