Sha256: f9f651ee975feaff91d282bd18e219d85d171b4297cafc1908883e704e077b47
Contents?: true
Size: 1.44 KB
Versions: 6
Compression:
Stored size: 1.44 KB
Contents
module Plutus # 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*. # # @see http://en.wikipedia.org/wiki/Equity_(finance) Equity # # @author Michael Bulat class Equity < Account # 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 # # @example # >> asset.balance # => #<BigDecimal:103259bb8,'0.2E4',4(12)> # # @return [BigDecimal] The decimal value balance def balance unless contra credits_balance - debits_balance else debits_balance - credits_balance end end # This class method is used to return # the balance of all Equity accounts. # # Contra accounts are automatically subtracted from the balance. # # @example # >> Plutus::Equity.balance # => #<BigDecimal:1030fcc98,'0.82875E5',8(20)> # # @return [BigDecimal] The decimal value balance def self.balance accounts_balance = BigDecimal.new('0') accounts = self.all accounts.each do |equity| unless equity.contra accounts_balance += equity.balance else accounts_balance -= equity.balance end end accounts_balance end end end
Version data entries
6 entries across 6 versions & 1 rubygems