reckon 0.10.0 → 0.11.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
  SHA256:
3
- metadata.gz: 9b0141e2c8428b74039967461cb7db1b06fd4acd63edb2db8921ec2c9a2895ec
4
- data.tar.gz: 82c6d558f8e030988114db22d9ad59f580c7275a10a019b68c02355ea6639c71
3
+ metadata.gz: 58ef387a88fd33e7aeddc98842e3c5cf147e74830b659393ec5f75d0179d6bba
4
+ data.tar.gz: 3983fafdcce5b9e016dfd09cfa7a905bc0bf829d3b15f383f162b5738bbf0f49
5
5
  SHA512:
6
- metadata.gz: ec2519c7bd438012ae498b4e3a9517d6c63ae3de71bf7237043bdbeb60c589a88180a9171f0bcb5b25f1e7dda35c7f6eb9d99173d6c9905e2bc0913fe244cca6
7
- data.tar.gz: 8f3ea58e38dc864cdcbb10b8ecb50f214f0dfa903eef6029b9c48057807d6910de3928b61c7bc4e14051dd9052f01fafcefab9bffca8dc107d516f17e5e4a427
6
+ metadata.gz: 44731aea841dc2c3a4830085eda5dccc3b8958502eb21b8aee7ea4d52f2429e7dc2125de4c15084c804970ebc1199a859ef87437518f9635d0f8c33ae7c4444c
7
+ data.tar.gz: c2f4ed1e9ccf0f169a285d5337b3f97b7867d018a8541f4c009fe4dc105f0141884066071860a68b9baf688452b44ccc34b109d6ad4ff576645213c0ece3019e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.11.0](https://github.com/cantino/reckon/tree/v0.11.0) (2025-03-04)
4
+
5
+ [Full Changelog](https://github.com/cantino/reckon/compare/v0.10.0...v0.11.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - Feature request: confidence score [\#134](https://github.com/cantino/reckon/issues/134)
10
+ - feature request [\#133](https://github.com/cantino/reckon/issues/133)
11
+
3
12
  ## [v0.10.0](https://github.com/cantino/reckon/tree/v0.10.0) (2024-11-27)
4
13
 
5
14
  [Full Changelog](https://github.com/cantino/reckon/compare/v0.9.6...v0.10.0)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- reckon (0.10.0)
4
+ reckon (0.11.0)
5
5
  chronic (>= 0.3.0)
6
6
  highline (~> 2.0)
7
7
  matrix (>= 0.4.2)
@@ -21,7 +21,7 @@ GEM
21
21
  method_source (~> 1.0)
22
22
  rake (13.0.6)
23
23
  rantly (1.2.0)
24
- rchardet (1.8.0)
24
+ rchardet (1.9.0)
25
25
  rspec (3.12.0)
26
26
  rspec-core (~> 3.12.0)
27
27
  rspec-expectations (~> 3.12.0)
data/README.md CHANGED
@@ -108,6 +108,9 @@ Would tokenize to 'ING', 'Direct' and 'Deposit'. The matcher would then suggest
108
108
  Here's an example of `tokens.yaml`:
109
109
 
110
110
  ```
111
+ config:
112
+ similarity_threshold: 2 # range 0-10
113
+
111
114
  Income:
112
115
  Salary:
113
116
  - 'LÖN'
@@ -126,6 +129,8 @@ Expenses:
126
129
 
127
130
  Reckon will use `Income:Unknown` or `Expenses:Unknown` if it can't match a transaction to an account.
128
131
 
132
+ The config key is a special key used to set configuration when running in unattended mode. The only config variable is similarity_threshold (currently).
133
+
129
134
  You can override these names with the `--default_outof_account` and `--default_into_account` options.
130
135
 
131
136
  ### Substring Match
data/lib/reckon/app.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require 'yaml'
4
4
  require 'stringio'
5
5
 
6
+ UnattendedConfig = Struct.new(:similarity_threshold)
7
+
6
8
  module Reckon
7
9
  # The main app
8
10
  class App
@@ -42,7 +44,11 @@ module Reckon
42
44
 
43
45
  raise "#{filename} doesn't exist!" unless File.exist?(filename)
44
46
 
45
- extract_account_tokens(YAML.load_file(filename)).each do |account, tokens|
47
+ tokens = YAML.load_file(filename)
48
+ cfg = build_unattended_config(tokens.delete('config'))
49
+ @options[:similarity_threshold] = cfg.similarity_threshold if cfg
50
+
51
+ extract_account_tokens(tokens).each do |account, tokens|
46
52
  tokens.each do |t|
47
53
  if t.start_with?('/')
48
54
  add_regexp(account, t)
@@ -53,6 +59,13 @@ module Reckon
53
59
  end
54
60
  end
55
61
 
62
+ def build_unattended_config(cfg)
63
+ return unless cfg
64
+ invalid = cfg.keys - UnattendedConfig.members.map(&:to_s)
65
+ raise "Invalid keys in config: #{invalid}" if invalid.any?
66
+ return UnattendedConfig.new(*cfg.values_at(*UnattendedConfig.members.map(&:to_s)))
67
+ end
68
+
56
69
  def learn_from_ledger_file(ledger_file)
57
70
  return unless ledger_file
58
71
 
@@ -287,7 +300,10 @@ module Reckon
287
300
 
288
301
  def suggest(row)
289
302
  most_specific_regexp_match(row) +
290
- @matcher.find_similar(row[:description]).map { |n| n[:account] }
303
+ @matcher.find_similar(row[:description]).filter do |n|
304
+ !@options[:similarity_threshold] ||
305
+ n.fetch(:simliarity, 0) * 10 >= @options[:similarity_threshold]
306
+ end.map { |n| n[:account] }
291
307
  end
292
308
 
293
309
  def output(ledger_line)
@@ -1,3 +1,3 @@
1
1
  module Reckon
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -0,0 +1,9 @@
1
+ DEBIT,20091224120000[0:GMT],"HOST 037196321563 MO 12/22SLICEHOST",-85.00
2
+ CHECK,20091224120000[0:GMT],"Book Store",-20.00
3
+ DEBIT,20091224120000[0:GMT],"GITHUB 041287430274 CA 12/22GITHUB 04",-7.00
4
+ CREDIT,20091223120000[0:GMT],"Some Company vendorpymt PPD ID: 59728JSL20",3520.00
5
+ CREDIT,20091223120000[0:GMT],"Blarg BLARG REVENUE PPD ID: 00jah78563",1558.52
6
+ DEBIT,20091221120000[0:GMT],"WEBSITE-BALANCE-17DEC09 12 12/17WEBSITE-BAL",-12.23
7
+ DEBIT,20091214120000[0:GMT],"WEBSITE-BALANCE-10DEC09 12 12/10WEBSITE-BAL",-20.96
8
+ CREDIT,20091211120000[0:GMT],"PAYPAL TRANSFER PPD ID: PAYPALSDSL",-116.22
9
+ CREDIT,20091210120000[0:GMT],"Some Company vendorpymt PPD ID: 5KL3832735",2105.00
@@ -0,0 +1,36 @@
1
+ 2009-12-10 CREDIT; Some Company vendorpymt PPD ID: 5KL3832735
2
+ Assets:Bank:Checking $2,105.00
3
+ Income:Unknown
4
+
5
+ 2009-12-11 CREDIT; PAYPAL TRANSFER PPD ID: PAYPALSDSL
6
+ Expenses:Unknown
7
+ Assets:Bank:Checking -$116.22
8
+
9
+ 2009-12-14 DEBIT; WEBSITE-BALANCE-10DEC09 12 12/10WEBSITE-BAL
10
+ Expenses:Websites
11
+ Assets:Bank:Checking -$20.96
12
+
13
+ 2009-12-21 DEBIT; WEBSITE-BALANCE-17DEC09 12 12/17WEBSITE-BAL
14
+ Expenses:Websites
15
+ Assets:Bank:Checking -$12.23
16
+
17
+ 2009-12-23 CREDIT; Some Company vendorpymt PPD ID: 59728JSL20
18
+ Assets:Bank:Checking $3,520.00
19
+ Income:Unknown
20
+
21
+ 2009-12-23 CREDIT; Blarg BLARG REVENUE PPD ID: 00jah78563
22
+ Assets:Bank:Checking $1,558.52
23
+ Income:Unknown
24
+
25
+ 2009-12-24 DEBIT; GITHUB 041287430274 CA 12/22GITHUB 04
26
+ Expenses:Unknown
27
+ Assets:Bank:Checking -$7.00
28
+
29
+ 2009-12-24 CHECK; Book Store
30
+ Expenses:Unknown
31
+ Assets:Bank:Checking -$20.00
32
+
33
+ 2009-12-24 DEBIT; HOST 037196321563 MO 12/22SLICEHOST
34
+ Expenses:Unknown
35
+ Assets:Bank:Checking -$85.00
36
+
@@ -0,0 +1,2 @@
1
+ -f input.csv --unattended --account 'Assets:Bank:Checking' \
2
+ --account-tokens tokens.yml
@@ -0,0 +1,19 @@
1
+ config:
2
+ similarity_threshold: 6
3
+
4
+ Income:
5
+ Salary:
6
+ - 'LÖN'
7
+ - 'Salary'
8
+ Expenses:
9
+ Bank:
10
+ - 'Comission'
11
+ - /mastercard/i
12
+ Rent:
13
+ - '0011223344' # Landlord bank number
14
+ Websites:
15
+ - /web/i
16
+ Books:
17
+ - 'Book'
18
+ '[Internal:Transfer]': # Virtual account
19
+ - '4433221100' # Your own account number
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reckon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Cantino
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-11-27 00:00:00.000000000 Z
13
+ date: 2025-03-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -274,6 +274,10 @@ files:
274
274
  - spec/integration/two_money_columns_manual/input.csv
275
275
  - spec/integration/two_money_columns_manual/output.ledger
276
276
  - spec/integration/two_money_columns_manual/test_args
277
+ - spec/integration/unattended_config/input.csv
278
+ - spec/integration/unattended_config/output.ledger
279
+ - spec/integration/unattended_config/test_args
280
+ - spec/integration/unattended_config/tokens.yml
277
281
  - spec/integration/yyyymmdd_date_example/input.csv
278
282
  - spec/integration/yyyymmdd_date_example/output.ledger
279
283
  - spec/integration/yyyymmdd_date_example/test_args