full depth accounts list
This commit is contained in:
parent
2474f8c570
commit
85ba7103d2
1 changed files with 8 additions and 6 deletions
|
@ -20,31 +20,33 @@ module Ledger
|
||||||
|
|
||||||
def accounts( depth = 9999 )
|
def accounts( depth = 9999 )
|
||||||
accounts = run( '', 'accounts' )
|
accounts = run( '', 'accounts' )
|
||||||
.split( "\n" )
|
.split( "\n" )
|
||||||
.map do |a|
|
.map do |a|
|
||||||
a.split( ':' )
|
a.split( ':' )
|
||||||
.each_slice( depth )
|
.each_slice( depth )
|
||||||
.to_a.first
|
.to_a.first
|
||||||
end.uniq
|
end.uniq
|
||||||
|
|
||||||
top_level_accounts = accounts.map(&:first).uniq.map { |account| [ account ] }
|
accounts.map(&:length).max.times do |i|
|
||||||
|
accounts += accounts.map { |acc| acc.first( i ) }
|
||||||
|
end
|
||||||
|
|
||||||
( accounts + top_level_accounts ).sort
|
accounts.uniq.sort.reject { |a| a.empty? }
|
||||||
end
|
end
|
||||||
|
|
||||||
def dates_salaries( category = 'salaire' )
|
def dates_salaries( category = 'salaire' )
|
||||||
CSV.parse( run( '', 'csv', category ) )
|
CSV.parse( run( '', 'csv', category ) )
|
||||||
.map do |row|
|
.map do |row|
|
||||||
Date.parse row[ 0 ]
|
Date.parse row[ 0 ]
|
||||||
end
|
end
|
||||||
.uniq
|
.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def register( period = nil, categories = '' )
|
def register( period = nil, categories = '' )
|
||||||
period = period.nil? ? '' : "-p '#{period}'"
|
period = period.nil? ? '' : "-p '#{period}'"
|
||||||
|
|
||||||
CSV.parse( run( "--no-revalued --exchange '#{CURRENCY}' #{period}", 'csv', categories ) )
|
CSV.parse( run( "--no-revalued --exchange '#{CURRENCY}' #{period}", 'csv', categories ) )
|
||||||
.map do |row|
|
.map do |row|
|
||||||
{ date: row[ 0 ],
|
{ date: row[ 0 ],
|
||||||
payee: row[ 2 ],
|
payee: row[ 2 ],
|
||||||
account: row[ 3 ],
|
account: row[ 3 ],
|
||||||
|
|
Loading…
Add table
Reference in a new issue