Class: Skr::GlAccount
- Defined in:
- lib/skr/gl_account.rb
Overview
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.
Constant Summary collapse
- DEFAULT_ACCOUNTS =
{}
Instance Attribute Summary collapse
-
#description ⇒ Object
A short description of the GL Account.
Class Method Summary collapse
-
.default_for(lookup) ⇒ GlAccount
The default account for the key from Core::Configuration.default_gl_accounts.
Instance Method Summary collapse
-
#account_mask ⇒ String
The account number suitable for querying all branches.
-
#balance_for(period, mask = self.account_mask) ⇒ BigDecimal
The balance for a given period.
-
#default_number ⇒ String
The account number combined with the default branch code.
-
#number_for_location(location) ⇒ String
The account number combined with location branch code.
-
#trial_balance ⇒ BigDecimal
The balance for the current period.
Instance Attribute Details
#description ⇒ Object
A short description of the GL Account
|
# File 'lib/skr/gl_account.rb', line 15
|
Class Method Details
.default_for(lookup) ⇒ GlAccount
Returns the default account for the key from Core::Configuration.default_gl_accounts.
23 24 25 26 27 |
# 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 |
Instance Method Details
#account_mask ⇒ String
Returns the account number suitable for querying all branches.
45 46 47 |
# File 'lib/skr/gl_account.rb', line 45 def account_mask number + '%' end |
#balance_for(period, mask = self.account_mask) ⇒ BigDecimal
Returns the balance for a given period.
50 51 52 |
# 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 ⇒ String
Returns the account number combined with the default branch code.
35 36 37 |
# File 'lib/skr/gl_account.rb', line 35 def default_number self.number + Skr::Core.config.default_branch_code end |
#number_for_location(location) ⇒ String
Returns the account number combined with location branch code.
30 31 32 |
# File 'lib/skr/gl_account.rb', line 30 def number_for_location( location ) self.number + location.gl_branch_code end |
#trial_balance ⇒ BigDecimal
Returns The balance for the current period.
40 41 42 |
# File 'lib/skr/gl_account.rb', line 40 def trial_balance balance_for( GlPeriod.current ) end |