reckon 0.4.4 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/.ruby-version +1 -1
- data/.travis.yml +10 -2
- data/CHANGELOG.md +235 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +73 -15
- data/README.md +12 -5
- data/lib/reckon.rb +13 -12
- data/lib/reckon/app.rb +94 -116
- data/lib/reckon/cosine_similarity.rb +122 -0
- data/lib/reckon/csv_parser.rb +116 -129
- data/lib/reckon/date_column.rb +60 -0
- data/lib/reckon/ledger_parser.rb +204 -30
- data/lib/reckon/logger.rb +4 -0
- data/lib/reckon/money.rb +6 -62
- data/lib/reckon/version.rb +3 -0
- data/reckon.gemspec +8 -5
- data/spec/data_fixtures/51-sample.csv +8 -0
- data/spec/data_fixtures/51-tokens.yml +9 -0
- data/spec/data_fixtures/73-sample.csv +2 -0
- data/spec/data_fixtures/73-tokens.yml +8 -0
- data/spec/data_fixtures/73-transactions.ledger +7 -0
- data/spec/data_fixtures/85-date-example.csv +2 -0
- data/spec/data_fixtures/austrian_example.csv +13 -0
- data/spec/data_fixtures/bom_utf8_file.csv +1 -0
- data/spec/data_fixtures/broker_canada_example.csv +12 -0
- data/spec/data_fixtures/chase.csv +9 -0
- data/spec/data_fixtures/danish_kroner_nordea_example.csv +6 -0
- data/spec/data_fixtures/english_date_example.csv +3 -0
- data/spec/data_fixtures/french_example.csv +9 -0
- data/spec/data_fixtures/german_date_example.csv +3 -0
- data/spec/data_fixtures/harder_date_example.csv +5 -0
- data/spec/data_fixtures/ing.csv +3 -0
- data/spec/data_fixtures/intuit_mint_example.csv +7 -0
- data/spec/data_fixtures/invalid_header_example.csv +6 -0
- data/spec/data_fixtures/inversed_credit_card.csv +16 -0
- data/spec/data_fixtures/nationwide.csv +4 -0
- data/spec/data_fixtures/simple.csv +2 -0
- data/spec/data_fixtures/some_other.csv +9 -0
- data/spec/data_fixtures/spanish_date_example.csv +3 -0
- data/spec/data_fixtures/suntrust.csv +7 -0
- data/spec/data_fixtures/test_money_column.csv +3 -0
- data/spec/data_fixtures/two_money_columns.csv +5 -0
- data/spec/data_fixtures/yyyymmdd_date_example.csv +1 -0
- data/spec/reckon/app_spec.rb +96 -34
- data/spec/reckon/csv_parser_spec.rb +185 -307
- data/spec/reckon/date_column_spec.rb +12 -13
- data/spec/reckon/ledger_parser_spec.rb +99 -9
- data/spec/reckon/money_spec.rb +42 -29
- data/spec/spec_helper.rb +22 -0
- metadata +85 -21
- data/CHANGES.md +0 -9
@@ -0,0 +1,8 @@
|
|
1
|
+
01/09/2015,05354 SUBWAY,8.19,,1000.00
|
2
|
+
02/18/2015,WENDY'S #6338,8.55,,1000.00
|
3
|
+
02/25/2015,WENDY'S #6338,8.55,,1000.00
|
4
|
+
02/25/2015,WENDY'S #6338,9.14,,1000.00
|
5
|
+
02/27/2015,WENDY'S #6338,5.85,,1000.00
|
6
|
+
03/09/2015,WENDY'S #6338,17.70,,1000.00
|
7
|
+
03/16/2015,WENDY'S #6338,11.15,,1000.00
|
8
|
+
03/23/2015,WENDY'S,10.12,,1000.00
|
@@ -0,0 +1,13 @@
|
|
1
|
+
00075757575;Abbuchung Onlinebanking 654321098765 BG/000002462 BICBICBI AT654000000065432109 Thematische Universität Stadt ;22.01.2014;22.01.2014;-18,00;EUR
|
2
|
+
00075757575;333222111333222 222111333222 OG/000002461 BICBICBIXXX AT333000000003332221 Telekom Land AG RECHNUNG 11/13 333222111333222 ;17.01.2014;17.01.2014;-9,05;EUR
|
3
|
+
00075757575;Helm BG/000002460 10000 00007878787 Muster Dr.Beispiel-Vorname ;15.01.2014;15.01.2014;+120,00;EUR
|
4
|
+
00075757575;Gutschrift Dauerauftrag BG/000002459 BICBICBI AT787000000007878787 Muster Dr.Beispiel-Vorname ;15.01.2014;15.01.2014;+22,00;EUR
|
5
|
+
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
|
6
|
+
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
|
7
|
+
00075757575;050055556666000 OG/000002456 BKAUATWWXXX AT555500000555566665 JKL Telekommm Stadt GmbH JKL Rechnung 555666555 ;03.01.2014;03.01.2014;-17,15;EUR
|
8
|
+
00075757575;Abbuchung Einzugsermächtigung OG/000002455 INTERNATIONALER AUTOMOBIL-, 10000 00006655665 ;02.01.2014;02.01.2014;-17,40;EUR
|
9
|
+
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
|
10
|
+
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
|
11
|
+
00075757575;Anlass VD/000002452 BKAUATWWBRN AT808800080880880880 Dipl.Ing.Dr. Berta Beispiel ;02.01.2014;02.01.2014;+61,90;EUR
|
12
|
+
00075757575;Abbuchung Onlinebanking 000009999999 BG/000002451 BICBICBI AT099000000009999999 Asdfjklöasdf Asdfjklöasdfjklöasdf ;02.01.2014;02.01.2014;-104,69;EUR
|
13
|
+
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
|
@@ -0,0 +1 @@
|
|
1
|
+
"Date","Time","TimeZone","Name","Type","Status","Currency","Gross","Fee","Net","From Email Address","To Email Address","Transaction ID","Shipping Address","Address Status","Item Title","Item ID","Shipping and Handling Amount","Insurance Amount","Sales Tax","Option 1 Name","Option 1 Value","Option 2 Name","Option 2 Value","Reference Txn ID","Invoice Number","Custom Number","Quantity","Receipt ID","Balance","Address Line 1","Address Line 2/District/Neighborhood","Town/City","State/Province/Region/County/Territory/Prefecture/Republic","Zip/Postal Code","Country","Contact Phone Number","Subject","Note","Country Code","Balance Impact"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
2014-02-10,2014-02-10,Interest,ISHARES S&P/TSX CAPPED REIT IN,XRE,179,,,12.55,CAD
|
2
|
+
2014-01-16,2014-01-16,Reinvestment,ISHARES GLOBAL AGRICULTURE IND,COW,3,,,-81.57,CAD
|
3
|
+
2014-01-16,2014-01-16,Contribution,CONTRIBUTION,,,,,600.00,CAD
|
4
|
+
2014-01-16,2014-01-16,Interest,ISHARES GLOBAL AGRICULTURE IND,COW,200,,,87.05,CAD
|
5
|
+
2014-01-14,2014-01-14,Reinvestment,BMO NASDAQ 100 EQTY HEDGED TO,ZQQ,2,,,-54.72,CAD
|
6
|
+
2014-01-07,2014-01-10,Sell,BMO NASDAQ 100 EQTY HEDGED TO,ZQQ,-300,27.44,CDN,8222.05,CAD
|
7
|
+
2014-01-07,2014-01-07,Interest,BMO S&P/TSX EQUAL WEIGHT BKS I,ZEB,250,,,14.00,CAD
|
8
|
+
2013-07-02,2013-07-02,Dividend,SELECT SECTOR SPDR FD SHS BEN,XLB,130,,,38.70,USD
|
9
|
+
2013-06-27,2013-06-27,Dividend,ICICI BK SPONSORED ADR,IBN,100,,,66.70,USD
|
10
|
+
2013-06-19,2013-06-24,Buy,ISHARES S&P/TSX CAPPED REIT IN,XRE,300,15.90,CDN,-4779.95,CAD
|
11
|
+
2013-06-17,2013-06-17,Contribution,CONTRIBUTION,,,,,600.00,CAD
|
12
|
+
2013-05-22,2013-05-22,Dividend,NATBK,NA,70,,,58.10,CAD
|
@@ -0,0 +1,9 @@
|
|
1
|
+
DEBIT,20091224120000[0:GMT],"HOST 037196321563 MO 12/22SLICEHOST",-85.00
|
2
|
+
CHECK,20091224120000[0:GMT],"CHECK 2656",-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,6 @@
|
|
1
|
+
16-11-2012;Dankort-nota DSB Kobenhavn 15149;16-11-2012;-48,00;26550,33
|
2
|
+
26-10-2012;Dankort-nota Ziggy Cafe 19471;26-10-2012;-79,00;26054,54
|
3
|
+
22-10-2012;Dankort-nota H&M Hennes & M 10681;23-10-2012;497,90;25433,54
|
4
|
+
12-10-2012;Visa kob DKK 995,00 WWW.ASOS.COM 00000 ;12-10-2012;-995,00;27939,54
|
5
|
+
12-09-2012;Dankort-nota B.J. TRADING E 14660;12-09-2012;-3452,90;26164,80
|
6
|
+
27-08-2012;Dankort-nota MATAS - 20319 18230;27-08-2012;-655,00;21127,45
|
@@ -0,0 +1,9 @@
|
|
1
|
+
01234567890;22/01/2014;CHEQUE 012345678901234578ABC000 0000 4381974748378178473744441;0000037;-10,00;
|
2
|
+
01234567890;22/01/2014;CHEQUE 012345678901937845500TS1 0000 7439816947047874387438445;0000038;-5,76;
|
3
|
+
01234567890;22/01/2014;CARTE 012345 CB:*0123456 XX XXXXXX XXX 33BORDEAUX;00X0X0X;-105,90;
|
4
|
+
01234567890;22/01/2014;CARTE 012345 CB:*0123456 XXXXXXXXXXX 33SAINT ANDRE D;00X0X0X;-39,99;
|
5
|
+
01234567890;22/01/2014;CARTE 012345 CB:*0123456 XXXXXXX XXXXX 33BORDEAUX;10X9X6X;-36,00;
|
6
|
+
01234567890;22/01/2014;PRLV XXXXXXXX ABONNEMENT XXXXXXXXXXXXXX.NET N.EMETTEUR: 324411;0XX0XXX;-40,00;
|
7
|
+
01234567890;21/01/2014;CARTE 012345 CB:*0123456 XXXXX XX33433ST ANDRE DE C;0POBUES;-47,12;
|
8
|
+
01234567890;21/01/2014;CARTE 012345 CB:*0123456 XXXXXXXXXXXX33433ST ANDRE DE C;0POBUER;-27,02;
|
9
|
+
01234567890;21/01/2014;CARTE 012345 CB:*0123456 XXXXXX XXXXXXXX33ST ANDRE 935/;0POBUEQ;-25,65;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
10-Nov-9,-123.12,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER MORTGAGE,0.00,
|
2
|
+
09-Nov-10,123.12,,,SALARY SALARY,NGHSKS46383BGDJKD FOO BAR,432.12,
|
3
|
+
04-Nov-11,-1234.00,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER SAV TO MECU,0.00,
|
4
|
+
04-Nov-9,1234.00,,,TRANSFER CREDIT INTERNET TRANSFER,INTERNET TRANSFER,1234.00,
|
5
|
+
28-Oct-10,-123.12,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER SAV TO MORTGAGE,0.00,
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"12/10/2014","Dn Ing Inv","[DN]ING INV/PLA","0.01","credit","Investments","Chequing","",""
|
2
|
+
"2/03/2014","Ds Lms Msp Condo","[DS]LMS598 MSP/DIV","331.63","debit","Condo Fees","Chequing","",""
|
3
|
+
"2/10/2014","Ib Granville","[IB] 2601 GRANVILLE","100.00","debit","Uncategorized","Chequing","",""
|
4
|
+
"2/06/2014","So Pa","[SO]PA 0005191230116379851","140.72","debit","Mortgage & Rent","Chequing","",""
|
5
|
+
"2/03/2014","Dn Sun Life","[DN]SUN LIFE MSP/DIV","943.34","credit","Income","Chequing","",""
|
6
|
+
"1/30/2014","Transfer to CBT (Savings)","[CW] TF 0004#3409-797","500.00","debit","Transfer","Chequing","",""
|
7
|
+
"1/30/2014","Costco","[PR]COSTCO WHOLESAL","559.96","debit","Business Services","Chequing","",""
|
@@ -0,0 +1,6 @@
|
|
1
|
+
-
|
2
|
+
="0234500012345678";21/11/2015;19/02/2016;36;19/02/2016;1234,37 EUR
|
3
|
+
|
4
|
+
Date de l'opération;Libellé;Détail de l'écriture;Montant de l'opération;Devise
|
5
|
+
19/02/2016;VIR RECU 508160;VIR RECU 1234567834S DE: Francois REF: 123457891234567894561231 PROVENANCE: DE Allemagne ;50,00;EUR
|
6
|
+
18/02/2016;COTISATION JAZZ;COTISATION JAZZ ;-8,10;EUR
|
@@ -0,0 +1,16 @@
|
|
1
|
+
2013/01/17,2013/01/16,2013011702,DEBIT,2226,"VODAFONE PREPAY VISA M AUCKLAND NZL",30.00
|
2
|
+
2013/01/18,2013/01/17,2013011801,DEBIT,2226,"WILSON PARKING AUCKLAND NZL",4.60
|
3
|
+
2013/01/18,2013/01/17,2013011802,DEBIT,2226,"AUCKLAND TRANSPORT HENDERSON NZL",2.00
|
4
|
+
2013/01/19,2013/01/19,2013011901,CREDIT,2226,"INTERNET PAYMENT RECEIVED ",-500.00
|
5
|
+
2013/01/26,2013/01/23,2013012601,DEBIT,2226,"ITUNES NZ CORK IRL",64.99
|
6
|
+
2013/01/26,2013/01/25,2013012602,DEBIT,2226,"VODAFONE FXFLNE BBND R NEWTON NZL",90.26
|
7
|
+
2013/01/29,2013/01/29,2013012901,CREDIT,2101,"PAYMENT RECEIVED THANK YOU ",-27.75
|
8
|
+
2013/01/30,2013/01/29,2013013001,DEBIT,2226,"AUCKLAND TRANSPORT HENDERSON NZL",3.50
|
9
|
+
2013/02/05,2013/02/03,2013020501,DEBIT,2226,"Z BEACH RD AUCKLAND NZL",129.89
|
10
|
+
2013/02/05,2013/02/03,2013020502,DEBIT,2226,"TOURNAMENT KHYBER PASS AUCKLAND NZL",8.00
|
11
|
+
2013/02/05,2013/02/04,2013020503,DEBIT,2226,"VODAFONE PREPAY VISA M AUCKLAND NZL",30.00
|
12
|
+
2013/02/08,2013/02/07,2013020801,DEBIT,2226,"AKLD TRANSPORT PARKING AUCKLAND NZL",2.50
|
13
|
+
2013/02/08,2013/02/07,2013020802,DEBIT,2226,"AUCKLAND TRANSPORT HENDERSON NZL",3.50
|
14
|
+
2013/02/12,2013/02/11,2013021201,DEBIT,2226,"AKLD TRANSPORT PARKING AUCKLAND NZL",1.50
|
15
|
+
2013/02/17,2013/02/17,2013021701,CREDIT,2226,"INTERNET PAYMENT RECEIVED ",-12.00
|
16
|
+
2013/02/17,2013/02/17,2013021702,CREDIT,2226,"INTERNET PAYMENT RECEIVED ",-18.00
|
@@ -0,0 +1,9 @@
|
|
1
|
+
DEBIT,2011/12/24,"HOST 037196321563 MO 12/22SLICEHOST",($85.00)
|
2
|
+
CHECK,2010/12/24,"CHECK 2656",($20.00)
|
3
|
+
DEBIT,2009/12/24,"GITHUB 041287430274 CA 12/22GITHUB 04",($7.00)
|
4
|
+
CREDIT,2008/12/24,"Some Company vendorpymt PPD ID: 59728JSL20",$3520.00
|
5
|
+
CREDIT,2007/12/24,"Blarg BLARG REVENUE PPD ID: 00jah78563",$1558.52
|
6
|
+
DEBIT,2006/12/24,"WEBSITE-BALANCE-17DEC09 12 12/17WEBSITE-BAL",$.23
|
7
|
+
DEBIT,2005/12/24,"WEBSITE-BALANCE-10DEC09 12 12/10WEBSITE-BAL",($0.96)
|
8
|
+
CREDIT,2004/12/24,"PAYPAL TRANSFER PPD ID: PAYPALSDSL",($116.22)
|
9
|
+
CREDIT,2003/12/24,"Some Company vendorpymt PPD ID: 5KL3832735",$2105.00
|
@@ -0,0 +1,7 @@
|
|
1
|
+
11/01/2014,0, Deposit,0,500.00,500.00
|
2
|
+
11/02/2014,101,Check,100.00,0,400.00
|
3
|
+
11/03/2014,102,Check,100.00,0,300.00
|
4
|
+
11/04/2014,103,Check,100.00,0,200.00
|
5
|
+
11/05/2014,104,Check,100.00,0,100.00
|
6
|
+
11/06/2014,105,Check,100.00,0,0.00
|
7
|
+
11/17/2014,0, Deposit,0,700.00,700.00
|
@@ -0,0 +1,5 @@
|
|
1
|
+
4/1/2008,Check - 0000000122,122,-$76.00,"","$1,750.06"
|
2
|
+
3/28/2008,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
|
3
|
+
3/27/2008,Check - 0000000112,112,-$800.00,"","$1,498.57"
|
4
|
+
3/26/2008,Check - 0000000251,251,-$88.55,"","$1,298.57"
|
5
|
+
3/26/2008,Check - 0000000251,251,"","+$88.55","$1,298.57"
|
@@ -0,0 +1 @@
|
|
1
|
+
DEBIT,20121231,"ODESK***BAL-27DEC12 650-12345 CA 12/28",-123.45
|
data/spec/reckon/app_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
2
|
|
4
3
|
require "spec_helper"
|
5
4
|
require 'rubygems'
|
@@ -8,18 +7,18 @@ require 'reckon'
|
|
8
7
|
describe Reckon::App do
|
9
8
|
context 'with chase csv input' do
|
10
9
|
before do
|
11
|
-
@chase = Reckon::App.new(:
|
12
|
-
@chase.learn_from(
|
10
|
+
@chase = Reckon::App.new(string: BANK_CSV)
|
11
|
+
@chase.learn_from(BANK_LEDGER)
|
13
12
|
@rows = []
|
14
|
-
@chase.each_row_backwards { |row| @rows.push(
|
13
|
+
@chase.each_row_backwards { |row| @rows.push(row) }
|
15
14
|
end
|
16
15
|
|
17
16
|
describe "each_row_backwards" do
|
18
17
|
it "should return rows with hashes" do
|
19
|
-
@rows[0][:pretty_date].should == "2009
|
18
|
+
@rows[0][:pretty_date].should == "2009-12-10"
|
20
19
|
@rows[0][:pretty_money].should == " $2105.00"
|
21
20
|
@rows[0][:description].should == "CREDIT; Some Company vendorpymt PPD ID: 5KL3832735"
|
22
|
-
@rows[1][:pretty_date].should == "2009
|
21
|
+
@rows[1][:pretty_date].should == "2009-12-11"
|
23
22
|
@rows[1][:pretty_money].should == "-$116.22"
|
24
23
|
@rows[1][:description].should == "CREDIT; PAYPAL TRANSFER PPD ID: PAYPALSDSL"
|
25
24
|
end
|
@@ -27,53 +26,117 @@ describe Reckon::App do
|
|
27
26
|
|
28
27
|
describe "weighted_account_match" do
|
29
28
|
it "should guess the correct account" do
|
30
|
-
|
29
|
+
row = @rows.find { |n| n[:description] =~ /Book Store/ }
|
30
|
+
|
31
|
+
result = @chase.matcher.find_similar(row[:description]).first
|
32
|
+
expect(result[:account]).to eq("Expenses:Books")
|
33
|
+
expect(result[:similarity]).to be > 0.0
|
31
34
|
end
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
35
38
|
context 'unattended mode with chase csv input' do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
let(:output_file) { StringIO.new }
|
40
|
+
let(:chase) {
|
41
|
+
Reckon::App.new(
|
42
|
+
string: BANK_CSV,
|
43
|
+
unattended: true,
|
44
|
+
output_file: output_file,
|
45
|
+
bank_account: 'Assets:Bank:Checking'
|
46
|
+
)
|
47
|
+
}
|
40
48
|
|
41
49
|
describe 'walk backwards' do
|
42
50
|
it 'should assign Income:Unknown and Expenses:Unknown by default' do
|
43
|
-
|
44
|
-
|
45
|
-
|
51
|
+
chase.walk_backwards
|
52
|
+
expect(output_file.string.scan('Expenses:Unknown').count).to eq(5)
|
53
|
+
expect(output_file.string.scan('Income:Unknown').count).to eq(4)
|
46
54
|
end
|
47
55
|
|
48
56
|
it 'should change default account names' do
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
+
chase = Reckon::App.new(
|
58
|
+
string: BANK_CSV,
|
59
|
+
unattended: true,
|
60
|
+
output_file: output_file,
|
61
|
+
default_into_account: 'Expenses:Default',
|
62
|
+
default_outof_account: 'Income:Default',
|
63
|
+
bank_account: 'Assets:Bank:Checking',
|
64
|
+
)
|
65
|
+
chase.walk_backwards
|
66
|
+
expect(output_file.string.scan('Expenses:Default').count).to eq(5)
|
67
|
+
expect(output_file.string.scan('Income:Default').count).to eq(4)
|
57
68
|
end
|
58
69
|
|
59
70
|
it 'should learn from a ledger file' do
|
60
|
-
|
61
|
-
|
62
|
-
|
71
|
+
chase.learn_from( BANK_LEDGER )
|
72
|
+
chase.walk_backwards
|
73
|
+
output_file.string.scan('Expenses:Books').count.should == 1
|
63
74
|
end
|
64
75
|
|
65
76
|
it 'should learn from an account tokens file and parse regexps' do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
77
|
+
chase = Reckon::App.new(
|
78
|
+
string: BANK_CSV,
|
79
|
+
unattended: true,
|
80
|
+
output_file: output_file,
|
81
|
+
account_tokens_file: fixture_path('tokens.yaml'),
|
82
|
+
bank_account: 'Assets:Bank:Checking',
|
83
|
+
)
|
84
|
+
chase.walk_backwards
|
85
|
+
expect(output_file.string.scan('Expenses:Books').count).to eq(1)
|
86
|
+
expect(output_file.string.scan('Expenses:Websites').count).to eq(2)
|
73
87
|
end
|
74
88
|
end
|
75
89
|
end
|
76
90
|
|
91
|
+
context "Issue #73 - regression test" do
|
92
|
+
it "should categorize transaction correctly" do
|
93
|
+
output = StringIO.new
|
94
|
+
app = Reckon::App.new(
|
95
|
+
file: fixture_path('73-sample.csv'),
|
96
|
+
unattended: true,
|
97
|
+
account_tokens_file: fixture_path('73-tokens.yml'),
|
98
|
+
bank_account: "Liabilities:Credit Cards:Visa",
|
99
|
+
contains_header: 1,
|
100
|
+
ignore_column: [4],
|
101
|
+
date_format: '%m/%d/%Y',
|
102
|
+
output_file: output
|
103
|
+
)
|
104
|
+
app.walk_backwards
|
105
|
+
|
106
|
+
expect(output.string).to include('Expenses:Automotive:Car Wash')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "Issue #64 - regression test" do
|
111
|
+
it 'should work for simple file' do
|
112
|
+
rows = []
|
113
|
+
app = Reckon::App.new(file: fixture_path('test_money_column.csv'))
|
114
|
+
expect { app.each_row_backwards { |n| rows << n } }
|
115
|
+
.to output(/Skipping row: 'Date, Note, Amount'/).to_stderr_from_any_process
|
116
|
+
expect(rows.length).to eq(2)
|
117
|
+
expect(rows[0][:pretty_date]).to eq('2012-03-22')
|
118
|
+
expect(rows[0][:pretty_money]).to eq(' $50.00')
|
119
|
+
expect(rows[1][:pretty_date]).to eq('2012-03-23')
|
120
|
+
expect(rows[1][:pretty_money]).to eq('-$10.00')
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'Issue #51 - regression test' do
|
125
|
+
it 'should assign correct accounts with tokens' do
|
126
|
+
output = StringIO.new
|
127
|
+
Reckon::App.new(
|
128
|
+
file: fixture_path('51-sample.csv'),
|
129
|
+
unattended: true,
|
130
|
+
account_tokens_file: fixture_path('51-tokens.yml'),
|
131
|
+
ignore_columns: [5],
|
132
|
+
bank_account: 'Assets:Chequing',
|
133
|
+
output_file: output
|
134
|
+
).walk_backwards
|
135
|
+
expect(output.string).not_to include('Income:Unknown')
|
136
|
+
expect(output.string.scan('Expenses:Dining:Resturant').size).to eq(8)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
77
140
|
#DATA
|
78
141
|
BANK_CSV = (<<-CSV).strip
|
79
142
|
DEBIT,20091224120000[0:GMT],"HOST 037196321563 MO 12/22SLICEHOST",-85.00
|
@@ -95,6 +158,5 @@ describe Reckon::App do
|
|
95
158
|
2004/05/27 Book Store
|
96
159
|
Expenses:Books $20.00
|
97
160
|
Liabilities:MasterCard
|
98
|
-
|
99
|
-
|
161
|
+
LEDGER
|
100
162
|
end
|
@@ -1,53 +1,74 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# coding: utf-8
|
3
3
|
|
4
|
-
|
4
|
+
require_relative "../spec_helper"
|
5
5
|
require 'rubygems'
|
6
|
-
|
7
|
-
|
8
|
-
Reckon::CSVParser.settings[:testing] = true
|
6
|
+
require_relative '../../lib/reckon'
|
9
7
|
|
10
8
|
describe Reckon::CSVParser do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@intuit_mint = Reckon::CSVParser.new(:string => INTUIT_MINT_EXAMPLE)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should be in testing mode" do
|
31
|
-
@chase.settings[:testing].should be_true
|
32
|
-
Reckon::CSVParser.settings[:testing].should be_true
|
33
|
-
end
|
9
|
+
let(:chase) { Reckon::CSVParser.new(file: fixture_path('chase.csv')) }
|
10
|
+
let(:some_other_bank) { Reckon::CSVParser.new(file: fixture_path('some_other.csv')) }
|
11
|
+
let(:two_money_columns) { Reckon::CSVParser.new(file: fixture_path('two_money_columns.csv')) }
|
12
|
+
let(:suntrust_csv) { Reckon::CSVParser.new(file: fixture_path('suntrust.csv')) }
|
13
|
+
let(:simple_csv) { Reckon::CSVParser.new(file: fixture_path('simple.csv')) }
|
14
|
+
let(:nationwide) { Reckon::CSVParser.new(file: fixture_path('nationwide.csv'), csv_separator: ',', suffixed: true, currency: "POUND") }
|
15
|
+
let(:german_date) { Reckon::CSVParser.new(file: fixture_path('german_date_example.csv')) }
|
16
|
+
let(:danish_kroner_nordea) { Reckon::CSVParser.new(file: fixture_path('danish_kroner_nordea_example.csv'), csv_separator: ';', comma_separates_cents: true) }
|
17
|
+
let(:yyyymmdd_date) { Reckon::CSVParser.new(file: fixture_path('yyyymmdd_date_example.csv')) }
|
18
|
+
let(:spanish_date) { Reckon::CSVParser.new(file: fixture_path('spanish_date_example.csv'), date_format: '%d/%m/%Y') }
|
19
|
+
let(:english_date) { Reckon::CSVParser.new(file: fixture_path('english_date_example.csv')) }
|
20
|
+
let(:ing_csv) { Reckon::CSVParser.new(file: fixture_path('ing.csv'), comma_separates_cents: true ) }
|
21
|
+
let(:austrian_csv) { Reckon::CSVParser.new(file: fixture_path('austrian_example.csv'), comma_separates_cents: true, csv_separator: ';' ) }
|
22
|
+
let(:french_csv) { Reckon::CSVParser.new(file: fixture_path('french_example.csv'), csv_separator: ';', comma_separates_cents: true) }
|
23
|
+
let(:broker_canada) { Reckon::CSVParser.new(file: fixture_path('broker_canada_example.csv')) }
|
24
|
+
let(:intuit_mint) { Reckon::CSVParser.new(file: fixture_path('intuit_mint_example.csv')) }
|
34
25
|
|
35
26
|
describe "parse" do
|
27
|
+
it "should use binary encoding if none specified and chardet fails" do
|
28
|
+
allow(CharDet).to receive(:detect).and_return({'encoding' => nil})
|
29
|
+
app = Reckon::CSVParser.new(file: fixture_path("extratofake.csv"))
|
30
|
+
expect(app.send(:try_encoding, "foobarbaz")).to eq("BINARY")
|
31
|
+
end
|
32
|
+
|
36
33
|
it "should work with foreign character encodings" do
|
37
|
-
app = Reckon::CSVParser.new(:
|
34
|
+
app = Reckon::CSVParser.new(file: fixture_path("extratofake.csv"))
|
38
35
|
app.columns[0][0..2].should == ["Data", "10/31/2012", "11/01/2012"]
|
39
|
-
app.columns[2].first.should == "
|
36
|
+
app.columns[2].first.should == "Histórico"
|
40
37
|
end
|
41
38
|
|
42
39
|
it "should work with other separators" do
|
43
40
|
Reckon::CSVParser.new(:string => "one;two\nthree;four", :csv_separator => ';').columns.should == [['one', 'three'], ['two', 'four']]
|
44
41
|
end
|
42
|
+
|
43
|
+
it 'should parse quoted lines' do
|
44
|
+
file = %q("30.03.2015";"29.03.2015";"09.04.2015";"BARAUSZAHLUNGSENTGELT";"5266 xxxx xxxx 9454";"";"0";"EUR";"0,00";"EUR";"-3,50";"0")
|
45
|
+
Reckon::CSVParser.new(string: file, csv_separator: ';', comma_separates_cents: true).columns.length.should == 12
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should parse csv with BOM' do
|
49
|
+
file = File.expand_path(fixture_path("bom_utf8_file.csv"))
|
50
|
+
Reckon::CSVParser.new(file: file).columns.length.should == 41
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'file with invalid csv in header' do
|
54
|
+
let(:invalid_file) { fixture_path('invalid_header_example.csv') }
|
55
|
+
|
56
|
+
it 'should ignore invalid header lines' do
|
57
|
+
Reckon::CSVParser.new(file: invalid_file, contains_header: 4)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should fail' do
|
61
|
+
expect { Reckon::CSVParser.new(file: invalid_file, contains_header: 1) }.to(
|
62
|
+
raise_error(CSV::MalformedCSVError)
|
63
|
+
)
|
64
|
+
end
|
65
|
+
end
|
45
66
|
end
|
46
67
|
|
47
68
|
describe "columns" do
|
48
69
|
it "should return the csv transposed" do
|
49
|
-
|
50
|
-
|
70
|
+
simple_csv.columns.should == [["entry1", "entry4"], ["entry2", "entry5"], ["entry3", "entry6"]]
|
71
|
+
chase.columns.length.should == 4
|
51
72
|
end
|
52
73
|
|
53
74
|
it "should be ok with empty lines" do
|
@@ -58,81 +79,89 @@ describe Reckon::CSVParser do
|
|
58
79
|
end
|
59
80
|
|
60
81
|
describe "detect_columns" do
|
61
|
-
|
62
|
-
@harder_date_example_csv = Reckon::CSVParser.new(:string => HARDER_DATE_EXAMPLE)
|
63
|
-
end
|
82
|
+
let(:harder_date_example_csv) { Reckon::CSVParser.new(file: fixture_path('harder_date_example.csv')) }
|
64
83
|
|
65
84
|
it "should detect the money column" do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
85
|
+
chase.money_column_indices.should == [3]
|
86
|
+
some_other_bank.money_column_indices.should == [3]
|
87
|
+
two_money_columns.money_column_indices.should == [3, 4]
|
88
|
+
suntrust_csv.money_column_indices.should == [3, 4]
|
89
|
+
nationwide.money_column_indices.should == [3, 4]
|
90
|
+
harder_date_example_csv.money_column_indices.should == [1]
|
91
|
+
danish_kroner_nordea.money_column_indices.should == [3]
|
92
|
+
yyyymmdd_date.money_column_indices.should == [3]
|
93
|
+
ing_csv.money_column_indices.should == [6]
|
94
|
+
austrian_csv.money_column_indices.should == [4]
|
95
|
+
french_csv.money_column_indices.should == [4]
|
96
|
+
broker_canada.money_column_indices.should == [8]
|
97
|
+
intuit_mint.money_column_indices.should == [3]
|
79
98
|
end
|
80
99
|
|
81
100
|
it "should detect the date column" do
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
101
|
+
chase.date_column_index.should == 1
|
102
|
+
some_other_bank.date_column_index.should == 1
|
103
|
+
two_money_columns.date_column_index.should == 0
|
104
|
+
harder_date_example_csv.date_column_index.should == 0
|
105
|
+
danish_kroner_nordea.date_column_index.should == 0
|
106
|
+
yyyymmdd_date.date_column_index.should == 1
|
107
|
+
french_csv.date_column_index.should == 1
|
108
|
+
broker_canada.date_column_index.should == 0
|
109
|
+
intuit_mint.date_column_index.should == 0
|
91
110
|
Reckon::CSVParser.new(:string => '2014-01-13,"22211100000",-10').date_column_index.should == 0
|
92
111
|
end
|
93
112
|
|
94
113
|
it "should consider all other columns to be description columns" do
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
114
|
+
chase.description_column_indices.should == [0, 2]
|
115
|
+
some_other_bank.description_column_indices.should == [0, 2]
|
116
|
+
two_money_columns.description_column_indices.should == [1, 2, 5]
|
117
|
+
harder_date_example_csv.description_column_indices.should == [2, 3, 4, 5, 6, 7]
|
118
|
+
danish_kroner_nordea.description_column_indices.should == [1, 2, 4]
|
119
|
+
yyyymmdd_date.description_column_indices.should == [0, 2]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "money_column_indicies" do
|
124
|
+
it "should prefer the option over the heuristic" do
|
125
|
+
chase = Reckon::CSVParser.new(file: fixture_path('chase.csv'))
|
126
|
+
expect(chase.money_column_indices).to eq([3])
|
127
|
+
|
128
|
+
chase = Reckon::CSVParser.new(file: fixture_path('chase.csv'), money_column: 2)
|
129
|
+
expect(chase.money_column_indices).to eq([1])
|
101
130
|
end
|
102
131
|
end
|
103
132
|
|
104
133
|
describe "money_for" do
|
105
134
|
it "should return the appropriate fields" do
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
135
|
+
chase.money_for(1).should == -20
|
136
|
+
chase.money_for(4).should == 1558.52
|
137
|
+
chase.money_for(7).should == -116.22
|
138
|
+
some_other_bank.money_for(1).should == -20
|
139
|
+
some_other_bank.money_for(4).should == 1558.52
|
140
|
+
some_other_bank.money_for(7).should == -116.22
|
141
|
+
two_money_columns.money_for(0).should == -76
|
142
|
+
two_money_columns.money_for(1).should == 327.49
|
143
|
+
two_money_columns.money_for(2).should == -800
|
144
|
+
two_money_columns.money_for(3).should == -88.55
|
145
|
+
two_money_columns.money_for(4).should == 88.55
|
146
|
+
nationwide.money_for(0).should == 500.00
|
147
|
+
nationwide.money_for(1).should == -20.00
|
148
|
+
danish_kroner_nordea.money_for(0).should == -48.00
|
149
|
+
danish_kroner_nordea.money_for(1).should == -79.00
|
150
|
+
danish_kroner_nordea.money_for(2).should == 497.90
|
151
|
+
danish_kroner_nordea.money_for(3).should == -995.00
|
152
|
+
danish_kroner_nordea.money_for(4).should == -3452.90
|
153
|
+
danish_kroner_nordea.money_for(5).should == -655.00
|
154
|
+
yyyymmdd_date.money_for(0).should == -123.45
|
155
|
+
ing_csv.money_for(0).should == -136.13
|
156
|
+
ing_csv.money_for(1).should == 375.00
|
157
|
+
austrian_csv.money_for(0).should == -18.00
|
158
|
+
austrian_csv.money_for(2).should == 120.00
|
159
|
+
french_csv.money_for(0).should == -10.00
|
160
|
+
french_csv.money_for(1).should == -5.76
|
161
|
+
broker_canada.money_for(0).should == 12.55
|
162
|
+
broker_canada.money_for(1).should == -81.57
|
163
|
+
intuit_mint.money_for(0).should == 0.01
|
164
|
+
intuit_mint.money_for(1).should == -331.63
|
136
165
|
end
|
137
166
|
|
138
167
|
it "should handle the comma_separates_cents option correctly" do
|
@@ -142,71 +171,85 @@ describe Reckon::CSVParser do
|
|
142
171
|
end
|
143
172
|
|
144
173
|
it "should return negated values if the inverse option is passed" do
|
145
|
-
inversed_csv = Reckon::CSVParser.new(:
|
174
|
+
inversed_csv = Reckon::CSVParser.new(file: fixture_path('inversed_credit_card.csv'), inverse: true)
|
146
175
|
inversed_csv.money_for(0).should == -30.00
|
147
176
|
inversed_csv.money_for(3).should == 500.00
|
148
177
|
end
|
149
178
|
end
|
150
179
|
|
180
|
+
describe "date_column_index" do
|
181
|
+
it "should prefer the option over the heuristic" do
|
182
|
+
chase = Reckon::CSVParser.new(file: fixture_path('chase.csv'))
|
183
|
+
expect(chase.date_column_index).to eq(1)
|
184
|
+
|
185
|
+
chase = Reckon::CSVParser.new(file: fixture_path('chase.csv'), date_column: 3)
|
186
|
+
expect(chase.date_column_index).to eq(2)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
151
190
|
describe "date_for" do
|
152
191
|
it "should return a parsed date object" do
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
192
|
+
chase.date_for(1).year.should == Time.parse("2009/12/24").year
|
193
|
+
chase.date_for(1).month.should == Time.parse("2009/12/24").month
|
194
|
+
chase.date_for(1).day.should == Time.parse("2009/12/24").day
|
195
|
+
some_other_bank.date_for(1).year.should == Time.parse("2010/12/24").year
|
196
|
+
some_other_bank.date_for(1).month.should == Time.parse("2010/12/24").month
|
197
|
+
some_other_bank.date_for(1).day.should == Time.parse("2010/12/24").day
|
198
|
+
german_date.date_for(1).year.should == Time.parse("2009/12/24").year
|
199
|
+
german_date.date_for(1).month.should == Time.parse("2009/12/24").month
|
200
|
+
german_date.date_for(1).day.should == Time.parse("2009/12/24").day
|
201
|
+
danish_kroner_nordea.date_for(0).year.should == Time.parse("2012/11/16").year
|
202
|
+
danish_kroner_nordea.date_for(0).month.should == Time.parse("2012/11/16").month
|
203
|
+
danish_kroner_nordea.date_for(0).day.should == Time.parse("2012/11/16").day
|
204
|
+
yyyymmdd_date.date_for(0).year.should == Time.parse("2012/12/31").year
|
205
|
+
yyyymmdd_date.date_for(0).month.should == Time.parse("2012/12/31").month
|
206
|
+
yyyymmdd_date.date_for(0).day.should == Time.parse("2012/12/31").day
|
207
|
+
spanish_date.date_for(1).year.should == Time.parse("2009/12/02").year
|
208
|
+
spanish_date.date_for(1).month.should == Time.parse("2009/12/02").month
|
209
|
+
spanish_date.date_for(1).day.should == Time.parse("2009/12/02").day
|
210
|
+
english_date.date_for(1).year.should == Time.parse("2009/12/24").year
|
211
|
+
english_date.date_for(1).month.should == Time.parse("2009/12/24").month
|
212
|
+
english_date.date_for(1).day.should == Time.parse("2009/12/24").day
|
213
|
+
nationwide.date_for(1).month.should == 10
|
214
|
+
ing_csv.date_for(1).month.should == Time.parse("2012/11/12").month
|
215
|
+
ing_csv.date_for(1).day.should == Time.parse("2012/11/12").day
|
216
|
+
broker_canada.date_for(5).year.should == 2014
|
217
|
+
broker_canada.date_for(5).month.should == 1
|
218
|
+
broker_canada.date_for(5).day.should == 7
|
219
|
+
intuit_mint.date_for(1).year.should == 2014
|
220
|
+
intuit_mint.date_for(1).month.should == 2
|
221
|
+
intuit_mint.date_for(1).day.should == 3
|
183
222
|
end
|
184
223
|
end
|
185
224
|
|
186
225
|
describe "description_for" do
|
187
226
|
it "should return the combined fields that are not money for date fields" do
|
188
|
-
|
189
|
-
|
227
|
+
chase.description_for(1).should == "CHECK; CHECK 2656"
|
228
|
+
chase.description_for(7).should == "CREDIT; PAYPAL TRANSFER PPD ID: PAYPALSDSL"
|
190
229
|
end
|
191
230
|
|
192
231
|
it "should not append empty description column" do
|
193
232
|
parser = Reckon::CSVParser.new(:string => '01/09/2015,05354 SUBWAY,8.19,,',:date_format => '%d/%m/%Y')
|
194
|
-
parser.description_column_indices.should == [1, 4]
|
195
233
|
parser.description_for(0).should == '05354 SUBWAY'
|
196
234
|
end
|
235
|
+
|
236
|
+
it "should handle nil description" do
|
237
|
+
parser = Reckon::CSVParser.new(string: '2015-09-01,test,3.99')
|
238
|
+
expect(parser.description_for(1)).to eq("")
|
239
|
+
end
|
197
240
|
end
|
198
241
|
|
199
242
|
describe "pretty_money_for" do
|
200
243
|
it "work with negative and positive numbers" do
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
244
|
+
some_other_bank.pretty_money_for(1).should == "-$20.00"
|
245
|
+
some_other_bank.pretty_money_for(4).should == " $1558.52"
|
246
|
+
some_other_bank.pretty_money_for(7).should == "-$116.22"
|
247
|
+
some_other_bank.pretty_money_for(5).should == " $0.23"
|
248
|
+
some_other_bank.pretty_money_for(6).should == "-$0.96"
|
206
249
|
end
|
207
250
|
|
208
251
|
it "work with other currencies such as €" do
|
209
|
-
euro_bank = Reckon::CSVParser.new(:
|
252
|
+
euro_bank = Reckon::CSVParser.new(file: fixture_path('some_other.csv'), currency: "€", suffixed: false )
|
210
253
|
euro_bank.pretty_money_for(1).should == "-€20.00"
|
211
254
|
euro_bank.pretty_money_for(4).should == " €1558.52"
|
212
255
|
euro_bank.pretty_money_for(7).should == "-€116.22"
|
@@ -215,7 +258,7 @@ describe Reckon::CSVParser do
|
|
215
258
|
end
|
216
259
|
|
217
260
|
it "work with suffixed currencies such as SEK" do
|
218
|
-
swedish_bank = Reckon::CSVParser.new(:
|
261
|
+
swedish_bank = Reckon::CSVParser.new(file: fixture_path('some_other.csv'), currency: 'SEK', suffixed: true )
|
219
262
|
swedish_bank.pretty_money_for(1).should == "-20.00 SEK"
|
220
263
|
swedish_bank.pretty_money_for(4).should == " 1558.52 SEK"
|
221
264
|
swedish_bank.pretty_money_for(7).should == "-116.22 SEK"
|
@@ -224,180 +267,15 @@ describe Reckon::CSVParser do
|
|
224
267
|
end
|
225
268
|
|
226
269
|
it "should work with merge columns" do
|
227
|
-
|
228
|
-
|
270
|
+
nationwide.pretty_money_for(0).should == " 500.00 POUND"
|
271
|
+
nationwide.pretty_money_for(1).should == "-20.00 POUND"
|
229
272
|
end
|
230
273
|
end
|
231
274
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
CHECK,20091224120000[0:GMT],"CHECK 2656",-20.00
|
239
|
-
DEBIT,20091224120000[0:GMT],"GITHUB 041287430274 CA 12/22GITHUB 04",-7.00
|
240
|
-
CREDIT,20091223120000[0:GMT],"Some Company vendorpymt PPD ID: 59728JSL20",3520.00
|
241
|
-
CREDIT,20091223120000[0:GMT],"Blarg BLARG REVENUE PPD ID: 00jah78563",1558.52
|
242
|
-
DEBIT,20091221120000[0:GMT],"WEBSITE-BALANCE-17DEC09 12 12/17WEBSITE-BAL",-12.23
|
243
|
-
DEBIT,20091214120000[0:GMT],"WEBSITE-BALANCE-10DEC09 12 12/10WEBSITE-BAL",-20.96
|
244
|
-
CREDIT,20091211120000[0:GMT],"PAYPAL TRANSFER PPD ID: PAYPALSDSL",-116.22
|
245
|
-
CREDIT,20091210120000[0:GMT],"Some Company vendorpymt PPD ID: 5KL3832735",2105.00
|
246
|
-
CSV
|
247
|
-
|
248
|
-
SOME_OTHER_CSV = (<<-CSV).strip
|
249
|
-
DEBIT,2011/12/24,"HOST 037196321563 MO 12/22SLICEHOST",($85.00)
|
250
|
-
CHECK,2010/12/24,"CHECK 2656",($20.00)
|
251
|
-
DEBIT,2009/12/24,"GITHUB 041287430274 CA 12/22GITHUB 04",($7.00)
|
252
|
-
CREDIT,2008/12/24,"Some Company vendorpymt PPD ID: 59728JSL20",$3520.00
|
253
|
-
CREDIT,2007/12/24,"Blarg BLARG REVENUE PPD ID: 00jah78563",$1558.52
|
254
|
-
DEBIT,2006/12/24,"WEBSITE-BALANCE-17DEC09 12 12/17WEBSITE-BAL",$.23
|
255
|
-
DEBIT,2005/12/24,"WEBSITE-BALANCE-10DEC09 12 12/10WEBSITE-BAL",($0.96)
|
256
|
-
CREDIT,2004/12/24,"PAYPAL TRANSFER PPD ID: PAYPALSDSL",($116.22)
|
257
|
-
CREDIT,2003/12/24,"Some Company vendorpymt PPD ID: 5KL3832735",$2105.00
|
258
|
-
CSV
|
259
|
-
|
260
|
-
INVERSED_CREDIT_CARD = (<<-CSV).strip
|
261
|
-
2013/01/17,2013/01/16,2013011702,DEBIT,2226,"VODAFONE PREPAY VISA M AUCKLAND NZL",30.00
|
262
|
-
2013/01/18,2013/01/17,2013011801,DEBIT,2226,"WILSON PARKING AUCKLAND NZL",4.60
|
263
|
-
2013/01/18,2013/01/17,2013011802,DEBIT,2226,"AUCKLAND TRANSPORT HENDERSON NZL",2.00
|
264
|
-
2013/01/19,2013/01/19,2013011901,CREDIT,2226,"INTERNET PAYMENT RECEIVED ",-500.00
|
265
|
-
2013/01/26,2013/01/23,2013012601,DEBIT,2226,"ITUNES NZ CORK IRL",64.99
|
266
|
-
2013/01/26,2013/01/25,2013012602,DEBIT,2226,"VODAFONE FXFLNE BBND R NEWTON NZL",90.26
|
267
|
-
2013/01/29,2013/01/29,2013012901,CREDIT,2101,"PAYMENT RECEIVED THANK YOU ",-27.75
|
268
|
-
2013/01/30,2013/01/29,2013013001,DEBIT,2226,"AUCKLAND TRANSPORT HENDERSON NZL",3.50
|
269
|
-
2013/02/05,2013/02/03,2013020501,DEBIT,2226,"Z BEACH RD AUCKLAND NZL",129.89
|
270
|
-
2013/02/05,2013/02/03,2013020502,DEBIT,2226,"TOURNAMENT KHYBER PASS AUCKLAND NZL",8.00
|
271
|
-
2013/02/05,2013/02/04,2013020503,DEBIT,2226,"VODAFONE PREPAY VISA M AUCKLAND NZL",30.00
|
272
|
-
2013/02/08,2013/02/07,2013020801,DEBIT,2226,"AKLD TRANSPORT PARKING AUCKLAND NZL",2.50
|
273
|
-
2013/02/08,2013/02/07,2013020802,DEBIT,2226,"AUCKLAND TRANSPORT HENDERSON NZL",3.50
|
274
|
-
2013/02/12,2013/02/11,2013021201,DEBIT,2226,"AKLD TRANSPORT PARKING AUCKLAND NZL",1.50
|
275
|
-
2013/02/17,2013/02/17,2013021701,CREDIT,2226,"INTERNET PAYMENT RECEIVED ",-12.00
|
276
|
-
2013/02/17,2013/02/17,2013021702,CREDIT,2226,"INTERNET PAYMENT RECEIVED ",-18.00
|
277
|
-
CSV
|
278
|
-
|
279
|
-
TWO_MONEY_COLUMNS_BANK = (<<-CSV).strip
|
280
|
-
4/1/2008,Check - 0000000122,122,-$76.00,"","$1,750.06"
|
281
|
-
3/28/2008,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
|
282
|
-
3/27/2008,Check - 0000000112,112,-$800.00,"","$1,498.57"
|
283
|
-
3/26/2008,Check - 0000000251,251,-$88.55,"","$1,298.57"
|
284
|
-
3/26/2008,Check - 0000000251,251,"","+$88.55","$1,298.57"
|
285
|
-
CSV
|
286
|
-
|
287
|
-
SUNTRUST_CSV = (<<-CSV).strip
|
288
|
-
11/01/2014,0, Deposit,0,500.00,500.00
|
289
|
-
11/02/2014,101,Check,100.00,0,400.00
|
290
|
-
11/03/2014,102,Check,100.00,0,300.00
|
291
|
-
11/04/2014,103,Check,100.00,0,200.00
|
292
|
-
11/05/2014,104,Check,100.00,0,100.00
|
293
|
-
11/06/2014,105,Check,100.00,0,0.00
|
294
|
-
11/17/2014,0, Deposit,0,700.00,700.00
|
295
|
-
CSV
|
296
|
-
|
297
|
-
NATIONWIDE_CSV = (<<-CSV).strip
|
298
|
-
07 Nov 2013,Bank credit,Bank credit,,£500.00,£500.00
|
299
|
-
09 Oct 2013,ATM Withdrawal,Withdrawal,£20.00,,£480.00
|
300
|
-
09 Dec 2013,Visa,Supermarket,£19.77,,£460.23
|
301
|
-
10 Dec 2013,ATM Withdrawal 2,ATM Withdrawal 4,£100.00,,£360.23
|
302
|
-
CSV
|
303
|
-
|
304
|
-
ING_CSV = (<<-CSV).strip
|
305
|
-
20121115,From1,Acc,T1,IC,Af,"136,13",Incasso,SEPA Incasso, Opm1
|
306
|
-
20121112,Names,NL28 INGB 1200 3244 16,21817,GT,Bij,"375,00", Opm2
|
307
|
-
20091117,Names,NL28 INGB 1200 3244 16,21817,GT,Af,"257,50", Opm3
|
308
|
-
CSV
|
309
|
-
|
310
|
-
HARDER_DATE_EXAMPLE = (<<-CSV).strip
|
311
|
-
10-Nov-9,-123.12,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER MORTGAGE,0.00,
|
312
|
-
09-Nov-10,123.12,,,SALARY SALARY,NGHSKS46383BGDJKD FOO BAR,432.12,
|
313
|
-
04-Nov-11,-1234.00,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER SAV TO MECU,0.00,
|
314
|
-
04-Nov-9,1234.00,,,TRANSFER CREDIT INTERNET TRANSFER,INTERNET TRANSFER,1234.00,
|
315
|
-
28-Oct-10,-123.12,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER SAV TO MORTGAGE,0.00,
|
316
|
-
CSV
|
317
|
-
|
318
|
-
GERMAN_DATE_EXAMPLE = (<<-CSV).strip
|
319
|
-
24.12.2009,Check - 0000000122,122,-$76.00,"","$1,750.06"
|
320
|
-
24.12.2009,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
|
321
|
-
24.12.2009,Check - 0000000112,112,-$800.00,"","$1,498.57"
|
322
|
-
CSV
|
323
|
-
|
324
|
-
DANISH_KRONER_NORDEA_EXAMPLE = (<<-CSV).strip
|
325
|
-
16-11-2012;Dankort-nota DSB Kobenhavn 15149;16-11-2012;-48,00;26550,33
|
326
|
-
26-10-2012;Dankort-nota Ziggy Cafe 19471;26-10-2012;-79,00;26054,54
|
327
|
-
22-10-2012;Dankort-nota H&M Hennes & M 10681;23-10-2012;497,90;25433,54
|
328
|
-
12-10-2012;Visa kob DKK 995,00 WWW.ASOS.COM 00000 ;12-10-2012;-995,00;27939,54
|
329
|
-
12-09-2012;Dankort-nota B.J. TRADING E 14660;12-09-2012;-3452,90;26164,80
|
330
|
-
27-08-2012;Dankort-nota MATAS - 20319 18230;27-08-2012;-655,00;21127,45
|
331
|
-
CSV
|
332
|
-
|
333
|
-
YYYYMMDD_DATE_EXAMPLE = (<<-CSV).strip
|
334
|
-
DEBIT,20121231,"ODESK***BAL-27DEC12 650-12345 CA 12/28",-123.45
|
335
|
-
CSV
|
336
|
-
|
337
|
-
SPANISH_DATE_EXAMPLE = (<<-CSV).strip
|
338
|
-
02/12/2009,Check - 0000000122,122,-$76.00,"","$1,750.06"
|
339
|
-
02/12/2009,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
|
340
|
-
02/12/2009,Check - 0000000112,112,-$800.00,"","$1,498.57"
|
341
|
-
CSV
|
342
|
-
|
343
|
-
ENGLISH_DATE_EXAMPLE = (<<-CSV).strip
|
344
|
-
24/12/2009,Check - 0000000122,122,-$76.00,"","$1,750.06"
|
345
|
-
24/12/2009,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
|
346
|
-
24/12/2009,Check - 0000000112,112,-$800.00,"","$1,498.57"
|
347
|
-
CSV
|
348
|
-
|
349
|
-
AUSTRIAN_EXAMPLE = (<<-CSV).strip
|
350
|
-
00075757575;Abbuchung Onlinebanking 654321098765 BG/000002462 BICBICBI AT654000000065432109 Thematische Universität Stadt ;22.01.2014;22.01.2014;-18,00;EUR
|
351
|
-
00075757575;333222111333222 222111333222 OG/000002461 BICBICBIXXX AT333000000003332221 Telekom Land AG RECHNUNG 11/13 333222111333222 ;17.01.2014;17.01.2014;-9,05;EUR
|
352
|
-
00075757575;Helm BG/000002460 10000 00007878787 Muster Dr.Beispiel-Vorname ;15.01.2014;15.01.2014;+120,00;EUR
|
353
|
-
00075757575;Gutschrift Dauerauftrag BG/000002459 BICBICBI AT787000000007878787 Muster Dr.Beispiel-Vorname ;15.01.2014;15.01.2014;+22,00;EUR
|
354
|
-
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
|
355
|
-
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
|
356
|
-
00075757575;050055556666000 OG/000002456 BKAUATWWXXX AT555500000555566665 JKL Telekommm Stadt GmbH JKL Rechnung 555666555 ;03.01.2014;03.01.2014;-17,15;EUR
|
357
|
-
00075757575;Abbuchung Einzugsermächtigung OG/000002455 INTERNATIONALER AUTOMOBIL-, 10000 00006655665 ;02.01.2014;02.01.2014;-17,40;EUR
|
358
|
-
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
|
359
|
-
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
|
360
|
-
00075757575;Anlass VD/000002452 BKAUATWWBRN AT808800080880880880 Dipl.Ing.Dr. Berta Beispiel ;02.01.2014;02.01.2014;+61,90;EUR
|
361
|
-
00075757575;Abbuchung Onlinebanking 000009999999 BG/000002451 BICBICBI AT099000000009999999 Asdfjklöasdf Asdfjklöasdfjklöasdf ;02.01.2014;02.01.2014;-104,69;EUR
|
362
|
-
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
|
363
|
-
CSV
|
364
|
-
|
365
|
-
FRENCH_EXAMPLE = (<<-CSV).strip
|
366
|
-
01234567890;22/01/2014;22/01/2014;CHEQUE 012345678901234578ABC000 0000 4381974748378178473744441;0000037;22/01/2014;-10,00;
|
367
|
-
01234567890;22/01/2014;22/01/2014;CHEQUE 012345678901937845500TS1 0000 7439816947047874387438445;0000038;22/01/2014;-5,76;
|
368
|
-
01234567890;22/01/2014;22/01/2014;CARTE 012345 CB:*0123456 XX XXXXXX XXX 33BORDEAUX;00X0X0X;22/01/2014;-105,90;
|
369
|
-
01234567890;22/01/2014;22/01/2014;CARTE 012345 CB:*0123456 XXXXXXXXXXX 33SAINT ANDRE D;00X0X0X;22/01/2014;-39,99;
|
370
|
-
01234567890;22/01/2014;22/01/2014;CARTE 012345 CB:*0123456 XXXXXXX XXXXX 33BORDEAUX;10X9X6X;22/01/2014;-36,00;
|
371
|
-
01234567890;22/01/2014;22/01/2014;PRLV XXXXXXXX ABONNEMENT XXXXXXXXXXXXXX.NET N.EMETTEUR: 324411;0XX0XXX;22/01/2014;-40,00;
|
372
|
-
01234567890;21/01/2014;21/01/2014;CARTE 012345 CB:*0123456 XXXXX XX33433ST ANDRE DE C;0POBUES;21/01/2014;-47,12;
|
373
|
-
01234567890;21/01/2014;21/01/2014;CARTE 012345 CB:*0123456 XXXXXXXXXXXX33433ST ANDRE DE C;0POBUER;21/01/2014;-27,02;
|
374
|
-
01234567890;21/01/2014;21/01/2014;CARTE 012345 CB:*0123456 XXXXXX XXXXXXXX33ST ANDRE 935/;0POBUEQ;21/01/2014;-25,65;
|
375
|
-
CSV
|
376
|
-
|
377
|
-
BROKER_CANADA_EXAMPLE = (<<-CSV).strip
|
378
|
-
2014-02-10,2014-02-10,Interest,ISHARES S&P/TSX CAPPED REIT IN,XRE,179,,,12.55,CAD
|
379
|
-
2014-01-16,2014-01-16,Reinvestment,ISHARES GLOBAL AGRICULTURE IND,COW,3,,,-81.57,CAD
|
380
|
-
2014-01-16,2014-01-16,Contribution,CONTRIBUTION,,,,,600.00,CAD
|
381
|
-
2014-01-16,2014-01-16,Interest,ISHARES GLOBAL AGRICULTURE IND,COW,200,,,87.05,CAD
|
382
|
-
2014-01-14,2014-01-14,Reinvestment,BMO NASDAQ 100 EQTY HEDGED TO,ZQQ,2,,,-54.72,CAD
|
383
|
-
2014-01-07,2014-01-10,Sell,BMO NASDAQ 100 EQTY HEDGED TO,ZQQ,-300,27.44,CDN,8222.05,CAD
|
384
|
-
2014-01-07,2014-01-07,Interest,BMO S&P/TSX EQUAL WEIGHT BKS I,ZEB,250,,,14.00,CAD
|
385
|
-
2013-07-02,2013-07-02,Dividend,SELECT SECTOR SPDR FD SHS BEN,XLB,130,,,38.70,USD
|
386
|
-
2013-06-27,2013-06-27,Dividend,ICICI BK SPONSORED ADR,IBN,100,,,66.70,USD
|
387
|
-
2013-06-19,2013-06-24,Buy,ISHARES S&P/TSX CAPPED REIT IN,XRE,300,15.90,CDN,-4779.95,CAD
|
388
|
-
2013-06-17,2013-06-17,Contribution,CONTRIBUTION,,,,,600.00,CAD
|
389
|
-
2013-05-22,2013-05-22,Dividend,NATBK,NA,70,,,58.10,CAD
|
390
|
-
CSV
|
391
|
-
|
392
|
-
INTUIT_MINT_EXAMPLE = (<<-CSV).strip
|
393
|
-
"12/10/2014","Dn Ing Inv","[DN]ING INV/PLA","0.01","credit","Investments","Chequing","",""
|
394
|
-
"2/03/2014","Ds Lms Msp Condo","[DS]LMS598 MSP/DIV","331.63","debit","Condo Fees","Chequing","",""
|
395
|
-
"2/10/2014","Ib Granville","[IB] 2601 GRANVILLE","100.00","debit","Uncategorized","Chequing","",""
|
396
|
-
"2/06/2014","So Pa","[SO]PA 0005191230116379851","140.72","debit","Mortgage & Rent","Chequing","",""
|
397
|
-
"2/03/2014","Dn Sun Life","[DN]SUN LIFE MSP/DIV","943.34","credit","Income","Chequing","",""
|
398
|
-
"1/30/2014","Transfer to CBT (Savings)","[CW] TF 0004#3409-797","500.00","debit","Transfer","Chequing","",""
|
399
|
-
"1/30/2014","Costco","[PR]COSTCO WHOLESAL","559.96","debit","Business Services","Chequing","",""
|
400
|
-
CSV
|
401
|
-
|
402
|
-
|
275
|
+
describe '85 regression test' do
|
276
|
+
it 'should detect correct date column' do
|
277
|
+
p = Reckon::CSVParser.new(file:fixture_path('85-date-example.csv'))
|
278
|
+
expect(p.date_column_index).to eq(2)
|
279
|
+
end
|
280
|
+
end
|
403
281
|
end
|