Module: Generalis

Defined in:
lib/generalis.rb,
lib/generalis/link.rb,
lib/generalis/asset.rb,
lib/generalis/debit.rb,
lib/generalis/entry.rb,
lib/generalis/config.rb,
lib/generalis/credit.rb,
lib/generalis/account.rb,
lib/generalis/expense.rb,
lib/generalis/revenue.rb,
lib/generalis/version.rb,
lib/generalis/linkable.rb,
lib/generalis/liability.rb,
lib/generalis/accountable.rb,
lib/generalis/transaction.rb,
lib/generalis/transaction/dsl.rb,
lib/generalis/transaction/links.rb,
lib/rspec/helpers/format_helper.rb,
lib/generalis/transaction/preparation.rb,
lib/generalis/transaction/double_entry.rb,
lib/rspec/helpers/resolve_amount_helper.rb,
lib/rspec/helpers/resolve_account_helper.rb,
lib/generators/generalis/install_generator.rb,
lib/generators/generalis/migrations_generator.rb,
lib/generators/generalis/transaction_generator.rb

Defined Under Namespace

Modules: Accountable, Generators, Linkable, RSpec Classes: Account, Asset, Config, Credit, Debit, Entry, Expense, Liability, Link, Revenue, Transaction

Constant Summary collapse

VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.configConfig

Returns:



39
40
41
# File 'lib/generalis.rb', line 39

def self.config
  @config ||= Config.new.freeze
end

.configure {|config| ... } ⇒ void

This method returns an undefined value.

Yields:



44
45
46
47
48
49
# File 'lib/generalis.rb', line 44

def self.configure
  config = Config.new
  yield(config)

  @config = config.freeze
end

.table_name_prefixString

Returns:

  • (String)


52
53
54
# File 'lib/generalis.rb', line 52

def self.table_name_prefix
  config.table_name_prefix
end

.trial_balancesHash{String => Integer}

Returns:

  • (Hash{String => Integer})


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/generalis.rb', line 26

def self.trial_balances
  subquery = Entry
    .group(:account_id, :currency)
    .select(Entry.arel_table[:id].maximum)

  Entry
    .joins(:account)
    .where(id: subquery)
    .group(:currency)
    .sum((Entry.arel_table[:balance_after_cents] * Account.arel_table[:coefficient]))
end