treasurer 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/treasurer/accounts.rb +27 -4
- data/lib/treasurer/report.rb +69 -21
- data/treasurer.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75e0d7fbb9f8e3d3e7257b32b95d02551c86d734
|
4
|
+
data.tar.gz: acfd855c6aba173967f3ac4ad2f5f834f6d72686
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8bd30fa88d03684297b4cc00432d2ee64efcd130bdd0bc4efcf964275acc1cc6fccef878c7e711f6675bb16253eaa5044f4631a43f1dc0508c1cb682c7a478d
|
7
|
+
data.tar.gz: 65914ce5e0540c566aad1d9b8dab06fd8ce2e672789a8472ac70a9fc5dbd27da54c13b84b5631fc2e75278456e3724fb44e77870bee5bffda7981f4f95a66682
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
data/lib/treasurer/accounts.rb
CHANGED
@@ -96,7 +96,7 @@ class Treasurer::Reporter
|
|
96
96
|
:Expense
|
97
97
|
end
|
98
98
|
end
|
99
|
-
def red_line(date)
|
99
|
+
def red_line(date=@reporter.today)
|
100
100
|
if Treasurer::LocalCustomisations.instance_methods.include? :red_line
|
101
101
|
val = super(name, date)
|
102
102
|
if rc = @reporter.report_currency and rc != @original_currency
|
@@ -121,6 +121,18 @@ class Treasurer::Reporter
|
|
121
121
|
def has_balance?
|
122
122
|
not @runs.find{|r| not r.has_balance?}
|
123
123
|
end
|
124
|
+
def available(date = @reporter.today)
|
125
|
+
case type
|
126
|
+
when :Asset, :Equity
|
127
|
+
b = balance
|
128
|
+
b - red_line
|
129
|
+
when :Liability
|
130
|
+
b = balance
|
131
|
+
red_line - b
|
132
|
+
else
|
133
|
+
nil
|
134
|
+
end
|
135
|
+
end
|
124
136
|
def balance(date = @reporter.today, options={})
|
125
137
|
@balance_cache ||= {}
|
126
138
|
if b = @balance_cache[[date,options]]
|
@@ -316,9 +328,19 @@ EOF
|
|
316
328
|
kit.data[4].gp.with = "l lw 5 dt 2 lc rgb 'black' "
|
317
329
|
kit.gp.key = ' bottom left '
|
318
330
|
kit.gp.key = ' rmargin samplen 2'
|
331
|
+
kit.gp.decimalsign = 'locale "en_GB.UTF-8"'
|
332
|
+
|
333
|
+
#bal, avail = balance, available
|
334
|
+
|
335
|
+
if avail = available
|
336
|
+
kit.gp.label = [
|
337
|
+
%[ "Balance \\n#{balance}\\n\\nAvailable\\n#{avail}" at screen 0.95, screen 0.5 right],
|
338
|
+
]
|
339
|
+
end
|
319
340
|
|
320
341
|
#(p kit; STDIN.gets) if name == :LloydsCreditCard
|
321
342
|
CodeRunner::Budget.kit_time_format_x(kit)
|
343
|
+
kit.gp.format.push %[y "%'.2f"]
|
322
344
|
size = case type
|
323
345
|
when :Equity
|
324
346
|
"4.0in,4.0in"
|
@@ -327,8 +349,9 @@ EOF
|
|
327
349
|
end
|
328
350
|
|
329
351
|
fork do
|
330
|
-
(kit).gnuplot_write("#{name_c_file}
|
331
|
-
%
|
352
|
+
(kit).gnuplot_write("#{name_c_file}_balance2.eps", size: size) #, latex: true)
|
353
|
+
system %[ps2epsi #{name_c_file}_balance2.eps #{name_c_file}_balance.eps]
|
354
|
+
system %[epstopdf #{name_c_file}_balance.eps]
|
332
355
|
end
|
333
356
|
#%x[epstopdf #{name}_balance.eps]
|
334
357
|
end
|
@@ -356,7 +379,7 @@ EOF
|
|
356
379
|
def name
|
357
380
|
:Equity
|
358
381
|
end
|
359
|
-
def red_line(date)
|
382
|
+
def red_line(date=@reporter.today)
|
360
383
|
@accounts.map{|acc|
|
361
384
|
case acc.type
|
362
385
|
when :Asset
|
data/lib/treasurer/report.rb
CHANGED
@@ -188,6 +188,7 @@ class Treasurer
|
|
188
188
|
currency_list.each do |currency|
|
189
189
|
report << discretionary_account_table(currency)
|
190
190
|
end
|
191
|
+
report << available_balances_table
|
191
192
|
report << account_balance_graphs
|
192
193
|
report << expense_account_summary
|
193
194
|
report << account_expenditure_graphs
|
@@ -200,7 +201,7 @@ class Treasurer
|
|
200
201
|
report << footer
|
201
202
|
|
202
203
|
File.open('report.tex', 'w'){|f| f.puts report}
|
203
|
-
Process.
|
204
|
+
Process.waitall
|
204
205
|
system "lualatex report.tex && lualatex report.tex"
|
205
206
|
end
|
206
207
|
def account_summaries
|
@@ -240,11 +241,10 @@ EOF
|
|
240
241
|
end
|
241
242
|
def expense_account_summary
|
242
243
|
<<EOF
|
243
|
-
\\section{Expense and Income
|
244
|
-
\\subsection{
|
245
|
-
\\subsection{Expense}
|
244
|
+
\\section{Expense and Income Details}
|
245
|
+
\\subsection{Expense totals for #@days_before-day Budget Period}
|
246
246
|
#{expense_pie_charts_by_currency('accountperiod_expense', @expense_accounts){|r| r.days_ago(@today) < @days_before}}
|
247
|
-
\\subsection{Income}
|
247
|
+
\\subsection{Income totals for #@days_before-day Budget Period}
|
248
248
|
#{expense_pie_charts_by_currency('accountperiod_income', @accounts.find_all{|acc| acc.type==:Income}){|r| r.days_ago(@today) < @days_before}}
|
249
249
|
\\subsection{Expense Account Breakdown}
|
250
250
|
#{@expense_accounts.find_all{|exaccount| exaccount.should_report?}.map{|exaccount|
|
@@ -343,13 +343,20 @@ EOF
|
|
343
343
|
kit.gp.grid = "ytics mytics lw 2,lw 1"
|
344
344
|
kit.xlabel = nil
|
345
345
|
kit.ylabel = nil
|
346
|
+
kit.gp.decimalsign = 'locale "en_GB.UTF-8"'
|
347
|
+
kit.gp.format = [%["%'.2f"]]
|
346
348
|
i = -1
|
347
349
|
kit.gp.xtics = "(#{labels.map{|l| %["#{l}" #{i+=1}]}.join(', ')}) rotate by 90 right"
|
348
350
|
pp ['kit222', kit, labels]
|
349
351
|
fork do
|
350
352
|
|
351
353
|
kit.gp.key = "off"
|
352
|
-
kit.gnuplot_write("#{name}.eps", size: "#{[[labels.size.to_f/4.5, 4.5].min, 1.0].max}in,4.5in")
|
354
|
+
kit.gnuplot_write("#{name}2.eps", size: "#{[[labels.size.to_f/4.5, 4.5].min, 1.0].max}in,4.5in")
|
355
|
+
system %[ps2epsi #{name}2.eps #{name}.eps]
|
356
|
+
system %[epstopdf #{name}.eps]
|
357
|
+
|
358
|
+
end
|
359
|
+
fork do
|
353
360
|
kit.gp.key = "tmargin"
|
354
361
|
kit.gp.border = "unset"
|
355
362
|
kit.gp.xtics = "unset"
|
@@ -363,13 +370,13 @@ EOF
|
|
363
370
|
#kit.gp.style = "fill empty noborder"
|
364
371
|
#kit.gp.yrange = "[-10:10]"
|
365
372
|
kit.gnuplot_write("#{name}_key.eps", size: "4.0in,1.5in")
|
366
|
-
%
|
373
|
+
system %[convert -density 500 #{name}_key.eps -resize 4000 -bordercolor white -border 20x20 -background white -flatten -trim +repage #{name}_key.pdf]
|
367
374
|
#%x[convert -density 500 #{name}.eps -resize 4000 -bordercolor white -border 20x20 -background white -flatten -trim +repage #{name}.pdf]
|
368
375
|
end
|
369
376
|
|
370
377
|
#"\\begin{center}\\includegraphics[width=3.0in]{#{name}.eps}\\vspace{1em}\\end{center}"
|
371
378
|
#"\\begin{center}\\includegraphics[width=0.9\\textwidth]{#{name}.eps}\\vspace{1em}\\end{center}"
|
372
|
-
"\\myfigurerot{#{name}.
|
379
|
+
"\\myfigurerot{#{name}.pdf}{#{name}_key.pdf}{270}"
|
373
380
|
end
|
374
381
|
def get_in_limit_discretionary_account_factor(currency)
|
375
382
|
@projected_account_factor = 1.0
|
@@ -421,17 +428,48 @@ EOF
|
|
421
428
|
\\section{Discretionary Budget Summary (#{currency})}
|
422
429
|
\\begin{tabulary}{0.9\\textwidth}{ R | r r r r }
|
423
430
|
Budget & Average & Projection & Limit & Stable \\\\
|
424
|
-
|
431
|
+
\\hline\\Tstrut
|
432
|
+
#{rows =
|
425
433
|
discretionary_accounts.map{|account, info|
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
434
|
+
[
|
435
|
+
account.name_c,
|
436
|
+
account.average,
|
437
|
+
account.projection,
|
438
|
+
account.projection * @in_limit_discretionary_account_factors[currency],
|
439
|
+
account.projection * @stable_discretionary_account_factors[currency]
|
440
|
+
]
|
441
|
+
}
|
442
|
+
tls = rows.transpose.slice(1..4).map{|vals| vals.sum}
|
443
|
+
rows.map{|dat|
|
444
|
+
"#{dat[0]} & #{dat[1].to_tex} & #{dat[2].to_tex} & #{dat[3].to_tex} & #{dat[4].to_tex} \\\\"
|
445
|
+
}.join("\n\n")
|
431
446
|
}
|
432
|
-
|
433
|
-
|
447
|
+
#{if @report_currency
|
448
|
+
"
|
449
|
+
\\hline\\Tstrut
|
434
450
|
Totals & #{tls.map{|v| v.to_tex}.join(" & ")}
|
451
|
+
"
|
452
|
+
end
|
453
|
+
}
|
454
|
+
\\end{tabulary}
|
455
|
+
EOF
|
456
|
+
end
|
457
|
+
|
458
|
+
# A table showing the available balance for each kind of account,
|
459
|
+
# being the amount that can be spent today.
|
460
|
+
def available_balances_table
|
461
|
+
<<EOF
|
462
|
+
\\section{Available Balances}
|
463
|
+
\\begin{tabulary}{0.9\\textwidth}{R | r r c}
|
464
|
+
Account & Balance & Available & Type\\\\
|
465
|
+
\\hline\\Tstrut
|
466
|
+
#{
|
467
|
+
[:Equity, :Asset, :Liability].map{|type|
|
468
|
+
@accounts.find_all{|acc| acc.type == type}.map{|acc|
|
469
|
+
[acc.name_c, acc.balance(@today).to_tex, acc.available(@today).to_tex, type.to_s].join(" & ")
|
470
|
+
}.join("\\\\ \n")
|
471
|
+
}.join("\\\\ \n\n")
|
472
|
+
}
|
435
473
|
\\end{tabulary}
|
436
474
|
EOF
|
437
475
|
end
|
@@ -491,10 +529,13 @@ EOF
|
|
491
529
|
end
|
492
530
|
kit.title = "#{account.name_c} Expenditure with average (Total = #{kit.data[0].y.data.sum})"
|
493
531
|
CodeRunner::Budget.kit_time_format_x(kit)
|
532
|
+
kit.gp.decimalsign = 'locale "en_GB.UTF-8"'
|
533
|
+
kit.gp.format.push %[y "%'.2f"]
|
494
534
|
#kit.gnuplot
|
495
535
|
#ep ['kit1122', account, kit]
|
496
536
|
fork do
|
497
|
-
kit.gnuplot_write("#{account.name_c_file}.eps", size: "4.0in,2.0in")
|
537
|
+
kit.gnuplot_write("#{account.name_c_file}2.eps", size: "4.0in,2.0in")
|
538
|
+
system "ps2epsi #{account.name_c_file}2.eps #{account.name_c_file}.eps"
|
498
539
|
exec "epstopdf #{account.name_c_file}.eps"
|
499
540
|
end
|
500
541
|
#%x[ps2eps #{account}.ps]
|
@@ -612,7 +653,7 @@ EOF
|
|
612
653
|
\\section{Recent Transactions}
|
613
654
|
#{@accounts.find_all{|acc| not acc.type == :Equity}.sort_by{|acc| acc.external ? 0 : 1}.map{|acc|
|
614
655
|
"\\subsection{#{acc.name_c}}
|
615
|
-
\\
|
656
|
+
\\transactionsize
|
616
657
|
#{all = acc.runs.find_all{|r| r.days_ago(@today) < @days_before}
|
617
658
|
case acc.type
|
618
659
|
when :Expense, :Income
|
@@ -621,7 +662,7 @@ EOF
|
|
621
662
|
all = all.sort_by{|r| [r.date, r.id]}.reverse
|
622
663
|
end
|
623
664
|
#ep ['acc', acc, 'ids', all.map{|r| r.id}, 'size', all.size]
|
624
|
-
all.pieces((all.size.to_f/
|
665
|
+
all.pieces((all.size.to_f/60.to_f).ceil).map{|piece|
|
625
666
|
"\\setlength{\\parindent}{0cm}\n\n\\begin{tabulary}{0.99\\textwidth}{ #{"c " * 3 + " l " + " r " * 3 + "l"}}
|
626
667
|
#{piece.map{|r|
|
627
668
|
(CodeRunner::Budget.rcp.component_results - [:sc] + [:sub_account]).map{|res|
|
@@ -650,7 +691,13 @@ EOF
|
|
650
691
|
\\usepackage{graphicx}
|
651
692
|
\\usepackage{multicol}
|
652
693
|
\\usepackage{hyperref}
|
653
|
-
|
694
|
+
%\\usepackage{libertine}
|
695
|
+
%\\usepackage{helvetica}
|
696
|
+
\\usepackage{fontspec}
|
697
|
+
\\setmainfont[
|
698
|
+
BoldFont={Linux Biolinum O Bold},
|
699
|
+
BoldItalicFont={Linux Biolinum O Bold},
|
700
|
+
]{Linux Biolinum O}
|
654
701
|
\\usepackage{xcolor,listings}
|
655
702
|
\\usepackage{epstopdf}
|
656
703
|
\\newcommand\\Tstrut{\\rule{0pt}{2.8ex}}
|
@@ -672,12 +719,13 @@ EOF
|
|
672
719
|
\\end{center}\\vspace*{0em}
|
673
720
|
|
674
721
|
}
|
722
|
+
\\newcommand{\\transactionsize}{\\scriptsize}
|
675
723
|
\\lstset{%
|
676
724
|
basicstyle=\\ttfamily\\color{black},
|
677
725
|
identifierstyle = \\ttfamily\\color{purple},
|
678
726
|
keywordstyle=\\ttfamily\\color{blue},
|
679
727
|
stringstyle=\\color{orange}}
|
680
|
-
\\usepackage[compact]{titlesec}
|
728
|
+
\\usepackage[bf,compact]{titlesec}
|
681
729
|
%\\titlespacing{\\section}{0pt}{*0}{*0}
|
682
730
|
%\\titlespacing{\\subsection}{0pt}{*0}{*2}
|
683
731
|
%\\titlespacing{\\subsubsection}{0pt}{*0}{*0}
|
data/treasurer.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: treasurer 0.
|
5
|
+
# stub: treasurer 0.9.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "treasurer".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.9.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Edmund Highcock".freeze]
|
14
|
-
s.date = "2018-04-
|
14
|
+
s.date = "2018-04-09"
|
15
15
|
s.description = "A simple command line tool for managing accounts and finances. Easily import internet banking spreadsheets and generate sophisticated reports and projections.".freeze
|
16
16
|
s.email = "edmundhighcock@users.sourceforge.net".freeze
|
17
17
|
s.executables = ["treasurer".freeze]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: treasurer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edmund Highcock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|