Sha256: 64aa1fe75285a5e87f095dddcaf1fb829b4ab554bbb31908ddaa7aa45798a9fa
Contents?: true
Size: 1.44 KB
Versions: 6
Compression:
Stored size: 1.44 KB
Contents
module Plutus # The Revenue class is an account type used to represents increases in owners equity. # # === Normal Balance # The normal balance on Revenue accounts is a *Credit*. # # @see http://en.wikipedia.org/wiki/Revenue Revenue # # @author Michael Bulat class Revenue < Account # The balance of the account. # # Revenue 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 Revenue accounts. # # Contra accounts are automatically subtracted from the balance. # # @example # >> Plutus::Revenue.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 |revenue| unless revenue.contra accounts_balance += revenue.balance else accounts_balance -= revenue.balance end end accounts_balance end end end
Version data entries
6 entries across 6 versions & 1 rubygems