module Aloe::AccountRepository
Public Instance Methods
closed()
click to toggle source
Scope to closed accounts.
@return [ActiveRecord::Relation]
# File lib/aloe/account_repository.rb, line 20 def closed unscoped.with_state('closed') end
currency(currency)
click to toggle source
Scope by currency.
@param [String, Symbol] currency Currency symbol @return [ActiveRecord::Relation]
# File lib/aloe/account_repository.rb, line 8 def currency(currency) where(currency: currency) end
default_scope()
click to toggle source
Default scope excludes closed accounts.
# File lib/aloe/account_repository.rb, line 13 def default_scope where('state != ?', 'closed') end
owner(owner)
click to toggle source
Scope by owner.
@param [ActiveRecord::Base] owner @return [ActiveRecord::Relation]
# File lib/aloe/account_repository.rb, line 28 def owner(owner) where(owner_type: owner.class.model_name.to_s, owner_id: owner.id) end
trial_balance(currency)
click to toggle source
Return the trial balance.
Trial balance is balance of all accounts in the system combined. It should at all times be 0. If it’s not, there is an error in accounts somewhere.
@param [String, Symbol] currency Currency symbol @return [Fixnum] Zero if everything’s fine
# File lib/aloe/account_repository.rb, line 40 def trial_balance(currency) currency(currency).sum :balance end