treasurer 0.10.2 → 0.10.3
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 +4 -4
- data/VERSION +1 -1
- data/lib/treasurer/account_choices.rb +38 -23
- data/lib/treasurer/commands.rb +5 -0
- data/lib/treasurer/report.rb +4 -1
- data/treasurer.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 530bccfe411d881237a70e7108ebc999b11401e6961a439b55c5efa8886be585
|
4
|
+
data.tar.gz: e4039efc362d99ba686675a04b7a3fe33e01498f8b3129840f588e2fada30790
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f16b0b2b1be1402f91d5b37bd764f9bd9c8763f3e99933d87bf7baa4decd989abdec961c9abc2c74072ce38fd8b9803ac1c9c0bb4aacfb2b4a93e5c0e33a2acb
|
7
|
+
data.tar.gz: 5a05d1f79c0138cb8f4f289bd8647c0a8c1deb8fa8a56e1c84c6adc0f8752e15daaace29d74fa65192726242ccf32c4f8fdeac64c89a717615439177ee60c372
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.3
|
@@ -161,33 +161,41 @@ class CodeRunner::Budget
|
|
161
161
|
chosen = false
|
162
162
|
transactions = runner.component_run_list.values.sort_by{|r| r.date}
|
163
163
|
idx = transactions.index(self)
|
164
|
+
ff = Proc.new{|float| float ? sprintf("%8.2f", float) : " "*8}
|
165
|
+
format = Proc.new{|runs| runs.map{|r|
|
166
|
+
#begin
|
167
|
+
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)
|
168
|
+
#rescue
|
169
|
+
#p r
|
170
|
+
#p r.data_line
|
171
|
+
#exit
|
172
|
+
#end
|
173
|
+
}.join("\n")}
|
174
|
+
format_choices = Proc.new{|chs| chs.map{|k,v| Terminal::LIGHT_GREEN + k + ":" + Terminal.default_colour + v}.join(" ")}
|
164
175
|
Dir.chdir(@runner.root_folder) do
|
165
176
|
sym = nil
|
177
|
+
print_transactions = Proc.new do
|
178
|
+
puts format.call(transactions.slice([idx-30, 0].max, 30))
|
179
|
+
puts Terminal::LIGHT_GREEN + format.call([transactions[idx]]) + "<-----" + Terminal.default_colour
|
180
|
+
sz = transactions.size
|
181
|
+
puts format.call(transactions.slice([idx+1, sz-1].min, 10))
|
182
|
+
end
|
166
183
|
while not chosen
|
167
184
|
Hash.phoenix('external_accounts.rb') do |account_hash|
|
168
185
|
#account_hash.each{|k,v| v[:name] = v[:name].to_sym} #Fixes an earlier bug
|
169
186
|
#choices = account_arr.size.times.map{|i| [i,account_arr[i][:name]]}
|
170
187
|
choices = account_hash.map{|k,v| [v[:sym], k]}.to_h
|
188
|
+
choices["-"] = "Transfer"
|
171
189
|
puts Terminal.default_colour
|
172
|
-
|
173
|
-
puts "-" * data_line.size
|
190
|
+
print_transactions.call
|
174
191
|
#format = Proc.new{|runs| runs.map{|r| r.signature.map{|d| d.to_s}.join(",")}.join("\n")}
|
175
|
-
format = Proc.new{|runs| runs.map{|r|
|
176
|
-
sprintf("%-40s %5.2f %5.2f %5.2f %12s", r.description, r.deposit, r.withdrawal, r.balance, r.account)
|
177
|
-
}.join("\n")}
|
178
|
-
puts format.call(transactions.slice([idx-10, 0].max, idx-1))
|
179
|
-
puts Terminal::LIGHT_GREEN + format.call([transactions[idx]]) + "<-----" + Terminal.default_colour
|
180
|
-
sz = transactions.size
|
181
|
-
puts format.call(transactions.slice([idx+1, sz].min, [idx+10,sz].min))
|
182
|
-
puts "-" * data_line.size
|
183
|
-
puts
|
184
|
-
puts "Account: " + account
|
185
192
|
puts
|
186
|
-
puts
|
193
|
+
puts format_choices.call(choices)
|
187
194
|
puts
|
188
|
-
puts "Please choose from the above external accounts for this transaction."
|
189
|
-
|
190
|
-
|
195
|
+
puts "Please choose from the above external accounts for this transaction." +
|
196
|
+
"If you wish to add a new account type 0. To quit type q. " +
|
197
|
+
"To start again for this transaction, type z. To mark it as transfer between" +
|
198
|
+
"two non-external accounts, press -."
|
191
199
|
while not chosen
|
192
200
|
require 'io/console'
|
193
201
|
choice = STDIN.getch
|
@@ -211,6 +219,10 @@ class CodeRunner::Budget
|
|
211
219
|
elsif choice == "z"
|
212
220
|
chosen = false
|
213
221
|
break
|
222
|
+
elsif choice == "-"
|
223
|
+
ext_account = "Transfer"
|
224
|
+
chosen = "Transfer"
|
225
|
+
break
|
214
226
|
elsif not choices.keys.include? choice
|
215
227
|
puts "Error: this symbol does not correspond to an account"
|
216
228
|
else
|
@@ -221,6 +233,9 @@ class CodeRunner::Budget
|
|
221
233
|
#choices_hash[data_line] = {external_account: chosen}
|
222
234
|
#end
|
223
235
|
end
|
236
|
+
if ext_account and chosen
|
237
|
+
break
|
238
|
+
end
|
224
239
|
ext_account = chosen
|
225
240
|
next if not chosen
|
226
241
|
chosen = false
|
@@ -229,13 +244,14 @@ class CodeRunner::Budget
|
|
229
244
|
sub_accounts = account_hash[ext_account][:sub_accounts]
|
230
245
|
sub_accounts.each{|k,v| v[:name] = v[:name].to_sym} #Fixes an earlier bug
|
231
246
|
choices = sub_accounts.map{|k,v| [v[:sym], k]}.to_h
|
232
|
-
puts "-" * data_line.size
|
247
|
+
#puts "-" * data_line.size
|
248
|
+
print_transactions.call
|
233
249
|
puts
|
234
|
-
puts choices
|
250
|
+
puts format_choices.call(choices)
|
235
251
|
puts
|
236
|
-
puts "Please choose from the above sub-accounts for this transaction."
|
237
|
-
|
238
|
-
|
252
|
+
puts "Please choose from the above sub-accounts for this transaction. " +
|
253
|
+
"If you wish to add a new sub account, type 0. To quit, type q. " +
|
254
|
+
"To start again for this transaction, type z"
|
239
255
|
while not chosen
|
240
256
|
require 'io/console'
|
241
257
|
choice = STDIN.getch
|
@@ -270,9 +286,8 @@ class CodeRunner::Budget
|
|
270
286
|
#Hash.phoenix('account_choices.rb') do |choices_hash|
|
271
287
|
#choices_hash[signature] = {external_account: ext_account, sub_account: chosen}
|
272
288
|
#end
|
273
|
-
add_sqlite_choices({external_account: ext_account, sub_account: chosen})
|
274
289
|
end #while not chosen
|
275
|
-
|
290
|
+
add_sqlite_choices({external_account: ext_account, sub_account: chosen})
|
276
291
|
end
|
277
292
|
{external_account: ext_account, sub_account: chosen}
|
278
293
|
end
|
data/lib/treasurer/commands.rb
CHANGED
@@ -32,7 +32,12 @@ 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
|
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)'
|
36
41
|
CodeRunner.run_command('external_account', crcopts)
|
37
42
|
end
|
38
43
|
def status(copts={})
|
data/lib/treasurer/report.rb
CHANGED
@@ -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
|
data/treasurer.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.
|
5
|
+
# stub: treasurer 0.10.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "treasurer".freeze
|
9
|
-
s.version = "0.10.
|
9
|
+
s.version = "0.10.3"
|
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]
|