Class: Account Abstract
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Account
- Defined in:
- app/models/account.rb
Overview
An account must be a subclass to be saved to the database. The Account class has a singleton method trial_balance to calculate the balance on all Accounts.
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:
Equity.create(:name => "Drawing", contra => true)
At all times the balance of all accounts should conform to the "accounting equation"
Assets = Liabilties + Owner's Equity
Each sublclass account acts as it’s own ledger. See the individual subclasses for a description.
Class Method Summary (collapse)
-
+ (BigDecimal) trial_balance
The trial balance of all accounts in the system.
Class Method Details
+ (BigDecimal) trial_balance
The trial balance of all accounts in the system. This should always equal zero, otherwise there is an error in the system.
49 50 51 52 53 54 55 |
# File 'app/models/account.rb', line 49 def self.trial_balance unless self.new.class == Account raise(NoMethodError, "undefined method 'trial_balance'") else Asset.balance - (Liability.balance + Equity.balance + Revenue.balance - Expense.balance) end end |