class Skr::GlAccount
A GlAccount
*(short for General Ledger Account)* is used to define each class of items for which money or the equivalent is spent or received.
Constants
- DEFAULT_ACCOUNTS
@private
Public Class Methods
default_for( lookup )
click to toggle source
@return [GlAccount] the default account for the key from {Skr::Core::Configuration.default_gl_accounts}
# File lib/skr/gl_account.rb, line 23 def self.default_for( lookup ) number = Core.config.default_gl_accounts[ lookup ] raise RuntimeError.new("Unkown GL default account lookup code: {lookup}") unless number DEFAULT_ACCOUNTS[ lookup ] ||= GlAccount.find_by_number( number ) end
Public Instance Methods
account_mask()
click to toggle source
@return [String] the account number suitable for querying all branches
# File lib/skr/gl_account.rb, line 45 def account_mask number + '%' end
balance_for( period, mask = self.account_mask )
click to toggle source
@return [BigDecimal] the balance for a given period
# File lib/skr/gl_account.rb, line 50 def balance_for( period, mask = self.account_mask ) GlPosting.matching( period, account_mask ).sum(:amount) end
default_number()
click to toggle source
@return [String] the account number combined with the default branch code
# File lib/skr/gl_account.rb, line 35 def default_number self.number + Skr::Core.config.default_branch_code end
number_for_location( location )
click to toggle source
@return [String] the account number combined with location branch code
# File lib/skr/gl_account.rb, line 30 def number_for_location( location ) self.number + location.gl_branch_code end
trial_balance()
click to toggle source
@return [BigDecimal] The balance for the current period
# File lib/skr/gl_account.rb, line 40 def trial_balance balance_for( GlPeriod.current ) end