oops
This commit is contained in:
parent
95fcd781a1
commit
7d5f893175
1 changed files with 14 additions and 0 deletions
|
@ -50,6 +50,20 @@ module Ledger
|
|||
end
|
||||
end
|
||||
|
||||
def balance( cleared = false, depth = nil, period = nil, categories = '' )
|
||||
period = period.nil? ? '' : "-p '#{period}'"
|
||||
depth = depth.nil? ? '' : "--depth #{depth}"
|
||||
operation = cleared ? 'cleared' : 'balance'
|
||||
run( "--flat --no-total --exchange '#{CURRENCY}' #{period} #{depth}", operation, categories )
|
||||
.split( "\n" )
|
||||
.map do |line|
|
||||
line_array = line.split( "#{CURRENCY}" )
|
||||
|
||||
{ account: line_array[ 1 ].strip,
|
||||
amount: line_array[ 0 ].tr( SEPARATOR, '.' ).to_f }
|
||||
end
|
||||
end
|
||||
|
||||
def cleared
|
||||
run( "--flat --no-total --exchange '#{CURRENCY}'", 'cleared', 'Assets Equity' )
|
||||
.split( "\n" )
|
||||
|
|
Loading…
Add table
Reference in a new issue