Module: Subledger::Store::Api::Balance

Included in:
Store
Defined in:
lib/subledger/store/api/roles/balance.rb

Instance Method Summary collapse

Instance Method Details

#account_balance(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/subledger/store/api/roles/balance.rb', line 5

def  args
  client  = args[:client]
   = args[:account]
  at      = args[:at].iso8601(3)

  path = Path.for_entity( :anchor =>  ) + '/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) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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