reckon 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +31 -17
- data/bin/reckon +1 -1
- data/lib/reckon.rb +2 -0
- data/lib/reckon/app.rb +15 -219
- data/lib/reckon/csv_parser.rb +259 -0
- data/lib/reckon/money.rb +150 -0
- data/reckon.gemspec +2 -2
- data/spec/reckon/app_spec.rb +14 -270
- data/spec/reckon/csv_parser_spec.rb +393 -0
- data/spec/reckon/date_column_spec.rb +39 -0
- data/spec/reckon/money_column_spec.rb +52 -0
- data/spec/reckon/money_spec.rb +68 -0
- metadata +28 -35
@@ -0,0 +1,393 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require "spec_helper"
|
5
|
+
require 'rubygems'
|
6
|
+
require 'reckon'
|
7
|
+
|
8
|
+
Reckon::CSVParser.settings[:testing] = true
|
9
|
+
|
10
|
+
describe Reckon::CSVParser do
|
11
|
+
before do
|
12
|
+
@chase = Reckon::CSVParser.new(:string => CHASE_CSV)
|
13
|
+
@some_other_bank = Reckon::CSVParser.new(:string => SOME_OTHER_CSV)
|
14
|
+
@two_money_columns = Reckon::CSVParser.new(:string => TWO_MONEY_COLUMNS_BANK)
|
15
|
+
@simple_csv = Reckon::CSVParser.new(:string => SIMPLE_CSV)
|
16
|
+
@nationwide = Reckon::CSVParser.new( :string => NATIONWIDE_CSV, :csv_separator => ',', :suffixed => true, :currency => "POUND" )
|
17
|
+
@german_date = Reckon::CSVParser.new(:string => GERMAN_DATE_EXAMPLE)
|
18
|
+
@danish_kroner_nordea = Reckon::CSVParser.new(:string => DANISH_KRONER_NORDEA_EXAMPLE, :csv_separator => ';', :comma_separates_cents => true)
|
19
|
+
@yyyymmdd_date = Reckon::CSVParser.new(:string => YYYYMMDD_DATE_EXAMPLE)
|
20
|
+
@spanish_date = Reckon::CSVParser.new(:string => SPANISH_DATE_EXAMPLE, :date_format => '%d/%m/%Y')
|
21
|
+
@english_date = Reckon::CSVParser.new(:string => ENGLISH_DATE_EXAMPLE)
|
22
|
+
@ing_csv = Reckon::CSVParser.new(:string => ING_CSV, :comma_separates_cents => true )
|
23
|
+
@austrian_csv = Reckon::CSVParser.new(:string => AUSTRIAN_EXAMPLE, :comma_separates_cents => true, :csv_separator => ';' )
|
24
|
+
@french_csv = Reckon::CSVParser.new(:string => FRENCH_EXAMPLE, :csv_separator => ';', :comma_separates_cents => true)
|
25
|
+
@broker_canada = Reckon::CSVParser.new(:string => BROKER_CANADA_EXAMPLE)
|
26
|
+
@intuit_mint = Reckon::CSVParser.new(:string => INTUIT_MINT_EXAMPLE)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be in testing mode" do
|
30
|
+
@chase.settings[:testing].should be_true
|
31
|
+
Reckon::CSVParser.settings[:testing].should be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "parse" do
|
35
|
+
it "should work with foreign character encodings" do
|
36
|
+
app = Reckon::CSVParser.new(:file => File.expand_path(File.join(File.dirname(__FILE__), "..", "data_fixtures", "extratofake.csv")))
|
37
|
+
app.columns[0][0..2].should == ["Data", "10/31/2012", "11/01/2012"]
|
38
|
+
app.columns[2].first.should == "Hist?rico"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should work with other separators" do
|
42
|
+
Reckon::CSVParser.new(:string => "one;two\nthree;four", :csv_separator => ';').columns.should == [['one', 'three'], ['two', 'four']]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "columns" do
|
47
|
+
it "should return the csv transposed" do
|
48
|
+
@simple_csv.columns.should == [["entry1", "entry4"], ["entry2", "entry5"], ["entry3", "entry6"]]
|
49
|
+
@chase.columns.length.should == 4
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should be ok with empty lines" do
|
53
|
+
lambda {
|
54
|
+
Reckon::CSVParser.new(:string => "one,two\nthree,four\n\n\n\n\n").columns.should == [['one', 'three'], ['two', 'four']]
|
55
|
+
}.should_not raise_error
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "detect_columns" do
|
60
|
+
before do
|
61
|
+
@harder_date_example_csv = Reckon::CSVParser.new(:string => HARDER_DATE_EXAMPLE)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should detect the money column" do
|
65
|
+
@chase.money_column_indices.should == [3]
|
66
|
+
@some_other_bank.money_column_indices.should == [3]
|
67
|
+
@two_money_columns.money_column_indices.should == [3, 4]
|
68
|
+
@nationwide.money_column_indices.should == [3, 4]
|
69
|
+
@harder_date_example_csv.money_column_indices.should == [1]
|
70
|
+
@danish_kroner_nordea.money_column_indices.should == [3]
|
71
|
+
@yyyymmdd_date.money_column_indices.should == [3]
|
72
|
+
@ing_csv.money_column_indices.should == [6]
|
73
|
+
@austrian_csv.money_column_indices.should == [4]
|
74
|
+
@french_csv.money_column_indices.should == [6]
|
75
|
+
@broker_canada.money_column_indices.should == [8]
|
76
|
+
@intuit_mint.money_column_indices.should == [3]
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should detect the date column" do
|
80
|
+
@chase.date_column_index.should == 1
|
81
|
+
@some_other_bank.date_column_index.should == 1
|
82
|
+
@two_money_columns.date_column_index.should == 0
|
83
|
+
@harder_date_example_csv.date_column_index.should == 0
|
84
|
+
@danish_kroner_nordea.date_column_index.should == 0
|
85
|
+
@yyyymmdd_date.date_column_index.should == 1
|
86
|
+
@french_csv.date_column_index.should == 2
|
87
|
+
@broker_canada.date_column_index.should == 0
|
88
|
+
@intuit_mint.date_column_index.should == 0
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should consider all other columns to be description columns" do
|
92
|
+
@chase.description_column_indices.should == [0, 2]
|
93
|
+
@some_other_bank.description_column_indices.should == [0, 2]
|
94
|
+
@two_money_columns.description_column_indices.should == [1, 2, 5]
|
95
|
+
@harder_date_example_csv.description_column_indices.should == [2, 3, 4, 5, 6, 7]
|
96
|
+
@danish_kroner_nordea.description_column_indices.should == [1, 2, 4]
|
97
|
+
@yyyymmdd_date.description_column_indices.should == [0, 2]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "money_for" do
|
102
|
+
it "should return the appropriate fields" do
|
103
|
+
@chase.money_for(1).should == -20
|
104
|
+
@chase.money_for(4).should == 1558.52
|
105
|
+
@chase.money_for(7).should == -116.22
|
106
|
+
@some_other_bank.money_for(1).should == -20
|
107
|
+
@some_other_bank.money_for(4).should == 1558.52
|
108
|
+
@some_other_bank.money_for(7).should == -116.22
|
109
|
+
@two_money_columns.money_for(0).should == -76
|
110
|
+
@two_money_columns.money_for(1).should == 327.49
|
111
|
+
@two_money_columns.money_for(2).should == -800
|
112
|
+
@two_money_columns.money_for(3).should == -88.55
|
113
|
+
@two_money_columns.money_for(4).should == 88.55
|
114
|
+
@nationwide.money_for(0).should == 500.00
|
115
|
+
@nationwide.money_for(1).should == -20.00
|
116
|
+
@danish_kroner_nordea.money_for(0).should == -48.00
|
117
|
+
@danish_kroner_nordea.money_for(1).should == -79.00
|
118
|
+
@danish_kroner_nordea.money_for(2).should == 497.90
|
119
|
+
@danish_kroner_nordea.money_for(3).should == -995.00
|
120
|
+
@danish_kroner_nordea.money_for(4).should == -3452.90
|
121
|
+
@danish_kroner_nordea.money_for(5).should == -655.00
|
122
|
+
@yyyymmdd_date.money_for(0).should == -123.45
|
123
|
+
@ing_csv.money_for(0).should == -136.13
|
124
|
+
@ing_csv.money_for(1).should == 375.00
|
125
|
+
@austrian_csv.money_for(0).should == -18.00
|
126
|
+
@austrian_csv.money_for(2).should == 120.00
|
127
|
+
@french_csv.money_for(0).should == -10.00
|
128
|
+
@french_csv.money_for(1).should == -5.76
|
129
|
+
@broker_canada.money_for(0).should == 12.55
|
130
|
+
@broker_canada.money_for(1).should == -81.57
|
131
|
+
@intuit_mint.money_for(0).should == 0.01
|
132
|
+
@intuit_mint.money_for(1).should == -331.63
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should handle the comma_separates_cents option correctly" do
|
136
|
+
european_csv = Reckon::CSVParser.new(:string => "$2,00;something\n1.025,67;something else", :csv_separator => ';', :comma_separates_cents => true)
|
137
|
+
european_csv.money_for(0).should == 2.00
|
138
|
+
european_csv.money_for(1).should == 1025.67
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should return negated values if the inverse option is passed" do
|
142
|
+
inversed_csv = Reckon::CSVParser.new(:string => INVERSED_CREDIT_CARD, :inverse => true)
|
143
|
+
inversed_csv.money_for(0).should == -30.00
|
144
|
+
inversed_csv.money_for(3).should == 500.00
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "date_for" do
|
149
|
+
it "should return a parsed date object" do
|
150
|
+
@chase.date_for(1).year.should == Time.parse("2009/12/24").year
|
151
|
+
@chase.date_for(1).month.should == Time.parse("2009/12/24").month
|
152
|
+
@chase.date_for(1).day.should == Time.parse("2009/12/24").day
|
153
|
+
@some_other_bank.date_for(1).year.should == Time.parse("2010/12/24").year
|
154
|
+
@some_other_bank.date_for(1).month.should == Time.parse("2010/12/24").month
|
155
|
+
@some_other_bank.date_for(1).day.should == Time.parse("2010/12/24").day
|
156
|
+
@german_date.date_for(1).year.should == Time.parse("2009/12/24").year
|
157
|
+
@german_date.date_for(1).month.should == Time.parse("2009/12/24").month
|
158
|
+
@german_date.date_for(1).day.should == Time.parse("2009/12/24").day
|
159
|
+
@danish_kroner_nordea.date_for(0).year.should == Time.parse("2012/11/16").year
|
160
|
+
@danish_kroner_nordea.date_for(0).month.should == Time.parse("2012/11/16").month
|
161
|
+
@danish_kroner_nordea.date_for(0).day.should == Time.parse("2012/11/16").day
|
162
|
+
@yyyymmdd_date.date_for(0).year.should == Time.parse("2012/12/31").year
|
163
|
+
@yyyymmdd_date.date_for(0).month.should == Time.parse("2012/12/31").month
|
164
|
+
@yyyymmdd_date.date_for(0).day.should == Time.parse("2012/12/31").day
|
165
|
+
@spanish_date.date_for(1).year.should == Time.parse("2009/12/02").year
|
166
|
+
@spanish_date.date_for(1).month.should == Time.parse("2009/12/02").month
|
167
|
+
@spanish_date.date_for(1).day.should == Time.parse("2009/12/02").day
|
168
|
+
@english_date.date_for(1).year.should == Time.parse("2009/12/24").year
|
169
|
+
@english_date.date_for(1).month.should == Time.parse("2009/12/24").month
|
170
|
+
@english_date.date_for(1).day.should == Time.parse("2009/12/24").day
|
171
|
+
@nationwide.date_for(1).month.should == 10
|
172
|
+
@ing_csv.date_for(1).month.should == Time.parse("2012/11/12").month
|
173
|
+
@ing_csv.date_for(1).day.should == Time.parse("2012/11/12").day
|
174
|
+
@broker_canada.date_for(5).year.should == 2014
|
175
|
+
@broker_canada.date_for(5).month.should == 1
|
176
|
+
@broker_canada.date_for(5).day.should == 7
|
177
|
+
@intuit_mint.date_for(1).year.should == 2014
|
178
|
+
@intuit_mint.date_for(1).month.should == 2
|
179
|
+
@intuit_mint.date_for(1).day.should == 3
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "description_for" do
|
184
|
+
it "should return the combined fields that are not money for date fields" do
|
185
|
+
@chase.description_for(1).should == "CHECK; CHECK 2656"
|
186
|
+
@chase.description_for(7).should == "CREDIT; PAYPAL TRANSFER PPD ID: PAYPALSDSL"
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "pretty_money_for" do
|
191
|
+
it "work with negative and positive numbers" do
|
192
|
+
@some_other_bank.pretty_money_for(1).should == "-$20.00"
|
193
|
+
@some_other_bank.pretty_money_for(4).should == " $1558.52"
|
194
|
+
@some_other_bank.pretty_money_for(7).should == "-$116.22"
|
195
|
+
@some_other_bank.pretty_money_for(5).should == " $0.23"
|
196
|
+
@some_other_bank.pretty_money_for(6).should == "-$0.96"
|
197
|
+
end
|
198
|
+
|
199
|
+
it "work with other currencies such as €" do
|
200
|
+
euro_bank = Reckon::CSVParser.new(:string => SOME_OTHER_CSV, :currency => "€", :suffixed => false )
|
201
|
+
euro_bank.pretty_money_for(1).should == "-€20.00"
|
202
|
+
euro_bank.pretty_money_for(4).should == " €1558.52"
|
203
|
+
euro_bank.pretty_money_for(7).should == "-€116.22"
|
204
|
+
euro_bank.pretty_money_for(5).should == " €0.23"
|
205
|
+
euro_bank.pretty_money_for(6).should == "-€0.96"
|
206
|
+
end
|
207
|
+
|
208
|
+
it "work with suffixed currencies such as SEK" do
|
209
|
+
swedish_bank = Reckon::CSVParser.new(:string => SOME_OTHER_CSV, :currency => 'SEK', :suffixed => true )
|
210
|
+
swedish_bank.pretty_money_for(1).should == "-20.00 SEK"
|
211
|
+
swedish_bank.pretty_money_for(4).should == " 1558.52 SEK"
|
212
|
+
swedish_bank.pretty_money_for(7).should == "-116.22 SEK"
|
213
|
+
swedish_bank.pretty_money_for(5).should == " 0.23 SEK"
|
214
|
+
swedish_bank.pretty_money_for(6).should == "-0.96 SEK"
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should work with merge columns" do
|
218
|
+
@nationwide.pretty_money_for(0).should == " 500.00 POUND"
|
219
|
+
@nationwide.pretty_money_for(1).should == "-20.00 POUND"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe "merge_columns" do
|
224
|
+
it "should work on adjacent columns" do
|
225
|
+
@simple_csv.merge_columns(0,1).should == [["entry1 entry2", "entry4 entry5"], ["entry3", "entry6"]]
|
226
|
+
end
|
227
|
+
|
228
|
+
it "should work on non-adjacent columns" do
|
229
|
+
@simple_csv.merge_columns(0,2).should == [["entry1 entry3", "entry4 entry6"], ["entry2", "entry5"]]
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
# Data
|
234
|
+
|
235
|
+
SIMPLE_CSV = "entry1,entry2,entry3\nentry4,entry5,entry6"
|
236
|
+
|
237
|
+
CHASE_CSV = (<<-CSV).strip
|
238
|
+
DEBIT,20091224120000[0:GMT],"HOST 037196321563 MO 12/22SLICEHOST",-85.00
|
239
|
+
CHECK,20091224120000[0:GMT],"CHECK 2656",-20.00
|
240
|
+
DEBIT,20091224120000[0:GMT],"GITHUB 041287430274 CA 12/22GITHUB 04",-7.00
|
241
|
+
CREDIT,20091223120000[0:GMT],"Some Company vendorpymt PPD ID: 59728JSL20",3520.00
|
242
|
+
CREDIT,20091223120000[0:GMT],"Blarg BLARG REVENUE PPD ID: 00jah78563",1558.52
|
243
|
+
DEBIT,20091221120000[0:GMT],"WEBSITE-BALANCE-17DEC09 12 12/17WEBSITE-BAL",-12.23
|
244
|
+
DEBIT,20091214120000[0:GMT],"WEBSITE-BALANCE-10DEC09 12 12/10WEBSITE-BAL",-20.96
|
245
|
+
CREDIT,20091211120000[0:GMT],"PAYPAL TRANSFER PPD ID: PAYPALSDSL",-116.22
|
246
|
+
CREDIT,20091210120000[0:GMT],"Some Company vendorpymt PPD ID: 5KL3832735",2105.00
|
247
|
+
CSV
|
248
|
+
|
249
|
+
SOME_OTHER_CSV = (<<-CSV).strip
|
250
|
+
DEBIT,2011/12/24,"HOST 037196321563 MO 12/22SLICEHOST",($85.00)
|
251
|
+
CHECK,2010/12/24,"CHECK 2656",($20.00)
|
252
|
+
DEBIT,2009/12/24,"GITHUB 041287430274 CA 12/22GITHUB 04",($7.00)
|
253
|
+
CREDIT,2008/12/24,"Some Company vendorpymt PPD ID: 59728JSL20",$3520.00
|
254
|
+
CREDIT,2007/12/24,"Blarg BLARG REVENUE PPD ID: 00jah78563",$1558.52
|
255
|
+
DEBIT,2006/12/24,"WEBSITE-BALANCE-17DEC09 12 12/17WEBSITE-BAL",$.23
|
256
|
+
DEBIT,2005/12/24,"WEBSITE-BALANCE-10DEC09 12 12/10WEBSITE-BAL",($0.96)
|
257
|
+
CREDIT,2004/12/24,"PAYPAL TRANSFER PPD ID: PAYPALSDSL",($116.22)
|
258
|
+
CREDIT,2003/12/24,"Some Company vendorpymt PPD ID: 5KL3832735",$2105.00
|
259
|
+
CSV
|
260
|
+
|
261
|
+
INVERSED_CREDIT_CARD = (<<-CSV).strip
|
262
|
+
2013/01/17,2013/01/16,2013011702,DEBIT,2226,"VODAFONE PREPAY VISA M AUCKLAND NZL",30.00
|
263
|
+
2013/01/18,2013/01/17,2013011801,DEBIT,2226,"WILSON PARKING AUCKLAND NZL",4.60
|
264
|
+
2013/01/18,2013/01/17,2013011802,DEBIT,2226,"AUCKLAND TRANSPORT HENDERSON NZL",2.00
|
265
|
+
2013/01/19,2013/01/19,2013011901,CREDIT,2226,"INTERNET PAYMENT RECEIVED ",-500.00
|
266
|
+
2013/01/26,2013/01/23,2013012601,DEBIT,2226,"ITUNES NZ CORK IRL",64.99
|
267
|
+
2013/01/26,2013/01/25,2013012602,DEBIT,2226,"VODAFONE FXFLNE BBND R NEWTON NZL",90.26
|
268
|
+
2013/01/29,2013/01/29,2013012901,CREDIT,2101,"PAYMENT RECEIVED THANK YOU ",-27.75
|
269
|
+
2013/01/30,2013/01/29,2013013001,DEBIT,2226,"AUCKLAND TRANSPORT HENDERSON NZL",3.50
|
270
|
+
2013/02/05,2013/02/03,2013020501,DEBIT,2226,"Z BEACH RD AUCKLAND NZL",129.89
|
271
|
+
2013/02/05,2013/02/03,2013020502,DEBIT,2226,"TOURNAMENT KHYBER PASS AUCKLAND NZL",8.00
|
272
|
+
2013/02/05,2013/02/04,2013020503,DEBIT,2226,"VODAFONE PREPAY VISA M AUCKLAND NZL",30.00
|
273
|
+
2013/02/08,2013/02/07,2013020801,DEBIT,2226,"AKLD TRANSPORT PARKING AUCKLAND NZL",2.50
|
274
|
+
2013/02/08,2013/02/07,2013020802,DEBIT,2226,"AUCKLAND TRANSPORT HENDERSON NZL",3.50
|
275
|
+
2013/02/12,2013/02/11,2013021201,DEBIT,2226,"AKLD TRANSPORT PARKING AUCKLAND NZL",1.50
|
276
|
+
2013/02/17,2013/02/17,2013021701,CREDIT,2226,"INTERNET PAYMENT RECEIVED ",-12.00
|
277
|
+
2013/02/17,2013/02/17,2013021702,CREDIT,2226,"INTERNET PAYMENT RECEIVED ",-18.00
|
278
|
+
CSV
|
279
|
+
|
280
|
+
TWO_MONEY_COLUMNS_BANK = (<<-CSV).strip
|
281
|
+
4/1/2008,Check - 0000000122,122,-$76.00,"","$1,750.06"
|
282
|
+
3/28/2008,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
|
283
|
+
3/27/2008,Check - 0000000112,112,-$800.00,"","$1,498.57"
|
284
|
+
3/26/2008,Check - 0000000251,251,-$88.55,"","$1,298.57"
|
285
|
+
3/26/2008,Check - 0000000251,251,"","+$88.55","$1,298.57"
|
286
|
+
CSV
|
287
|
+
|
288
|
+
NATIONWIDE_CSV = (<<-CSV).strip
|
289
|
+
07 Nov 2013,Bank credit,Bank credit,,£500.00,£500.00
|
290
|
+
09 Oct 2013,ATM Withdrawal,Withdrawal,£20.00,,£480.00
|
291
|
+
09 Dec 2013,Visa,Supermarket,£19.77,,£460.23
|
292
|
+
10 Dec 2013,ATM Withdrawal 2,ATM Withdrawal 4,£100.00,,£360.23
|
293
|
+
CSV
|
294
|
+
|
295
|
+
ING_CSV = (<<-CSV).strip
|
296
|
+
20121115,From1,Acc,T1,IC,Af,"136,13",Incasso,SEPA Incasso, Opm1
|
297
|
+
20121112,Names,NL28 INGB 1200 3244 16,21817,GT,Bij,"375,00", Opm2
|
298
|
+
20091117,Names,NL28 INGB 1200 3244 16,21817,GT,Af,"257,50", Opm3
|
299
|
+
CSV
|
300
|
+
|
301
|
+
HARDER_DATE_EXAMPLE = (<<-CSV).strip
|
302
|
+
10-Nov-9,-123.12,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER MORTGAGE,0.00,
|
303
|
+
09-Nov-10,123.12,,,SALARY SALARY,NGHSKS46383BGDJKD FOO BAR,432.12,
|
304
|
+
04-Nov-11,-1234.00,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER SAV TO MECU,0.00,
|
305
|
+
04-Nov-9,1234.00,,,TRANSFER CREDIT INTERNET TRANSFER,INTERNET TRANSFER,1234.00,
|
306
|
+
28-Oct-10,-123.12,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER SAV TO MORTGAGE,0.00,
|
307
|
+
CSV
|
308
|
+
|
309
|
+
GERMAN_DATE_EXAMPLE = (<<-CSV).strip
|
310
|
+
24.12.2009,Check - 0000000122,122,-$76.00,"","$1,750.06"
|
311
|
+
24.12.2009,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
|
312
|
+
24.12.2009,Check - 0000000112,112,-$800.00,"","$1,498.57"
|
313
|
+
CSV
|
314
|
+
|
315
|
+
DANISH_KRONER_NORDEA_EXAMPLE = (<<-CSV).strip
|
316
|
+
16-11-2012;Dankort-nota DSB Kobenhavn 15149;16-11-2012;-48,00;26550,33
|
317
|
+
26-10-2012;Dankort-nota Ziggy Cafe 19471;26-10-2012;-79,00;26054,54
|
318
|
+
22-10-2012;Dankort-nota H&M Hennes & M 10681;23-10-2012;497,90;25433,54
|
319
|
+
12-10-2012;Visa kob DKK 995,00 WWW.ASOS.COM 00000 ;12-10-2012;-995,00;27939,54
|
320
|
+
12-09-2012;Dankort-nota B.J. TRADING E 14660;12-09-2012;-3452,90;26164,80
|
321
|
+
27-08-2012;Dankort-nota MATAS - 20319 18230;27-08-2012;-655,00;21127,45
|
322
|
+
CSV
|
323
|
+
|
324
|
+
YYYYMMDD_DATE_EXAMPLE = (<<-CSV).strip
|
325
|
+
DEBIT,20121231,"ODESK***BAL-27DEC12 650-12345 CA 12/28",-123.45
|
326
|
+
CSV
|
327
|
+
|
328
|
+
SPANISH_DATE_EXAMPLE = (<<-CSV).strip
|
329
|
+
02/12/2009,Check - 0000000122,122,-$76.00,"","$1,750.06"
|
330
|
+
02/12/2009,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
|
331
|
+
02/12/2009,Check - 0000000112,112,-$800.00,"","$1,498.57"
|
332
|
+
CSV
|
333
|
+
|
334
|
+
ENGLISH_DATE_EXAMPLE = (<<-CSV).strip
|
335
|
+
24/12/2009,Check - 0000000122,122,-$76.00,"","$1,750.06"
|
336
|
+
24/12/2009,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
|
337
|
+
24/12/2009,Check - 0000000112,112,-$800.00,"","$1,498.57"
|
338
|
+
CSV
|
339
|
+
|
340
|
+
AUSTRIAN_EXAMPLE = (<<-CSV).strip
|
341
|
+
00075757575;Abbuchung Onlinebanking 654321098765 BG/000002462 BICBICBI AT654000000065432109 Thematische Universität Stadt ;22.01.2014;22.01.2014;-18,00;EUR
|
342
|
+
00075757575;333222111333222 222111333222 OG/000002461 BICBICBIXXX AT333000000003332221 Telekom Land AG RECHNUNG 11/13 333222111333222 ;17.01.2014;17.01.2014;-9,05;EUR
|
343
|
+
00075757575;Helm BG/000002460 10000 00007878787 Muster Dr.Beispiel-Vorname ;15.01.2014;15.01.2014;+120,00;EUR
|
344
|
+
00075757575;Gutschrift Dauerauftrag BG/000002459 BICBICBI AT787000000007878787 Muster Dr.Beispiel-Vorname ;15.01.2014;15.01.2014;+22,00;EUR
|
345
|
+
00075757575;Bezahlung Bankomat MC/000002458 0001 K1 06.01.UM 18.11 Bahn 8020 FSA\\Ort\10 10 2002200EUR ;07.01.2014;06.01.2014;-37,60;EUR
|
346
|
+
00075757575;Bezahlung Bankomat 10.33 MC/000002457 0001 K1 02.01.UM 10.33 Abcdef Electronic\\Wie n\1150 0400444 ;03.01.2014;02.01.2014;-46,42;EUR
|
347
|
+
00075757575;050055556666000 OG/000002456 BKAUATWWXXX AT555500000555566665 JKL Telekommm Stadt GmbH JKL Rechnung 555666555 ;03.01.2014;03.01.2014;-17,15;EUR
|
348
|
+
00075757575;Abbuchung Einzugsermächtigung OG/000002455 INTERNATIONALER AUTOMOBIL-, 10000 00006655665 ;02.01.2014;02.01.2014;-17,40;EUR
|
349
|
+
00075757575;POLIZZE 1/01/0101010 Fondsge010101010101nsverOG/000002454 BICBICBIXXX AT101000000101010101 VERSICHERUNG NAMEDERV AG POLIZZE 1/01/0101010 Fondsgebundene Lebensversicherung - fällig 01.01. 2014 Folg eprämie ;02.01.2014;02.01.2014;-31,71;EUR
|
350
|
+
00075757575;POLIZZE 1/01/0101012 Rentenv010101010102- fälOG/000002453 BICBICBIXXX AT101000000101010102 VERSICHERUNG NAMEDERV AG POLIZZE 1/01/0101012 Rentenversicherung - fällig 01.01.20 14 Folgeprämi e ;02.01.2014;02.01.2014;-32,45;EUR
|
351
|
+
00075757575;Anlass VD/000002452 BKAUATWWBRN AT808800080880880880 Dipl.Ing.Dr. Berta Beispiel ;02.01.2014;02.01.2014;+61,90;EUR
|
352
|
+
00075757575;Abbuchung Onlinebanking 000009999999 BG/000002451 BICBICBI AT099000000009999999 Asdfjklöasdf Asdfjklöasdfjklöasdf ;02.01.2014;02.01.2014;-104,69;EUR
|
353
|
+
00075757575;Abbuchung Onlinebanking FE/000002450 AT556600055665566556 CD Stadt Efghij Club Dipl.Ing. Max Muster M005566 - Mitgliedsbeitrag 2014 ;02.01.2014;02.01.2014;-39,00;EUR
|
354
|
+
CSV
|
355
|
+
|
356
|
+
FRENCH_EXAMPLE = (<<-CSV).strip
|
357
|
+
01234567890;22/01/2014;22/01/2014;CHEQUE 012345678901234578ABC000 0000 4381974748378178473744441;0000037;22/01/2014;-10,00;
|
358
|
+
01234567890;22/01/2014;22/01/2014;CHEQUE 012345678901937845500TS1 0000 7439816947047874387438445;0000038;22/01/2014;-5,76;
|
359
|
+
01234567890;22/01/2014;22/01/2014;CARTE 012345 CB:*0123456 XX XXXXXX XXX 33BORDEAUX;00X0X0X;22/01/2014;-105,90;
|
360
|
+
01234567890;22/01/2014;22/01/2014;CARTE 012345 CB:*0123456 XXXXXXXXXXX 33SAINT ANDRE D;00X0X0X;22/01/2014;-39,99;
|
361
|
+
01234567890;22/01/2014;22/01/2014;CARTE 012345 CB:*0123456 XXXXXXX XXXXX 33BORDEAUX;10X9X6X;22/01/2014;-36,00;
|
362
|
+
01234567890;22/01/2014;22/01/2014;PRLV XXXXXXXX ABONNEMENT XXXXXXXXXXXXXX.NET N.EMETTEUR: 324411;0XX0XXX;22/01/2014;-40,00;
|
363
|
+
01234567890;21/01/2014;21/01/2014;CARTE 012345 CB:*0123456 XXXXX XX33433ST ANDRE DE C;0POBUES;21/01/2014;-47,12;
|
364
|
+
01234567890;21/01/2014;21/01/2014;CARTE 012345 CB:*0123456 XXXXXXXXXXXX33433ST ANDRE DE C;0POBUER;21/01/2014;-27,02;
|
365
|
+
01234567890;21/01/2014;21/01/2014;CARTE 012345 CB:*0123456 XXXXXX XXXXXXXX33ST ANDRE 935/;0POBUEQ;21/01/2014;-25,65;
|
366
|
+
CSV
|
367
|
+
|
368
|
+
BROKER_CANADA_EXAMPLE = (<<-CSV).strip
|
369
|
+
2014-02-10,2014-02-10,Interest,ISHARES S&P/TSX CAPPED REIT IN,XRE,179,,,12.55,CAD
|
370
|
+
2014-01-16,2014-01-16,Reinvestment,ISHARES GLOBAL AGRICULTURE IND,COW,3,,,-81.57,CAD
|
371
|
+
2014-01-16,2014-01-16,Contribution,CONTRIBUTION,,,,,600.00,CAD
|
372
|
+
2014-01-16,2014-01-16,Interest,ISHARES GLOBAL AGRICULTURE IND,COW,200,,,87.05,CAD
|
373
|
+
2014-01-14,2014-01-14,Reinvestment,BMO NASDAQ 100 EQTY HEDGED TO,ZQQ,2,,,-54.72,CAD
|
374
|
+
2014-01-07,2014-01-10,Sell,BMO NASDAQ 100 EQTY HEDGED TO,ZQQ,-300,27.44,CDN,8222.05,CAD
|
375
|
+
2014-01-07,2014-01-07,Interest,BMO S&P/TSX EQUAL WEIGHT BKS I,ZEB,250,,,14.00,CAD
|
376
|
+
2013-07-02,2013-07-02,Dividend,SELECT SECTOR SPDR FD SHS BEN,XLB,130,,,38.70,USD
|
377
|
+
2013-06-27,2013-06-27,Dividend,ICICI BK SPONSORED ADR,IBN,100,,,66.70,USD
|
378
|
+
2013-06-19,2013-06-24,Buy,ISHARES S&P/TSX CAPPED REIT IN,XRE,300,15.90,CDN,-4779.95,CAD
|
379
|
+
2013-06-17,2013-06-17,Contribution,CONTRIBUTION,,,,,600.00,CAD
|
380
|
+
2013-05-22,2013-05-22,Dividend,NATBK,NA,70,,,58.10,CAD
|
381
|
+
CSV
|
382
|
+
|
383
|
+
INTUIT_MINT_EXAMPLE = (<<-CSV).strip
|
384
|
+
"12/10/2014","Dn Ing Inv","[DN]ING INV/PLA","0.01","credit","Investments","Chequing","",""
|
385
|
+
"2/03/2014","Ds Lms Msp Condo","[DS]LMS598 MSP/DIV","331.63","debit","Condo Fees","Chequing","",""
|
386
|
+
"2/10/2014","Ib Granville","[IB] 2601 GRANVILLE","100.00","debit","Uncategorized","Chequing","",""
|
387
|
+
"2/06/2014","So Pa","[SO]PA 0005191230116379851","140.72","debit","Mortgage & Rent","Chequing","",""
|
388
|
+
"2/03/2014","Dn Sun Life","[DN]SUN LIFE MSP/DIV","943.34","credit","Income","Chequing","",""
|
389
|
+
"1/30/2014","Transfer to CBT (Savings)","[CW] TF 0004#3409-797","500.00","debit","Transfer","Chequing","",""
|
390
|
+
"1/30/2014","Costco","[PR]COSTCO WHOLESAL","559.96","debit","Business Services","Chequing","",""
|
391
|
+
CSV
|
392
|
+
|
393
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require "spec_helper"
|
5
|
+
require 'rubygems'
|
6
|
+
require 'reckon'
|
7
|
+
|
8
|
+
describe Reckon::DateColumn do
|
9
|
+
describe "initialize" do
|
10
|
+
it "should detect us and world time" do
|
11
|
+
Reckon::DateColumn.new( ["01/02/2013", "01/14/2013"] ).endian_precedence.should == [:middle]
|
12
|
+
Reckon::DateColumn.new( ["01/02/2013", "14/01/2013"] ).endian_precedence.should == [:little]
|
13
|
+
end
|
14
|
+
it "should set endian_precedence to default when date format cannot be misinterpreted" do
|
15
|
+
Reckon::DateColumn.new( ["2013/01/02"] ).endian_precedence.should == [:middle,:little]
|
16
|
+
end
|
17
|
+
it "should raise an error when in doubt" do
|
18
|
+
expect{ Reckon::DateColumn.new( ["01/02/2013", "01/03/2013"] )}.to raise_error( StandardError )
|
19
|
+
end
|
20
|
+
end
|
21
|
+
describe "for" do
|
22
|
+
it "should detect the date" do
|
23
|
+
Reckon::DateColumn.new( ["13/12/2013"] ).for( 0 ).should ==
|
24
|
+
Time.new( 2013, 12, 13, 12 )
|
25
|
+
Reckon::DateColumn.new( ["01/14/2013"] ).for( 0 ).should ==
|
26
|
+
Time.new( 2013, 01, 14, 12 )
|
27
|
+
Reckon::DateColumn.new( ["13/12/2013", "21/11/2013"] ).for( 1 ).should ==
|
28
|
+
Time.new( 2013, 11, 21, 12 )
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should correctly use endian_precedence" do
|
32
|
+
Reckon::DateColumn.new( ["01/02/2013", "01/14/2013"] ).for(0).should ==
|
33
|
+
Time.new( 2013, 01, 02, 12 )
|
34
|
+
Reckon::DateColumn.new( ["01/02/2013", "14/01/2013"] ).for(0).should ==
|
35
|
+
Time.new( 2013, 02, 01, 12 )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require "spec_helper"
|
5
|
+
require 'rubygems'
|
6
|
+
require 'reckon'
|
7
|
+
|
8
|
+
describe Reckon::MoneyColumn do
|
9
|
+
describe "initialize" do
|
10
|
+
it "should convert strings into Money" do
|
11
|
+
Reckon::MoneyColumn.new( ["1.00", "-2.00"] ).should == [
|
12
|
+
Reckon::Money.new( 1.00 ), Reckon::Money.new( -2.00 ) ]
|
13
|
+
end
|
14
|
+
it "should convert empty string into nil" do
|
15
|
+
Reckon::MoneyColumn.new( ["1.00", ""] ).should == [
|
16
|
+
Reckon::Money.new( 1.00 ), nil ]
|
17
|
+
Reckon::MoneyColumn.new( ["", "-2.00"] ).should == [
|
18
|
+
nil, Reckon::Money.new( -2.00 ) ]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "positive?" do
|
23
|
+
it "should return false if one entry negative" do
|
24
|
+
Reckon::MoneyColumn.new( ["1.00", "-2.00"] ).positive?.should == false
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return true if all elements positive or nil" do
|
28
|
+
Reckon::MoneyColumn.new( ["1.00", "2.00"] ).positive?.should == true
|
29
|
+
Reckon::MoneyColumn.new( ["1.00", ""] ).positive?.should == true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "merge" do
|
34
|
+
it "should merge two columns" do
|
35
|
+
Reckon::MoneyColumn.new( ["1.00", ""] ).merge!(
|
36
|
+
Reckon::MoneyColumn.new( ["", "-2.00"] ) ).should == [
|
37
|
+
Reckon::Money.new( 1.00 ), Reckon::Money.new( -2.00 ) ]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return nil if columns cannot be merged" do
|
41
|
+
Reckon::MoneyColumn.new( ["1.00", ""] ).merge!(
|
42
|
+
Reckon::MoneyColumn.new( ["1.00", "-2.00"] ) ).should == nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should invert first column if both positive" do
|
46
|
+
Reckon::MoneyColumn.new( ["1.00", ""] ).merge!(
|
47
|
+
Reckon::MoneyColumn.new( ["", "2.00"] ) ).should == [
|
48
|
+
Reckon::Money.new( -1.00 ), Reckon::Money.new( 2.00 ) ]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|