reckon 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5984a4f8cd36d4e14f013c14bb111725f8681b90768b6710679820d1325a02e5
4
- data.tar.gz: b392d89078a7679f01a344799512ec0467cfe8cad101374a5b8fd198c7e39480
3
+ metadata.gz: fbf144e0683d1b618fbc046ade5af1c9fd37a69c2a62ee393301ce26f9b9a475
4
+ data.tar.gz: 32fc57d45adec068894497619c357a36482ede4e547a3169a4c8faf95e731a2c
5
5
  SHA512:
6
- metadata.gz: ae9b8348e93294d45354f1b96045305dd480b23cd34dcaca3f958fcbc866582000faa1711ea6cbb552578ffe98f126943221b98af298757b86e6dfa54c623f9d
7
- data.tar.gz: f43e7128e198c9b73fc40b148cbe281d0bc02aeec90d576615e24fe98789a1846553121319152bffb3a9ca966fd26e1b3916da90480979c5d55106e06dbfe7f2
6
+ metadata.gz: a5cdf653ec68d8360526c131335249fce69c9b51b12824023263621fb743c4c769cf9e9a44aa37108d8d1ef3ad51bba9b9268e36259c7d4597dddf20abf3c368
7
+ data.tar.gz: 0af870f477d800fb76edf3d7a4e31ef1120d40817b55d8e8da7175bad0e6daa2a981186e5bfc258a46703dd81cb1c07ed805a0260e9472264a5817fd207a9649
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.8.0](https://github.com/cantino/reckon/tree/v0.8.0) (2021-08-08)
4
+
5
+ [Full Changelog](https://github.com/cantino/reckon/compare/v0.7.2...v0.8.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - --date-format '%d/%m/%Y' not working [\#113](https://github.com/cantino/reckon/issues/113)
10
+ - Reckon behaviour does not match what is explained on README.md [\#112](https://github.com/cantino/reckon/issues/112)
11
+ - --date-format '%d/%m/%Y' not working [\#111](https://github.com/cantino/reckon/issues/111)
12
+ - --date-format '%d/ [\#110](https://github.com/cantino/reckon/issues/110)
13
+
14
+ **Merged pull requests:**
15
+
16
+ - Add ledger-date-format option to specify ledger file date format [\#114](https://github.com/cantino/reckon/pull/114) ([benprew](https://github.com/benprew))
17
+
3
18
  ## [v0.7.2](https://github.com/cantino/reckon/tree/v0.7.2) (2021-04-22)
4
19
 
5
20
  [Full Changelog](https://github.com/cantino/reckon/compare/v0.7.1...v0.7.2)
@@ -150,6 +165,7 @@
150
165
  - Fix bugs in ledger file parsing. Fixes \#56. [\#81](https://github.com/cantino/reckon/pull/81) ([benprew](https://github.com/benprew))
151
166
  - Better file encoding suggestions [\#80](https://github.com/cantino/reckon/pull/80) ([benprew](https://github.com/benprew))
152
167
  - :bug: fix matching algorithm, add logging and a spec helper. Fixes \#73 [\#79](https://github.com/cantino/reckon/pull/79) ([benprew](https://github.com/benprew))
168
+ - bug: invalid header lines should be ignored, not parsed. [\#78](https://github.com/cantino/reckon/pull/78) ([benprew](https://github.com/benprew))
153
169
  - convert default date format to iso8601 [\#77](https://github.com/cantino/reckon/pull/77) ([benprew](https://github.com/benprew))
154
170
  - Fix rspec failure for ruby 2.3 and 2.4 [\#69](https://github.com/cantino/reckon/pull/69) ([BlackEdder](https://github.com/BlackEdder))
155
171
  - Allow setting of money and date columns by index [\#67](https://github.com/cantino/reckon/pull/67) ([cantino](https://github.com/cantino))
@@ -202,11 +218,11 @@
202
218
 
203
219
  **Merged pull requests:**
204
220
 
205
- - bug: invalid header lines should be ignored, not parsed. [\#78](https://github.com/cantino/reckon/pull/78) ([benprew](https://github.com/benprew))
206
221
  - Better ISO 8601 dates support [\#49](https://github.com/cantino/reckon/pull/49) ([vzctl](https://github.com/vzctl))
207
222
  - Unattended mode and custom tokens support [\#47](https://github.com/cantino/reckon/pull/47) ([vzctl](https://github.com/vzctl))
208
223
  - \[RFC\] Implement issue \#40: Tab completion [\#46](https://github.com/cantino/reckon/pull/46) ([BlackEdder](https://github.com/BlackEdder))
209
224
  - set readline to allow for backspace in ask dialog [\#44](https://github.com/cantino/reckon/pull/44) ([mrtazz](https://github.com/mrtazz))
225
+ - Fix --encoding option [\#41](https://github.com/cantino/reckon/pull/41) ([mamciek](https://github.com/mamciek))
210
226
 
211
227
  ## [v0.3.10](https://github.com/cantino/reckon/tree/v0.3.10) (2014-08-16)
212
228
 
@@ -214,9 +230,7 @@
214
230
 
215
231
  **Merged pull requests:**
216
232
 
217
- - Fix --encoding option [\#41](https://github.com/cantino/reckon/pull/41) ([mamciek](https://github.com/mamciek))
218
233
  - Bumped version number [\#37](https://github.com/cantino/reckon/pull/37) ([BlackEdder](https://github.com/BlackEdder))
219
- - Ing csv [\#30](https://github.com/cantino/reckon/pull/30) ([BlackEdder](https://github.com/BlackEdder))
220
234
 
221
235
  ## [v0.3.9](https://github.com/cantino/reckon/tree/v0.3.9) (2014-02-20)
222
236
 
@@ -233,12 +247,15 @@
233
247
  - Date format [\#35](https://github.com/cantino/reckon/pull/35) ([BlackEdder](https://github.com/BlackEdder))
234
248
  - Added example from a french bank [\#34](https://github.com/cantino/reckon/pull/34) ([BlackEdder](https://github.com/BlackEdder))
235
249
  - Austrian example [\#33](https://github.com/cantino/reckon/pull/33) ([BlackEdder](https://github.com/BlackEdder))
250
+ - Ing csv [\#30](https://github.com/cantino/reckon/pull/30) ([BlackEdder](https://github.com/BlackEdder))
236
251
  - Further improvements in nationwide csv handling [\#29](https://github.com/cantino/reckon/pull/29) ([BlackEdder](https://github.com/BlackEdder))
237
252
  - Refactor: Add money class [\#28](https://github.com/cantino/reckon/pull/28) ([BlackEdder](https://github.com/BlackEdder))
238
253
  - Initial split of CSVparser from class App [\#27](https://github.com/cantino/reckon/pull/27) ([BlackEdder](https://github.com/BlackEdder))
239
254
  - Updated version of pull request 24: Allow for other currency symbols while calculating money\_score [\#26](https://github.com/cantino/reckon/pull/26) ([BlackEdder](https://github.com/BlackEdder))
240
255
  - Change double column detection [\#23](https://github.com/cantino/reckon/pull/23) ([BlackEdder](https://github.com/BlackEdder))
256
+ - Added optional argument to contains\_header to skip multiple header lines [\#22](https://github.com/cantino/reckon/pull/22) ([BlackEdder](https://github.com/BlackEdder))
241
257
  - Add a Bitdeli Badge to README [\#20](https://github.com/cantino/reckon/pull/20) ([bitdeli-chef](https://github.com/bitdeli-chef))
258
+ - Update README to show latest usage info [\#19](https://github.com/cantino/reckon/pull/19) ([purcell](https://github.com/purcell))
242
259
 
243
260
  ## [v0.3.8](https://github.com/cantino/reckon/tree/v0.3.8) (2013-07-03)
244
261
 
@@ -255,7 +272,6 @@
255
272
 
256
273
  **Merged pull requests:**
257
274
 
258
- - Update README to show latest usage info [\#19](https://github.com/cantino/reckon/pull/19) ([purcell](https://github.com/purcell))
259
275
  - add support for spanish dates dd/mm/yyyy closes \#13 [\#14](https://github.com/cantino/reckon/pull/14) ([mauromorales](https://github.com/mauromorales))
260
276
  - fix issue showing true when parsing the currency option related to \#7 [\#12](https://github.com/cantino/reckon/pull/12) ([mauromorales](https://github.com/mauromorales))
261
277
 
@@ -265,7 +281,6 @@
265
281
 
266
282
  **Merged pull requests:**
267
283
 
268
- - Added optional argument to contains\_header to skip multiple header lines [\#22](https://github.com/cantino/reckon/pull/22) ([BlackEdder](https://github.com/BlackEdder))
269
284
  - Updated the sources to allow for custom curreny [\#11](https://github.com/cantino/reckon/pull/11) ([ghost](https://github.com/ghost))
270
285
  - Add --account option on the commandline [\#10](https://github.com/cantino/reckon/pull/10) ([copiousfreetime](https://github.com/copiousfreetime))
271
286
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- reckon (0.7.2)
4
+ reckon (0.8.0)
5
5
  chronic (>= 0.3.0)
6
6
  highline (>= 1.5.2)
7
7
  rchardet (>= 1.8.0)
data/README.md CHANGED
@@ -58,10 +58,13 @@ Learn more:
58
58
  --encoding 'UTF-8'
59
59
  Specify an encoding for the CSV file
60
60
  -c, --currency '$' Currency symbol to use - default $ (ex £, EUR)
61
- --date-format '%d/%m/%Y'
62
- Force the date format (see Ruby DateTime strftime)
61
+ --date-format FORMAT
62
+ CSV file date format (see `date` for format)
63
+ --ledger-date-format FORMAT
64
+ Ledger date format (see `date` for format)
63
65
  -u, --unattended Don't ask questions and guess all the accounts automatically. Use with --learn-from or --account-tokens options.
64
66
  -t, --account-tokens FILE YAML file with manually-assigned tokens for each account (see README)
67
+ --table-output-file FILE
65
68
  --default-into-account NAME
66
69
  Default into account
67
70
  --default-outof-account NAME
@@ -80,13 +83,13 @@ If you find CSV files that it can't parse, send me examples or pull requests!
80
83
  You can run reckon in a non-interactive mode.
81
84
  To guess the accounts reckon can use an existing ledger file or a token file with keywords.
82
85
 
83
- `reckon --unattended -l 2010.dat -f bank.csv -o ledger.dat`
86
+ `reckon --unattended -a Checking -l 2010.dat -f bank.csv -o ledger.dat`
84
87
 
85
- `reckon --unattended --account-tokens tokens.yaml -f bank.csv -o ledger.dat`
88
+ `reckon --unattended -a Checking --account-tokens tokens.yaml -f bank.csv -o ledger.dat`
86
89
 
87
90
  In unattended mode, you can use STDIN to read your csv data, by specifying `-` as the argument to `-f`.
88
91
 
89
- `csv_file_generator | reckon --unattended -l 2010.dat -o ledger.dat -f -`
92
+ `csv_file_generator | reckon --unattended -a Checking -l 2010.dat -o ledger.dat -f -`
90
93
 
91
94
  ### Account Tokens
92
95
 
@@ -2,12 +2,13 @@ module Reckon
2
2
  class DateColumn < Array
3
3
  attr_accessor :endian_precedence
4
4
  def initialize( arr = [], options = {} )
5
+ @options = options
5
6
  arr.each do |value|
6
7
  if options[:date_format]
7
8
  begin
8
9
  value = Date.strptime(value, options[:date_format])
9
10
  rescue
10
- puts "I'm having trouble parsing #{value} with the desired format: #{options[:date_format]}"
11
+ puts "I'm having trouble parsing '#{value}' with the desired format: #{options[:date_format]}"
11
12
  exit 1
12
13
  end
13
14
  else
@@ -53,7 +54,7 @@ module Reckon
53
54
  date = self.for(index)
54
55
  return "" if date.nil?
55
56
 
56
- date.iso8601
57
+ date.strftime(@options[:ledger_date_format] || '%Y-%m-%d')
57
58
  end
58
59
 
59
60
  def self.likelihood(entry)
@@ -114,7 +114,7 @@ module Reckon
114
114
 
115
115
  def initialize(ledger, options = {})
116
116
  @options = options
117
- @date_format = options[:date_format] || '%Y-%m-%d'
117
+ @date_format = options[:ledger_date_format] || options[:date_format] || '%Y-%m-%d'
118
118
  parse(ledger)
119
119
  end
120
120
 
@@ -73,10 +73,14 @@ module Reckon
73
73
  options[:currency] = e
74
74
  end
75
75
 
76
- opts.on("", "--date-format '%d/%m/%Y'", "Force the date format (see Ruby DateTime strftime)") do |d|
76
+ opts.on("", "--date-format FORMAT", "CSV file date format (see `date` for format)") do |d|
77
77
  options[:date_format] = d
78
78
  end
79
79
 
80
+ opts.on("", "--ledger-date-format FORMAT", "Ledger date format (see `date` for format)") do |d|
81
+ options[:ledger_date_format] = d
82
+ end
83
+
80
84
  opts.on("-u", "--unattended", "Don't ask questions and guess all the accounts automatically. Use with --learn-from or --account-tokens options.") do |n|
81
85
  options[:unattended] = n
82
86
  end
@@ -1,3 +1,3 @@
1
1
  module Reckon
2
- VERSION="0.7.2"
2
+ VERSION="0.8.0"
3
3
  end
@@ -0,0 +1 @@
1
+ ledger --input-date-format '%d/%m/%Y'
@@ -0,0 +1,3 @@
1
+ 02/12/2009,Check - 0000000122,122,-$76.00,"","$1,750.06"
2
+ 02/12/2009,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
3
+ 02/12/2009,Check - 0000000112,112,-$800.00,"","$1,498.57"
@@ -0,0 +1,12 @@
1
+ 02/12/2009 BLARG R SH 456930; $1,826.06
2
+ Assets:Bank:Checking $327.49
3
+ Income:Unknown
4
+
5
+ 02/12/2009 Check - 0000000122; 122; $1,750.06
6
+ Income:Unknown
7
+ Assets:Bank:Checking -$76.00
8
+
9
+ 02/12/2009 Check - 0000000112; 112; $1,498.57
10
+ Income:Unknown
11
+ Assets:Bank:Checking -$800.00
12
+
@@ -0,0 +1 @@
1
+ -f input.csv --unattended --account Assets:Bank:Checking --date-format '%d/%m/%Y' --ledger-date-format '%d/%m/%Y'
@@ -1,7 +1,5 @@
1
1
  #!/bin/bash
2
2
 
3
- # set -x
4
-
5
3
  set -Euo pipefail
6
4
 
7
5
 
@@ -23,7 +21,7 @@ main () {
23
21
 
24
22
  echo > test.log
25
23
 
26
- NUM_TESTS=$(echo "$TESTS" |wc -l)
24
+ NUM_TESTS=$(echo "$TESTS" |wc -l |awk '{print $1}')
27
25
 
28
26
  echo "1..$NUM_TESTS"
29
27
 
@@ -31,17 +29,19 @@ main () {
31
29
 
32
30
  for t in $TESTS; do
33
31
  TEST_DIR=$(dirname "$t")
32
+ TEST_LOG=$(mktemp)
34
33
  pushd "$TEST_DIR" >/dev/null || exit 1
35
34
  if [[ -e "cli_input.exp" ]]; then
36
- cli_test
35
+ cli_test >$TEST_LOG 2>&1
37
36
  else
38
- unattended_test
37
+ unattended_test >$TEST_LOG 2>&1
39
38
  fi
40
39
 
41
40
  popd >/dev/null || exit 1
42
41
  # have to save output after popd
43
42
  echo -e "\n\n======>$TEST_DIR" >> test.log
44
- echo -e "TEST_CMD\n$TEST_LOG" >> test.log
43
+ echo -e "TEST_CMD: $TEST_CMD" >> test.log
44
+ cat $TEST_LOG >> test.log
45
45
 
46
46
  if [[ $ERROR -ne 0 ]]; then
47
47
  echo -e "not ok $I - $TEST_DIR"
@@ -56,11 +56,11 @@ main () {
56
56
 
57
57
  cli_test () {
58
58
  OUTPUT_FILE=$(mktemp)
59
- TEST_CMD="$RECKON_CMD --table-output-file $OUTPUT_FILE $(cat test_args)"
60
- TEST_CMD="expect -d -c 'spawn $TEST_CMD' cli_input.exp"
61
- TEST_LOG=$(eval "$TEST_CMD" 2>&1)
59
+ CLI_CMD="$RECKON_CMD --table-output-file $OUTPUT_FILE $(cat test_args)"
60
+ TEST_CMD="expect -d -c 'spawn $CLI_CMD' cli_input.exp"
61
+ eval $TEST_CMD 2>&1
62
62
  ERROR=0
63
- TEST_DIFF=$(diff -u "$OUTPUT_FILE" "expected_output")
63
+ TEST_DIFF=$(diff -u "$OUTPUT_FILE" expected_output)
64
64
 
65
65
  # ${#} is character length, test that there was no output from diff
66
66
  if [ ${#TEST_DIFF} -eq 0 ]; then
@@ -73,7 +73,7 @@ cli_test () {
73
73
  unattended_test() {
74
74
  OUTPUT_FILE=$(mktemp)
75
75
  TEST_CMD="$RECKON_CMD -o $OUTPUT_FILE $(cat test_args)"
76
- TEST_LOG=$(eval "$TEST_CMD" 2>&1)
76
+ eval $TEST_CMD 2>&1
77
77
  ERROR=0
78
78
 
79
79
  compare_output "$OUTPUT_FILE"
@@ -87,6 +87,26 @@ test_fail () {
87
87
  fi
88
88
  }
89
89
 
90
+ compare_output () {
91
+ OUTPUT_FILE=$1
92
+ pwd
93
+ if [[ -e compare_cmds ]]; then
94
+ COMPARE_CMDS=$(cat compare_cmds)
95
+ else
96
+ COMPARE_CMDS=$'ledger\nhledger'
97
+ fi
98
+
99
+ ERROR=1
100
+ while IFS= read -r n; do
101
+ if compare_output_for "$OUTPUT_FILE" "$n"; then
102
+ ERROR=0
103
+ else
104
+ ERROR=1
105
+ break
106
+ fi
107
+ done <<< "$COMPARE_CMDS"
108
+ }
109
+
90
110
  compare_output_for () {
91
111
  OUTPUT_FILE=$1
92
112
  LEDGER=$2
@@ -94,8 +114,11 @@ compare_output_for () {
94
114
  EXPECTED_FILE=$(mktemp)
95
115
  ACTUAL_FILE=$(mktemp)
96
116
 
97
- $LEDGER -f output.ledger r >"$EXPECTED_FILE" 2>&1 || return 1
98
- $LEDGER -f output.ledger r >"$ACTUAL_FILE" 2>&1 || return 1
117
+ echo $LEDGER -f output.ledger r "$EXPECTED_FILE"
118
+ eval $LEDGER -f output.ledger r >"$EXPECTED_FILE" || return 1
119
+
120
+ echo $LEDGER -f output.ledger r "$ACTUAL_FILE"
121
+ eval $LEDGER -f output.ledger r >"$ACTUAL_FILE" || return 1
99
122
 
100
123
  TEST_DIFF=$(diff -u "$EXPECTED_FILE" "$ACTUAL_FILE")
101
124
 
@@ -107,17 +130,4 @@ compare_output_for () {
107
130
  fi
108
131
  }
109
132
 
110
- compare_output () {
111
- OUTPUT_FILE=$1
112
-
113
- for n in {ledger,hledger}; do
114
- if compare_output_for "$OUTPUT_FILE" "$n"; then
115
- ERROR=0
116
- else
117
- ERROR=1
118
- return 0
119
- fi
120
- done
121
- }
122
-
123
133
  main "$@"
@@ -38,4 +38,16 @@ describe Reckon::DateColumn do
38
38
  .to eq(Date.new(2013, 2, 1))
39
39
  end
40
40
  end
41
+
42
+ describe "#pretty_for" do
43
+ it 'should use ledger_date_format' do
44
+ expect(Reckon::DateColumn.new(%w[13/02/2013], {ledger_date_format: '%d/%m/%Y'}).pretty_for(0))
45
+ .to eq('13/02/2013')
46
+ end
47
+
48
+ it 'should default to is' do
49
+ expect(Reckon::DateColumn.new(%w[13/12/2013]).pretty_for(0))
50
+ .to eq('2013-12-13')
51
+ end
52
+ end
41
53
  end
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.7.2
4
+ version: 0.8.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: 2021-04-22 00:00:00.000000000 Z
13
+ date: 2021-08-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -217,6 +217,10 @@ files:
217
217
  - spec/integration/inversed_credit_card/input.csv
218
218
  - spec/integration/inversed_credit_card/output.ledger
219
219
  - spec/integration/inversed_credit_card/test_args
220
+ - spec/integration/ledger_date_format/compare_cmds
221
+ - spec/integration/ledger_date_format/input.csv
222
+ - spec/integration/ledger_date_format/output.ledger
223
+ - spec/integration/ledger_date_format/test_args
220
224
  - spec/integration/nationwide/input.csv
221
225
  - spec/integration/nationwide/output.ledger
222
226
  - spec/integration/nationwide/test_args