module Subledger::Store::Api::Balance

Public Instance Methods

account_balance(args) click to toggle source
# File lib/subledger/store/api/roles/balance.rb, line 5
def account_balance args
  client  = args[:client]
  account = args[:account]
  at      = args[:at].iso8601(3)

  path = Path.for_entity( :anchor => account ) + '/balance?at=' + at

  begin
    response_hash = parse_json(
                      http.get( path ).body )
  rescue Exception => e
    raise BalanceError, "Cannot balance #{account}: #{e}"
  end

  Rest.to_balance response_hash, client
end
journal_entry_balance(args) click to toggle source
# File lib/subledger/store/api/roles/balance.rb, line 22
def journal_entry_balance args
  client        = args[:client]
  journal_entry = args[:journal_entry]

  path = Path.for_entity( :anchor => journal_entry ) + '/balance'

  begin
    response_hash = parse_json( http.get( path ).body )
  rescue Exception => e
    raise BalanceError, "Cannot balance #{journal_entry}: #{e}"
  end

  Rest.to_balance response_hash, client
end