Class: Skr::GlAccount
- Defined in:
- lib/skr/models/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 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/models/gl_account.rb', line 25
|
Class Method Details
.default_for(lookup) ⇒ GlAccount
Returns the default account for the key from Configuration.default_gl_accounts.
33 34 35 36 37 |
# File 'lib/skr/models/gl_account.rb', line 33 def self.default_for( lookup ) number = Skr.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.
55 56 57 |
# File 'lib/skr/models/gl_account.rb', line 55 def account_mask number + '%' end |
#balance_for(period, mask = self.account_mask) ⇒ BigDecimal
Returns the balance for a given period.
60 61 62 |
# File 'lib/skr/models/gl_account.rb', line 60 def balance_for( period, mask = self.account_mask ) GlPosting.( period ).matching( account_mask ).sum(:amount) end |
#default_number ⇒ String
Returns the account number combined with the default branch code.
45 46 47 |
# File 'lib/skr/models/gl_account.rb', line 45 def default_number self.number + Skr.config.default_branch_code end |
#number_for_location(location) ⇒ String
Returns the account number combined with location branch code.
40 41 42 |
# File 'lib/skr/models/gl_account.rb', line 40 def number_for_location( location ) self.number + location.gl_branch_code end |