budgetcrmod 0.3.0 → 0.4.0

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
  SHA1:
3
- metadata.gz: 2015715dae350f93b7931297fa1696a27ab988f3
4
- data.tar.gz: 719be9cb86645aa5a7ecc46c4588fb6baa2b17d4
3
+ metadata.gz: ade57698dee820f0d4b39a986ad8a9555d8bc34b
4
+ data.tar.gz: b829613b148110c54e7010359742e45134712f59
5
5
  SHA512:
6
- metadata.gz: 11dfb82752c234ca805a69b9abe16456201adf18adc849c29799ea927d0e317705f30dba08c9907f041a536da483980ee7fffc1d6c6664b9c876b5d01a9de432
7
- data.tar.gz: 969c97060b903b1c2661823f3c4df19d05700a4724249b41e9a03f9219a7b2dc111d549b9cce62dc4597be274785b01a0aaded206b0d815a84c84ae8133a32fe
6
+ metadata.gz: ec7c3854ffd4db2524a51dae9530c7c967c23aef7aed80bce76fcf94a6dc5dfac1221c48ae83fcfce46e3a42e71e951fe7a27b564f029d85f0e90fe7ff17d674
7
+ data.tar.gz: eb4a325310776a2cacd4a6e178eca7d4137a07d80f75c7cce644ddf31bd1f8b9623f803f87b5e256ea6e0e081c6d08920625e8b5772fd592d28bedb0e26be316
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -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: budgetcrmod 0.3.0 ruby lib
5
+ # stub: budgetcrmod 0.4.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "budgetcrmod".freeze
9
- s.version = "0.3.0"
9
+ s.version = "0.4.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-10"
14
+ s.date = "2018-06-30"
15
15
  s.description = "A CodeRunner module to help you do your budget".freeze
16
16
  s.email = "edmundhighcock@users.sourceforge.net".freeze
17
17
  s.extra_rdoc_files = [
@@ -7,15 +7,25 @@ class CodeRunner::Budget
7
7
  def external_account
8
8
  return @external_account if @external_account
9
9
  ext_account = false
10
+ unless @runner
11
+ raise "No runner for " + data_line
12
+ end
10
13
  Dir.chdir(@runner.root_folder) do
11
14
  chosen = false
12
15
  Hash.phoenix('account_choices.rb') do |choices_hash|
13
- if choices_hash[data_line]
16
+ if choices_hash[signature]
17
+ chosen = choices_hash[signature][:external_account]
18
+ elsif choices_hash[data_line]
14
19
  #choices_hash[data_line][:external_account] =
15
20
  #choices_hash[data_line][:external_account].to_sym #fixes earlier bug
16
21
  #choices_hash[data_line][:sub_account] =
17
22
  #choices_hash[data_line][:sub_account].to_sym #fixes earlier bug
18
23
  chosen = choices_hash[data_line][:external_account]
24
+ choices_hash[signature] = choices_hash[data_line]
25
+ choices_hash.delete(data_line)
26
+ elsif choices_hash[old_data_line]
27
+ chosen = choices_hash[old_data_line][:external_account]
28
+ choices_hash[signature] = choices_hash[old_data_line]
19
29
  end
20
30
  end
21
31
  return @external_account = chosen if chosen
@@ -29,9 +39,11 @@ class CodeRunner::Budget
29
39
  puts Terminal.default_colour
30
40
  puts
31
41
  puts "-" * data_line.size
32
- puts data_line
42
+ puts signature.inspect
33
43
  puts "-" * data_line.size
34
44
  puts
45
+ puts "Account: " + account
46
+ puts
35
47
  puts choices.inspect
36
48
  puts
37
49
  puts "Please choose from the above external accounts for this transaction."
@@ -117,7 +129,7 @@ class CodeRunner::Budget
117
129
  end
118
130
  next if not chosen
119
131
  Hash.phoenix('account_choices.rb') do |choices_hash|
120
- choices_hash[data_line] = {external_account: ext_account, sub_account: chosen}
132
+ choices_hash[signature] = {external_account: ext_account, sub_account: chosen}
121
133
  end
122
134
  end #while not chosen
123
135
 
@@ -134,9 +146,10 @@ class CodeRunner::Budget
134
146
  # well can be very helpful in showing a breakdown of expenditure.
135
147
  def sub_account
136
148
  return @sub_account if @sub_account
149
+ puts "SIGNATURE ", signature.inspect
137
150
  Dir.chdir(@runner.root_folder) do
138
151
  external_account until (
139
- choices = Hash.phoenix('account_choices.rb'){|choices_hash| choices_hash[data_line]}
152
+ choices = Hash.phoenix('account_choices.rb'){|choices_hash| choices_hash[signature]}
140
153
  p [choices, data_line]
141
154
  ) and choices[:sub_account]
142
155
  @sub_account = choices[:sub_account]
@@ -1,7 +1,7 @@
1
1
  require 'date'
2
2
  class String
3
3
  def latex_escape
4
- self.gsub(/(?<!\\)([$%_&^])/, '\\\\\1')
4
+ self.gsub(/(?<!\\)([$%_&^#])/, '\\\\\1')
5
5
  end
6
6
  #alias :old_to_f :to_f
7
7
  #def to_f
@@ -40,7 +40,8 @@ class CodeRunner
40
40
  @code_module_folder = File.dirname(File.expand_path(__FILE__)) # i.e. the directory this file is in
41
41
 
42
42
  @component_results = [:date, :type, :sc, :ac, :description, :deposit, :withdrawal, :balance]
43
- @results = [:date_i, :data, :data_line, :dataset] + @component_results
43
+ @results = [:date_i, :data, :data_line, :dataset, :description2, :given_withdrawal, :given_deposit] + @component_results
44
+ @signature_fields = [:date,:description,:deposit,:withdrawal,:account]
44
45
  def generate_input_file
45
46
  FileUtils.cp @data_file.sub(/~/, ENV['HOME']), @directory + '/data.cvs'
46
47
  end
@@ -161,10 +162,14 @@ class CodeRunner
161
162
  [:date,:description,:dummy,:deposit,:dummy]
162
163
  when /Datum,Text,Belopp/ #Ecster Credit Card
163
164
  [:date,:description,:deposit]
165
+ when /Effective Date,Entered Date,Transaction Description,Amount,Balance/ #QudosBank new format the first field is blank
166
+ [:dummy,:date,:description,:deposit,:balance]
164
167
  when /Effective Date,Entered Date,Transaction Description,Amount/ #QudosBank, the first field is blank
165
168
  [:dummy,:date,:description,:deposit]
166
169
  when /Date,Amount,Currency,Description,"Payment Reference","Running Balance","Exchange Rate","Payer Name","Payee Name","Payee Account Number",Merchant/ #TransferWise
167
170
  [:date,:deposit,:dummy,:description,:dummy,:balance,:dummy,:dummy,:dummy,:dummy,:dummy]
171
+ when /"TransferWise ID",Date,Amount,Currency,Description,"Payment Reference","Running Balance","Exchange From","Exchange To","Exchange Rate","Payer Name","Payee Name","Payee Account Number",Merchant,"Total fees"/ #TransferWise New
172
+ [:dummy,:date,:deposit,:dummy,:description,:description2,:balance,:dummy,:dummy,:dummy,:dummy,:dummy,:dummy,:dummy,:dummy]
168
173
  end
169
174
  end
170
175
 
@@ -196,11 +201,11 @@ class CodeRunner
196
201
  @data.each do |dataset|
197
202
  #next if @runner.cache[:data].include? dataset and Date.parse(dataset[0]) > Date.parse("1/1/2013")
198
203
  #next if @runner.component_run_list.map{|k,v| v.instance_variable_get(:@dataset)}.include? dataset # and Date.parse(dataset[0]) > Date.parse("1/1/2013")
199
- next if @runner.component_run_list.find{|k,v| v.dataset == dataset} # and Date.parse(dataset[0]) > Date.parse("1/1/2013")
200
204
  next if @first_line_string =~ /^Datum/ and dataset[1] =~ /Reservation/
201
- component = create_component
202
- component.set_zeroes
203
- ep 'Generating Component', @component_runs.size
205
+ h = {}
206
+ h[:withdrawal] = 0.0
207
+ h[:deposit] = 0.0
208
+ h[:account] = @account
204
209
  reslts = csv_data_fields
205
210
  reslts.each_with_index do |res,index|
206
211
  value = dataset[index]
@@ -217,16 +222,43 @@ class CodeRunner
217
222
  next unless value =~ /\d/
218
223
  value = value.to_f
219
224
  end
220
- component.set(res, value)
225
+ #component.set(res, value)
226
+ h[res] = value
221
227
  end
222
- component.set(:data_line, reslts.map{|r| component.send(r).to_s}.join(','))
228
+ h[:data_line] = reslts.map{|r| h[r].to_s}.join(',')
229
+
230
+ if h[:description2] and h[:description]
231
+ h[:description] += ":" + h[:description2]
232
+ end
233
+
234
+ h[:given_withdrawal] = h[:withdrawal]
235
+ h[:given_deposit] = h[:deposit]
236
+ if h[:deposit] < 0.0 and h[:withdrawal] == 0.0
237
+ h[:withdrawal] = -h[:deposit]
238
+ h[:deposit] = 0.0
239
+ end
240
+ if h[:withdrawal] < 0.0 and h[:deposit] == 0.0
241
+ h[:deposit] = -h[:withdrawal]
242
+ h[:withdrawal] = 0.0
243
+ end
244
+ next if @runner.component_run_list.find{|k,v|
245
+ v.signature == rcp.signature_fields.map{|res| h[res]}
246
+ } # and Date.parse(dataset[0]) > Date.parse("1/1/2013")
247
+
248
+ component = create_component
249
+ #component.set_zeroes
250
+ h.each{|k,v| component.set(k,v)}
251
+ ep 'Generating Component', @component_runs.size
223
252
  component.set(:dataset, dataset)
224
253
  component.date_i = component.date.to_datetime.to_time.to_i
225
- if component.deposit < 0.0 and component.withdrawal == 0.0
226
- component.withdrawal = -component.deposit
227
- component.deposit = 0.0
228
- end
229
- @runner.cache[:data].push dataset
254
+ #if component.description2 and component.description
255
+ #component.description += ":" + component.description2
256
+ #end
257
+ #if component.deposit < 0.0 and component.withdrawal == 0.0
258
+ #component.withdrawal = -component.deposit
259
+ #component.deposit = 0.0
260
+ #end
261
+ #@runner.cache[:data].push dataset
230
262
  component.external_account; component.sub_account # Triggers interactive account choices
231
263
  #component.account = @account
232
264
  end
@@ -240,6 +272,19 @@ class CodeRunner
240
272
  def ds
241
273
  description
242
274
  end
275
+ def signature
276
+ #[date,description,deposit,withdrawal,account]
277
+ rcp.signature_fields.map{|res| send(res)}
278
+ end
279
+
280
+ def old_data_line # For backwards compatibility issues when csv formats change
281
+ case @first_line_string
282
+ when /Effective Date,Entered Date,Transaction Description,Amount,Balance/ #QudosBank new format the first field is blank
283
+ data_line.sub(/,[^,]*?$/, '')
284
+ else
285
+ nil
286
+ end
287
+ end
243
288
 
244
289
 
245
290
  def self.predictable_component_ids(runner)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: budgetcrmod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.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-10 00:00:00.000000000 Z
11
+ date: 2018-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coderunner