Class: Equity
- Inherits:
-
Account
- Object
- ActiveRecord::Base
- Account
- Equity
- Defined in:
- app/models/equity.rb
Overview
The Equity class is an account type used to represents owners rights to the assets.
Normal Balance
The normal balance on Equity accounts is a Credit.
Class Method Summary (collapse)
-
+ (BigDecimal) balance
This class method is used to return the balance of all Equity accounts.
Instance Method Summary (collapse)
-
- (BigDecimal) balance
The balance of the account.
-
- (BigDecimal) credits_balance
The credit balance for the account.
-
- (BigDecimal) debits_balance
The debit balance for the account.
Methods inherited from Account
Class Method Details
+ (BigDecimal) balance
This class method is used to return the balance of all Equity accounts.
Contra accounts are automatically subtracted from the balance.
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/models/equity.rb', line 70 def self.balance accounts_balance = BigDecimal.new('0') accounts = self.find(:all) accounts.each do |equity| unless equity.contra accounts_balance += equity.balance else accounts_balance -= equity.balance end end accounts_balance end |
Instance Method Details
- (BigDecimal) balance
The balance of the account.
Equity accounts have normal credit balances, so the debits are subtracted from the credits unless this is a contra account, in which credits are subtracted from debits
52 53 54 55 56 57 58 |
# File 'app/models/equity.rb', line 52 def balance unless contra credits_balance - debits_balance else debits_balance - credits_balance end end |
- (BigDecimal) credits_balance
The credit balance for the account.
18 19 20 21 22 23 24 |
# File 'app/models/equity.rb', line 18 def credits_balance credits_balance = BigDecimal.new('0') credit_transactions.each do |credit_transaction| credits_balance = credits_balance + credit_transaction.amount end return credits_balance end |
- (BigDecimal) debits_balance
The debit balance for the account.
33 34 35 36 37 38 39 |
# File 'app/models/equity.rb', line 33 def debits_balance debits_balance = BigDecimal.new('0') debit_transactions.each do |debit_transaction| debits_balance = debits_balance + debit_transaction.amount end return debits_balance end |