treasurer 0.10.1 → 0.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 918eb4cb7a1aa8a9f0c6bac9efa881cdddebc888a61952c81f16f82e2e773a3d
4
- data.tar.gz: c0f5775f74249b13fef043752fe92f7186492d3b588b2821e2404f68431ff0eb
3
+ metadata.gz: b5ac67d0251cca1bbb93ed85a8334a66d0446701d3baa2b73b368df2b9cd93ca
4
+ data.tar.gz: bc15a7c7e792864a5f7e104d5eb44e9fbc09ee9769977cceba1ffc2c95bb6440
5
5
  SHA512:
6
- metadata.gz: d1bad563f203927243a5becdf1162e3037faec4a998125325ae0e3a20abe976a82e1b8f3734a534502994d94d27824260e72c99136973192f110e4de14da7c01
7
- data.tar.gz: da403469bc36b964d086bd090dd222e40757dc9f2cb837d501cb527829d61d13b06038c72b223ac666e1be537c3a38cc9fb1fde2eeb18d78ed4666254f1f0467
6
+ metadata.gz: 99de9f6f92158ea3f1a98121c98a831d518f2d3d43515dd6962658880d6c8e53a86b512270955bcb643877142ffd2a1d0914f058dd35f95ba935009e8d7be75b
7
+ data.tar.gz: 8d9a12e8c6b193554a8dc43b2573236f32baf3c4956037875196929b7dc485f49c85106d1e8fc7ff709f8d151a03efecf28d1137807d361ce4f950de5b221ecf
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ gem "activesupport", ">= 5.0.0"
12
12
  group :development do
13
13
  gem "shoulda", ">= 0"
14
14
  gem "rdoc", "~> 3.12"
15
- gem "bundler", "~> 1.0"
15
+ gem "bundler", "~> 2.0"
16
16
  gem "jeweler", "~> 2.3.1"
17
17
  gem "simplecov", ">= 0"
18
18
  gem "ruby-prof", ">= 0.15"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.1
1
+ 0.10.6
@@ -34,8 +34,10 @@ class CodeRunner::Budget
34
34
  end
35
35
  end
36
36
 
37
+ DATABASES={}
38
+
37
39
  def self.sqlitedb(folder)
38
- SQLite3::Database.new folder + "/treasurer.db"
40
+ DATABASES[folder] ||= SQLite3::Database.new folder + "/treasurer.db"
39
41
  end
40
42
 
41
43
  def sqlitedb
@@ -142,7 +144,7 @@ class CodeRunner::Budget
142
144
  'WHERE signature = ?',
143
145
  signature.inspect
144
146
  )
145
- pp "RRRRROOO", rows
147
+ #pp "RRRRROOO", rows
146
148
  if rows.size == 1
147
149
  return {
148
150
  external_account: eval(rows[0][0]),
@@ -159,26 +161,43 @@ class CodeRunner::Budget
159
161
  def get_new_choices
160
162
  ext_account = nil
161
163
  chosen = false
164
+ transactions = runner.component_run_list.values.sort_by{|r| r.date}
165
+ idx = transactions.index(self)
166
+ ff = Proc.new{|float| float ? sprintf("%8.2f", float) : " "*8}
167
+ format = Proc.new{|runs| runs.map{|r|
168
+ #begin
169
+ sprintf("%70s %s %8s %8s %8s %-12s", r.description[0,70], r.date.to_s, ff.call(r.deposit), ff.call(r.withdrawal), ff.call(r.balance), r.account)
170
+ #rescue
171
+ #p r
172
+ #p r.data_line
173
+ #exit
174
+ #end
175
+ }.join("\n")}
176
+ format_choices = Proc.new{|chs| chs.map{|k,v| Terminal::LIGHT_GREEN + k + ":" + Terminal.default_colour + v}.join(" ")}
162
177
  Dir.chdir(@runner.root_folder) do
163
178
  sym = nil
179
+ print_transactions = Proc.new do
180
+ puts format.call(transactions.slice([idx-30, 0].max, 30))
181
+ puts Terminal::LIGHT_GREEN + format.call([transactions[idx]]) + "<-----" + Terminal.default_colour
182
+ sz = transactions.size
183
+ puts format.call(transactions.slice([idx+1, sz-1].min, 10))
184
+ end
164
185
  while not chosen
165
186
  Hash.phoenix('external_accounts.rb') do |account_hash|
166
187
  #account_hash.each{|k,v| v[:name] = v[:name].to_sym} #Fixes an earlier bug
167
188
  #choices = account_arr.size.times.map{|i| [i,account_arr[i][:name]]}
168
189
  choices = account_hash.map{|k,v| [v[:sym], k]}.to_h
190
+ choices["-"] = "Transfer"
169
191
  puts Terminal.default_colour
192
+ print_transactions.call
193
+ #format = Proc.new{|runs| runs.map{|r| r.signature.map{|d| d.to_s}.join(",")}.join("\n")}
170
194
  puts
171
- puts "-" * data_line.size
172
- puts signature.inspect
173
- puts "-" * data_line.size
174
- puts
175
- puts "Account: " + account
195
+ puts format_choices.call(choices)
176
196
  puts
177
- puts choices.inspect
178
- puts
179
- puts "Please choose from the above external accounts for this transaction."
180
- puts "If you wish to add a new account type 0. To quit type q"
181
- puts "To start again for this transaction, type z"
197
+ puts "Please choose from the above external accounts for this transaction." +
198
+ "If you wish to add a new account type 0. To quit type q. " +
199
+ "To start again for this transaction, type z. To mark it as transfer between" +
200
+ "two non-external accounts, press -."
182
201
  while not chosen
183
202
  require 'io/console'
184
203
  choice = STDIN.getch
@@ -202,6 +221,10 @@ class CodeRunner::Budget
202
221
  elsif choice == "z"
203
222
  chosen = false
204
223
  break
224
+ elsif choice == "-"
225
+ ext_account = "Transfer"
226
+ chosen = "Transfer"
227
+ break
205
228
  elsif not choices.keys.include? choice
206
229
  puts "Error: this symbol does not correspond to an account"
207
230
  else
@@ -212,21 +235,25 @@ class CodeRunner::Budget
212
235
  #choices_hash[data_line] = {external_account: chosen}
213
236
  #end
214
237
  end
215
- ext_account = chosen
216
238
  next if not chosen
239
+ if ext_account and chosen
240
+ break
241
+ end
242
+ ext_account = chosen
217
243
  chosen = false
218
244
  Hash.phoenix('external_accounts.rb') do |account_hash|
219
245
  #choices = account_arr.size.times.map{|i| [i,account_arr[i][:name]]}
220
246
  sub_accounts = account_hash[ext_account][:sub_accounts]
221
247
  sub_accounts.each{|k,v| v[:name] = v[:name].to_sym} #Fixes an earlier bug
222
248
  choices = sub_accounts.map{|k,v| [v[:sym], k]}.to_h
223
- puts "-" * data_line.size
249
+ #puts "-" * data_line.size
250
+ print_transactions.call
224
251
  puts
225
- puts choices.inspect
252
+ puts format_choices.call(choices)
226
253
  puts
227
- puts "Please choose from the above sub-accounts for this transaction."
228
- puts "If you wish to add a new sub account, type 0. To quit, type q"
229
- puts "To start again for this transaction, type z"
254
+ puts "Please choose from the above sub-accounts for this transaction. " +
255
+ "If you wish to add a new sub account, type 0. To quit, type q. " +
256
+ "To start again for this transaction, type z"
230
257
  while not chosen
231
258
  require 'io/console'
232
259
  choice = STDIN.getch
@@ -249,6 +276,7 @@ class CodeRunner::Budget
249
276
  chosen = name
250
277
  elsif choice == "z"
251
278
  chosen = false
279
+ ext_account = nil
252
280
  break
253
281
  elsif not choices.keys.include? choice
254
282
  puts "Error: this symbol does not correspond to a sub-account"
@@ -261,9 +289,8 @@ class CodeRunner::Budget
261
289
  #Hash.phoenix('account_choices.rb') do |choices_hash|
262
290
  #choices_hash[signature] = {external_account: ext_account, sub_account: chosen}
263
291
  #end
264
- add_sqlite_choices({external_account: ext_account, sub_account: chosen})
265
292
  end #while not chosen
266
-
293
+ add_sqlite_choices({external_account: ext_account, sub_account: chosen})
267
294
  end
268
295
  {external_account: ext_account, sub_account: chosen}
269
296
  end
@@ -279,12 +306,14 @@ class CodeRunner::Budget
279
306
  end
280
307
  if not @external_account
281
308
  @external_account = (
282
- get_sqlite_choices[:external_account] or
283
- get_old_choices[:external_account]
309
+ (ch = get_sqlite_choices)[:external_account] or
310
+ (ch = get_old_choices)[:external_account] or
311
+ (ch = get_new_choices)[:external_account]
284
312
  )
285
- if not @external_account
286
- raise "No external account for #{data_line}"
287
- end
313
+ @sub_account = ch[:sub_account]
314
+ #if not @external_account
315
+ #raise "No external account for #{data_line}"
316
+ #end
288
317
  end
289
318
  return @external_account
290
319
  end
@@ -355,8 +355,11 @@ EOF
355
355
  end
356
356
 
357
357
  fork do
358
- (kit).gnuplot_write("#{name_c_file}_balance2.eps", size: size) #, latex: true)
359
- system %[ps2epsi #{name_c_file}_balance2.eps #{name_c_file}_balance.eps]
358
+ #(kit).gnuplot_write("#{name_c_file}_balance2.eps", size: size) #, latex: true)
359
+ (kit).gnuplot_write("#{name_c_file}_balance.eps", size: size) #, latex: true)
360
+ # Deprecate ps2epsi
361
+ # system %[ps2epsi #{name_c_file}_balance2.eps #{name_c_file}_balance.eps]
362
+ #system %[ps2eps < #{name_c_file}_balance2.eps > #{name_c_file}_balance.eps]
360
363
  system %[epstopdf #{name_c_file}_balance.eps]
361
364
  end
362
365
  #%x[epstopdf #{name}_balance.eps]
@@ -32,8 +32,15 @@ class << self
32
32
  def assign(copts={})
33
33
  load_treasurer_folder(copts)
34
34
  crcopts = eval(copts[:C]||"{}")
35
+ #crcopts[:h] = nil
36
+ #CodeRunner.run_command('generate_component_runs', crcopts)
35
37
  crcopts[:h] = :component
36
- CodeRunner.run_command('external_account', crcopts)
38
+ crcopts[:O] = 'date'
39
+ crcopts[:f] = 'not (component_runs and component_runs.size > 0 and component_runs[0].instance_variable_get(:@external_account))'
40
+ crcopts[:f] = 'not (@external_account and @sub_account)'
41
+ catch (:quit_data_entry) do
42
+ CodeRunner.run_command('external_account', crcopts)
43
+ end
37
44
  end
38
45
  def status(copts={})
39
46
  load_treasurer_folder(copts)
@@ -124,9 +124,12 @@ class Treasurer
124
124
  #p 'accounts256',@runs.size, @runs.map{|r| r.account}.uniq
125
125
 
126
126
  end
127
+ # Construct the list of accounts. Because of double entry accounting
128
+ # # every entry has two accounts. External accounts are abstract accounts
129
+ # that do not correspond to a real account: e.g. "Food Expenditure"
127
130
  def generate_accounts
128
131
  accounts = @runs.map{|r| r.account}.uniq.map{|acc| Account.new(acc, self, @runner, @runs, false)}
129
- external_accounts = (@runs.map{|r| r.external_account}.uniq - accounts.map{|acc| acc.name}).map{|acc| Account.new(acc, self, @runner, @runs, true)}
132
+ external_accounts = (@runs.map{|r| r.external_account}.uniq - accounts.map{|acc| acc.name} - ["Transfer"]).map{|acc| Account.new(acc, self, @runner, @runs, true)}
130
133
  #if not @report_currency
131
134
  external_accounts = external_accounts.map do |acc|
132
135
  if acc_inf = ACCOUNT_INFO[acc.name] and currencies = acc_inf[:currencies] and currencies.size > 1
@@ -390,8 +393,11 @@ EOF
390
393
  fork do
391
394
 
392
395
  kit.gp.key = "off"
393
- kit.gnuplot_write("#{name}2.eps", size: "#{[[labels.size.to_f/4.2, 5.0].min, 1.0].max}in,4.5in")
394
- system %[ps2epsi #{name}2.eps #{name}.eps]
396
+ #kit.gnuplot_write("#{name}2.eps", size: "#{[[labels.size.to_f/4.2, 5.0].min, 1.0].max}in,4.5in")
397
+ kit.gnuplot_write("#{name}.eps", size: "#{[[labels.size.to_f/4.2, 5.0].min, 1.0].max}in,4.5in")
398
+ # Deprecate ps2epsi... fails on bounding boxes.
399
+ #system %[ps2epsi #{name}2.eps #{name}.eps]
400
+ #system %[ps2eps < #{name}2.eps > #{name}.eps]
395
401
  system %[epstopdf #{name}.eps]
396
402
 
397
403
  end
@@ -574,8 +580,11 @@ EOF
574
580
  #kit.gnuplot
575
581
  #ep ['kit1122', account, kit]
576
582
  fork do
577
- kit.gnuplot_write("#{account.name_c_file}2.eps", size: "4.0in,2.0in")
578
- system "ps2epsi #{account.name_c_file}2.eps #{account.name_c_file}.eps"
583
+ #kit.gnuplot_write("#{account.name_c_file}2.eps", size: "4.0in,2.0in")
584
+ kit.gnuplot_write("#{account.name_c_file}.eps", size: "4.0in,2.0in")
585
+ #system "ps2epsi #{account.name_c_file}2.eps #{account.name_c_file}.eps"
586
+ # ps2epsi can break.. we use ps2eps instead!
587
+ #system "ps2eps < #{account.name_c_file}2.eps > #{account.name_c_file}.eps"
579
588
  exec "epstopdf #{account.name_c_file}.eps"
580
589
  end
581
590
  #%x[ps2eps #{account}.ps]
@@ -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.10.1 ruby lib
5
+ # stub: treasurer 0.10.6 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "treasurer".freeze
9
- s.version = "0.10.1"
9
+ s.version = "0.10.6"
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 = "2020-02-08"
14
+ s.date = "2020-06-27"
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]
@@ -47,37 +47,25 @@ Gem::Specification.new do |s|
47
47
  ]
48
48
  s.homepage = "http://github.com/edmundhighcock/treasurer".freeze
49
49
  s.licenses = ["GPLv3".freeze]
50
- s.rubygems_version = "3.0.6".freeze
50
+ s.rubygems_version = "3.1.2".freeze
51
51
  s.summary = "A simple command line tool for managing accounts and finances.".freeze
52
52
 
53
53
  if s.respond_to? :specification_version then
54
54
  s.specification_version = 4
55
+ end
55
56
 
56
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
- s.add_runtime_dependency(%q<activesupport>.freeze, [">= 5.0.0"])
58
- s.add_runtime_dependency(%q<coderunner>.freeze, [">= 0.14.16"])
59
- s.add_runtime_dependency(%q<budgetcrmod>.freeze, ["~> 0.5.0"])
60
- s.add_runtime_dependency(%q<command-line-flunky>.freeze, [">= 1.0.0"])
61
- s.add_runtime_dependency(%q<sqlite3>.freeze, ["~> 1.3"])
62
- s.add_development_dependency(%q<shoulda>.freeze, [">= 0"])
63
- s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
64
- s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
65
- s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3.1"])
66
- s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
67
- s.add_development_dependency(%q<ruby-prof>.freeze, [">= 0.15"])
68
- else
69
- s.add_dependency(%q<activesupport>.freeze, [">= 5.0.0"])
70
- s.add_dependency(%q<coderunner>.freeze, [">= 0.14.16"])
71
- s.add_dependency(%q<budgetcrmod>.freeze, ["~> 0.5.0"])
72
- s.add_dependency(%q<command-line-flunky>.freeze, [">= 1.0.0"])
73
- s.add_dependency(%q<sqlite3>.freeze, ["~> 1.3"])
74
- s.add_dependency(%q<shoulda>.freeze, [">= 0"])
75
- s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
76
- s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
77
- s.add_dependency(%q<jeweler>.freeze, ["~> 2.3.1"])
78
- s.add_dependency(%q<simplecov>.freeze, [">= 0"])
79
- s.add_dependency(%q<ruby-prof>.freeze, [">= 0.15"])
80
- end
57
+ if s.respond_to? :add_runtime_dependency then
58
+ s.add_runtime_dependency(%q<activesupport>.freeze, [">= 5.0.0"])
59
+ s.add_runtime_dependency(%q<coderunner>.freeze, [">= 0.14.16"])
60
+ s.add_runtime_dependency(%q<budgetcrmod>.freeze, ["~> 0.5.0"])
61
+ s.add_runtime_dependency(%q<command-line-flunky>.freeze, [">= 1.0.0"])
62
+ s.add_runtime_dependency(%q<sqlite3>.freeze, ["~> 1.3"])
63
+ s.add_development_dependency(%q<shoulda>.freeze, [">= 0"])
64
+ s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
65
+ s.add_development_dependency(%q<bundler>.freeze, ["~> 2.0"])
66
+ s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3.1"])
67
+ s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
68
+ s.add_development_dependency(%q<ruby-prof>.freeze, [">= 0.15"])
81
69
  else
82
70
  s.add_dependency(%q<activesupport>.freeze, [">= 5.0.0"])
83
71
  s.add_dependency(%q<coderunner>.freeze, [">= 0.14.16"])
@@ -86,7 +74,7 @@ Gem::Specification.new do |s|
86
74
  s.add_dependency(%q<sqlite3>.freeze, ["~> 1.3"])
87
75
  s.add_dependency(%q<shoulda>.freeze, [">= 0"])
88
76
  s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
89
- s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
77
+ s.add_dependency(%q<bundler>.freeze, ["~> 2.0"])
90
78
  s.add_dependency(%q<jeweler>.freeze, ["~> 2.3.1"])
91
79
  s.add_dependency(%q<simplecov>.freeze, [">= 0"])
92
80
  s.add_dependency(%q<ruby-prof>.freeze, [">= 0.15"])
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.10.1
4
+ version: 0.10.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edmund Highcock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-08 00:00:00.000000000 Z
11
+ date: 2020-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.0'
117
+ version: '2.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.0'
124
+ version: '2.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: jeweler
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  - !ruby/object:Gem::Version
218
218
  version: '0'
219
219
  requirements: []
220
- rubygems_version: 3.0.6
220
+ rubygems_version: 3.1.2
221
221
  signing_key:
222
222
  specification_version: 4
223
223
  summary: A simple command line tool for managing accounts and finances.