qiflib 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +39 -1
- data/html/Qiflib/Transaction.html +29 -35
- data/html/Qiflib/Util.html +53 -13
- data/html/Qiflib.html +39 -0
- data/html/README_rdoc.html +57 -20
- data/html/index.html +55 -19
- data/html/table_of_contents.html +12 -7
- data/lib/qiflib_constants.rb +10 -2
- data/lib/qiflib_transaction.rb +39 -45
- data/lib/qiflib_util.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b8600ed538280b36f811b9b4c603d2fd5e40317
|
4
|
+
data.tar.gz: dee8262aea5d8fd3cf9b89e4e5e304ffef147afe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 888f86ad1cb9e7c0140cfa4114456fe254c7a9a9d5465b7fb231f1f64dd5e6014083e2852dcaf47a9f5a5ccf57c0a7a59c627022374795b38890003c194f228b
|
7
|
+
data.tar.gz: aa2043e1cbdabf68effdda559a7d7b021375059e17aa3592cd2de4f892eb966c7f7af49b1b999b1d3dc734d97e6a86b3371866f1f0e704c1a0b381821e0e3f0b
|
data/README.rdoc
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
== Qiflib
|
1
|
+
== Qiflib
|
2
|
+
|
3
|
+
version 0.4.0, released 12-14-2013
|
2
4
|
|
3
5
|
A ruby library for reading and parsing qif files.
|
4
6
|
|
@@ -11,6 +13,10 @@ Category-name parsing is also supported.
|
|
11
13
|
Also includes DDL generation for importing the parsed categories and
|
12
14
|
transactions into a sqlite3 database.
|
13
15
|
|
16
|
+
Version 0.4.0 includes support for iBank version 4.7.5, this version
|
17
|
+
exports silightly differently than previous versions.
|
18
|
+
|
19
|
+
|
14
20
|
== Install
|
15
21
|
|
16
22
|
gem install qiflib
|
@@ -132,6 +138,38 @@ transactions into a sqlite3 database.
|
|
132
138
|
.import private/qiflib_categories.txt categories
|
133
139
|
|
134
140
|
|
141
|
+
== CSV fields
|
142
|
+
|
143
|
+
csv field index 0 = id
|
144
|
+
csv field index 1 = acct_owner
|
145
|
+
csv field index 2 = acct_name
|
146
|
+
csv field index 3 = acct_type
|
147
|
+
csv field index 4 = date
|
148
|
+
csv field index 5 = amount
|
149
|
+
csv field index 6 = number
|
150
|
+
csv field index 7 = ibank_n
|
151
|
+
csv field index 8 = cleared
|
152
|
+
csv field index 9 = payee
|
153
|
+
csv field index 10 = category
|
154
|
+
csv field index 11 = memo
|
155
|
+
csv field index 12 = split1_amount
|
156
|
+
csv field index 13 = split1_category
|
157
|
+
csv field index 14 = split1_memo
|
158
|
+
csv field index 15 = split2_amount
|
159
|
+
csv field index 16 = split2_category
|
160
|
+
csv field index 17 = split2_memo
|
161
|
+
csv field index 18 = split3_amount
|
162
|
+
csv field index 19 = split3_category
|
163
|
+
csv field index 20 = split3_memo
|
164
|
+
csv field index 21 = address1
|
165
|
+
csv field index 22 = address2
|
166
|
+
csv field index 23 = address3
|
167
|
+
csv field index 24 = address4
|
168
|
+
csv field index 25 = address5
|
169
|
+
csv field index 26 = address6
|
170
|
+
csv field index 27 = eol_ind
|
171
|
+
|
172
|
+
|
135
173
|
== Generated shell script
|
136
174
|
|
137
175
|
# bash-shell script
|
@@ -383,7 +383,7 @@ section of a qif file.</p>
|
|
383
383
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">csv_header</span>
|
384
384
|
<span class="ruby-constant">CSV</span>.<span class="ruby-identifier">generate</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">csv</span> <span class="ruby-operator">|</span>
|
385
385
|
<span class="ruby-identifier">csv</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-identifier">csv_transaction_field_names</span>
|
386
|
-
<span class="ruby-keyword">end</span>
|
386
|
+
<span class="ruby-keyword">end</span>
|
387
387
|
<span class="ruby-keyword">end</span></pre>
|
388
388
|
</div><!-- csv_header-source -->
|
389
389
|
|
@@ -465,18 +465,18 @@ section of a qif file.</p>
|
|
465
465
|
<span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span>
|
466
466
|
<span class="ruby-identifier">stripped</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip</span>
|
467
467
|
<span class="ruby-keyword">if</span> <span class="ruby-identifier">stripped</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
468
|
-
<span class="ruby-comment"># Field Indicator Explanations
|
469
|
-
<span class="ruby-comment"># D Date
|
470
|
-
<span class="ruby-comment"># T Amount
|
471
|
-
<span class="ruby-comment"># C Cleared status
|
472
|
-
<span class="ruby-comment"># N Num (check or reference number)
|
473
|
-
<span class="ruby-comment"># P Payee
|
474
|
-
<span class="ruby-comment"># M Memo
|
468
|
+
<span class="ruby-comment"># Field Indicator Explanations:</span>
|
469
|
+
<span class="ruby-comment"># D Date</span>
|
470
|
+
<span class="ruby-comment"># T Amount</span>
|
471
|
+
<span class="ruby-comment"># C Cleared status</span>
|
472
|
+
<span class="ruby-comment"># N Num (check or reference number)</span>
|
473
|
+
<span class="ruby-comment"># P Payee</span>
|
474
|
+
<span class="ruby-comment"># M Memo</span>
|
475
475
|
<span class="ruby-comment"># A Address (up to five lines; the sixth line is an optional message)</span>
|
476
|
-
<span class="ruby-comment"># L Category (Category/Subcategory/Transfer/Class)
|
477
|
-
<span class="ruby-comment"># S Category in split (Category/Transfer/Class)
|
478
|
-
<span class="ruby-comment"># E Memo in split
|
479
|
-
<span class="ruby-comment"># $ Dollar amount of split
|
476
|
+
<span class="ruby-comment"># L Category (Category/Subcategory/Transfer/Class)</span>
|
477
|
+
<span class="ruby-comment"># S Category in split (Category/Transfer/Class)</span>
|
478
|
+
<span class="ruby-comment"># E Memo in split</span>
|
479
|
+
<span class="ruby-comment"># $ Dollar amount of split</span>
|
480
480
|
<span class="ruby-comment"># ^ End of the entry</span>
|
481
481
|
<span class="ruby-keyword">if</span> (<span class="ruby-identifier">stripped</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^D/</span>))
|
482
482
|
<span class="ruby-ivar">@date</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Date</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>))
|
@@ -485,22 +485,16 @@ section of a qif file.</p>
|
|
485
485
|
<span class="ruby-keyword">elsif</span> (<span class="ruby-identifier">stripped</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^P/</span>))
|
486
486
|
<span class="ruby-ivar">@payee</span> = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>)
|
487
487
|
<span class="ruby-keyword">elsif</span> (<span class="ruby-identifier">stripped</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^C/</span>))
|
488
|
-
<span class="ruby-
|
489
|
-
<span class="ruby-ivar">@number</span> = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>)
|
490
|
-
<span class="ruby-keyword">else</span>
|
491
|
-
<span class="ruby-ivar">@cleared</span> = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>)
|
492
|
-
<span class="ruby-keyword">end</span>
|
488
|
+
<span class="ruby-ivar">@cleared</span> = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>)
|
493
489
|
<span class="ruby-keyword">elsif</span> (<span class="ruby-identifier">stripped</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^N/</span>))
|
494
|
-
<span class="ruby-
|
495
|
-
|
496
|
-
<span class="ruby-keyword">else</span>
|
497
|
-
<span class="ruby-ivar">@number</span> = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>)
|
498
|
-
<span class="ruby-keyword">end</span>
|
490
|
+
<span class="ruby-ivar">@ibank_n</span> = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>)
|
491
|
+
<span class="ruby-ivar">@number</span> = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>)
|
499
492
|
<span class="ruby-keyword">elsif</span> (<span class="ruby-identifier">stripped</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^M/</span>))
|
500
493
|
<span class="ruby-ivar">@memo</span> = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>)
|
501
494
|
<span class="ruby-keyword">elsif</span> (<span class="ruby-identifier">stripped</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^L/</span>))
|
502
495
|
<span class="ruby-ivar">@category</span> = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>).<span class="ruby-identifier">downcase</span>
|
503
496
|
<span class="ruby-keyword">elsif</span> (<span class="ruby-identifier">stripped</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^S/</span>))
|
497
|
+
<span class="ruby-ivar">@category</span> = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>).<span class="ruby-identifier">downcase</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@category</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-comment"># default to first split category</span>
|
504
498
|
<span class="ruby-identifier">current_split</span>[<span class="ruby-string">'category'</span>] = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>).<span class="ruby-identifier">downcase</span>
|
505
499
|
<span class="ruby-keyword">elsif</span> (<span class="ruby-identifier">stripped</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^E/</span>))
|
506
500
|
<span class="ruby-identifier">current_split</span>[<span class="ruby-string">'memo'</span>] = <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">stripped</span>)
|
@@ -511,8 +505,8 @@ section of a qif file.</p>
|
|
511
505
|
<span class="ruby-identifier">splits</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">current_split</span>
|
512
506
|
<span class="ruby-ivar">@curr_split</span> = {}
|
513
507
|
<span class="ruby-keyword">end</span>
|
514
|
-
<span class="ruby-keyword">end</span>
|
515
|
-
<span class="ruby-keyword">end</span>
|
508
|
+
<span class="ruby-keyword">end</span>
|
509
|
+
<span class="ruby-keyword">end</span>
|
516
510
|
<span class="ruby-keyword">end</span></pre>
|
517
511
|
</div><!-- add_line-source -->
|
518
512
|
|
@@ -543,7 +537,7 @@ section of a qif file.</p>
|
|
543
537
|
|
544
538
|
|
545
539
|
<div class="method-source-code" id="as_array-source">
|
546
|
-
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line
|
540
|
+
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line 101</span>
|
547
541
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">as_array</span>(<span class="ruby-identifier">idx</span>=<span class="ruby-value">0</span>)
|
548
542
|
<span class="ruby-identifier">array</span> = []
|
549
543
|
<span class="ruby-identifier">array</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">idx</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
@@ -560,9 +554,9 @@ section of a qif file.</p>
|
|
560
554
|
<span class="ruby-identifier">array</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">memo</span>
|
561
555
|
<span class="ruby-value">3</span>.<span class="ruby-identifier">times</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">|</span>
|
562
556
|
<span class="ruby-keyword">if</span> <span class="ruby-identifier">i</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">splits</span>.<span class="ruby-identifier">size</span>
|
563
|
-
<span class="ruby-identifier">array</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">splits</span>[<span class="ruby-identifier">i</span>][<span class="ruby-string">'amount'</span>]
|
564
|
-
<span class="ruby-identifier">array</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">splits</span>[<span class="ruby-identifier">i</span>][<span class="ruby-string">'category'</span>]
|
565
|
-
<span class="ruby-identifier">array</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">splits</span>[<span class="ruby-identifier">i</span>][<span class="ruby-string">'memo'</span>]
|
557
|
+
<span class="ruby-identifier">array</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">splits</span>[<span class="ruby-identifier">i</span>][<span class="ruby-string">'amount'</span>].<span class="ruby-identifier">to_s</span>
|
558
|
+
<span class="ruby-identifier">array</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">splits</span>[<span class="ruby-identifier">i</span>][<span class="ruby-string">'category'</span>]
|
559
|
+
<span class="ruby-identifier">array</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">splits</span>[<span class="ruby-identifier">i</span>][<span class="ruby-string">'memo'</span>]
|
566
560
|
<span class="ruby-keyword">else</span>
|
567
561
|
<span class="ruby-identifier">array</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'0.0'</span>
|
568
562
|
<span class="ruby-identifier">array</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
@@ -608,7 +602,7 @@ section of a qif file.</p>
|
|
608
602
|
|
609
603
|
|
610
604
|
<div class="method-source-code" id="current_split-source">
|
611
|
-
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line
|
605
|
+
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line 90</span>
|
612
606
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">current_split</span>
|
613
607
|
<span class="ruby-ivar">@curr_split</span> = {} <span class="ruby-keyword">if</span> <span class="ruby-ivar">@curr_split</span>.<span class="ruby-identifier">nil?</span>
|
614
608
|
<span class="ruby-ivar">@curr_split</span>
|
@@ -642,7 +636,7 @@ section of a qif file.</p>
|
|
642
636
|
|
643
637
|
|
644
638
|
<div class="method-source-code" id="ibank-3F-source">
|
645
|
-
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line
|
639
|
+
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line 79</span>
|
646
640
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">ibank?</span>
|
647
641
|
<span class="ruby-ivar">@source_app</span> <span class="ruby-operator">==</span> <span class="ruby-string">'ibank'</span>
|
648
642
|
<span class="ruby-keyword">end</span></pre>
|
@@ -675,7 +669,7 @@ section of a qif file.</p>
|
|
675
669
|
|
676
670
|
|
677
671
|
<div class="method-source-code" id="line_value-source">
|
678
|
-
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line
|
672
|
+
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line 137</span>
|
679
673
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">line_value</span>(<span class="ruby-identifier">s</span>)
|
680
674
|
<span class="ruby-keyword">return</span> <span class="ruby-string">''</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator"><</span> <span class="ruby-value">1</span>
|
681
675
|
<span class="ruby-identifier">s</span>[<span class="ruby-value">1</span>, <span class="ruby-identifier">s</span>.<span class="ruby-identifier">size</span>].<span class="ruby-identifier">strip</span>
|
@@ -709,11 +703,11 @@ section of a qif file.</p>
|
|
709
703
|
|
710
704
|
|
711
705
|
<div class="method-source-code" id="to_csv-source">
|
712
|
-
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line
|
706
|
+
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line 95</span>
|
713
707
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_csv</span>(<span class="ruby-identifier">idx</span>=<span class="ruby-value">0</span>)
|
714
708
|
<span class="ruby-constant">CSV</span>.<span class="ruby-identifier">generate</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">csv</span> <span class="ruby-operator">|</span>
|
715
709
|
<span class="ruby-identifier">csv</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">as_array</span>(<span class="ruby-identifier">idx</span>)
|
716
|
-
<span class="ruby-keyword">end</span>
|
710
|
+
<span class="ruby-keyword">end</span>
|
717
711
|
<span class="ruby-keyword">end</span></pre>
|
718
712
|
</div><!-- to_csv-source -->
|
719
713
|
|
@@ -744,10 +738,10 @@ section of a qif file.</p>
|
|
744
738
|
|
745
739
|
|
746
740
|
<div class="method-source-code" id="valid-3F-source">
|
747
|
-
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line
|
741
|
+
<pre><span class="ruby-comment"># File lib/qiflib_transaction.rb, line 83</span>
|
748
742
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">valid?</span>
|
749
743
|
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">nil?</span>
|
750
|
-
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator"><</span> <span class="ruby-value">8</span>
|
744
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator"><</span> <span class="ruby-value">8</span>
|
751
745
|
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-string">'0000-00-00'</span>
|
752
746
|
<span class="ruby-keyword">true</span>
|
753
747
|
<span class="ruby-keyword">end</span></pre>
|
data/html/Qiflib/Util.html
CHANGED
@@ -77,6 +77,8 @@
|
|
77
77
|
|
78
78
|
<li ><a href="#method-c-catetory_names_to_delim">::catetory_names_to_delim</a>
|
79
79
|
|
80
|
+
<li ><a href="#method-c-describe_csv_field_array">::describe_csv_field_array</a>
|
81
|
+
|
80
82
|
<li ><a href="#method-c-generate_sqlite_ddl">::generate_sqlite_ddl</a>
|
81
83
|
|
82
84
|
<li ><a href="#method-c-generate_sqlite_load_script">::generate_sqlite_load_script</a>
|
@@ -200,7 +202,7 @@ given Array of filenames.</p>
|
|
200
202
|
<span class="ruby-keyword">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">err</span>
|
201
203
|
<span class="ruby-identifier">file</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">file</span>
|
202
204
|
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Exception: #{err.class.name} #{err.message} #{err.inspect}"</span>
|
203
|
-
<span class="ruby-keyword">end</span>
|
205
|
+
<span class="ruby-keyword">end</span>
|
204
206
|
}
|
205
207
|
<span class="ruby-keyword">end</span>
|
206
208
|
<span class="ruby-identifier">categories</span>.<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each_with_index</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>, <span class="ruby-identifier">idx</span> <span class="ruby-operator">|</span>
|
@@ -265,6 +267,44 @@ within the given Array of filenames.</p>
|
|
265
267
|
</div><!-- catetory_names_to_delim-method -->
|
266
268
|
|
267
269
|
|
270
|
+
<div id="method-c-describe_csv_field_array" class="method-detail ">
|
271
|
+
|
272
|
+
<div class="method-heading">
|
273
|
+
<span class="method-name">describe_csv_field_array</span><span
|
274
|
+
class="method-args">(array)</span>
|
275
|
+
|
276
|
+
<span class="method-click-advice">click to toggle source</span>
|
277
|
+
|
278
|
+
</div>
|
279
|
+
|
280
|
+
|
281
|
+
<div class="method-description">
|
282
|
+
|
283
|
+
<p>For testing purposes: <a
|
284
|
+
href="Util.html#method-c-describe_csv_field_array">::describe_csv_field_array</a></p>
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
<div class="method-source-code" id="describe_csv_field_array-source">
|
290
|
+
<pre><span class="ruby-comment"># File lib/qiflib_util.rb, line 178</span>
|
291
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">describe_csv_field_array</span>(<span class="ruby-identifier">array</span>)
|
292
|
+
<span class="ruby-identifier">field_map</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-identifier">csv_transaction_field_map</span>
|
293
|
+
<span class="ruby-identifier">array</span>.<span class="ruby-identifier">each_with_index</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">val</span>, <span class="ruby-identifier">idx</span> <span class="ruby-operator">|</span>
|
294
|
+
<span class="ruby-identifier">field_name</span> = <span class="ruby-identifier">field_map</span>[<span class="ruby-identifier">idx</span>]
|
295
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"array[#{idx}].should == '#{val}' # #{field_name}"</span>
|
296
|
+
}
|
297
|
+
<span class="ruby-keyword">end</span></pre>
|
298
|
+
</div><!-- describe_csv_field_array-source -->
|
299
|
+
|
300
|
+
</div>
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
</div><!-- describe_csv_field_array-method -->
|
306
|
+
|
307
|
+
|
268
308
|
<div id="method-c-generate_sqlite_ddl" class="method-detail ">
|
269
309
|
|
270
310
|
<div class="method-heading">
|
@@ -290,7 +330,7 @@ and 'transactions' tables. The DDL will also import the
|
|
290
330
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">generate_sqlite_ddl</span>
|
291
331
|
<span class="ruby-identifier">lines</span> = []
|
292
332
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
293
|
-
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'drop table if exists transactions;'</span>
|
333
|
+
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'drop table if exists transactions;'</span>
|
294
334
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'drop table if exists categories;'</span>
|
295
335
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
296
336
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'create table transactions('</span>
|
@@ -326,14 +366,14 @@ and 'transactions' tables. The DDL will also import the
|
|
326
366
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
327
367
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'create table categories('</span>
|
328
368
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">' id integer,'</span>
|
329
|
-
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">' name varchar(80)'</span>
|
330
|
-
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">');'</span>
|
331
|
-
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
369
|
+
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">' name varchar(80)'</span>
|
370
|
+
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">');'</span>
|
371
|
+
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
332
372
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">".separator '^'"</span>
|
333
373
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
334
|
-
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'.import qiflib_transactions.txt transactions'</span>
|
335
|
-
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'.import qiflib_categories.txt categories'</span>
|
336
|
-
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
374
|
+
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'.import private/qiflib_transactions.txt transactions'</span>
|
375
|
+
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'.import private/qiflib_categories.txt categories'</span>
|
376
|
+
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
337
377
|
<span class="ruby-identifier">lines</span>
|
338
378
|
<span class="ruby-keyword">end</span></pre>
|
339
379
|
</div><!-- generate_sqlite_ddl-source -->
|
@@ -359,7 +399,7 @@ and 'transactions' tables. The DDL will also import the
|
|
359
399
|
|
360
400
|
<div class="method-description">
|
361
401
|
|
362
|
-
<p>Return the lines of bash-shell script to load the sqlite3 database via
|
402
|
+
<p>Return the lines of bash-shell script to load the sqlite3 database via the
|
363
403
|
DDL generated in method 'generate_sqlite_ddl'.</p>
|
364
404
|
|
365
405
|
|
@@ -372,7 +412,7 @@ DDL generated in method 'generate_sqlite_ddl'.</p>
|
|
372
412
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'#!/bin/bash'</span>
|
373
413
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
374
414
|
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"sqlite3 #{db_name} < #{ddl_name}"</span>
|
375
|
-
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
415
|
+
<span class="ruby-identifier">lines</span> <span class="ruby-operator"><<</span> <span class="ruby-string">''</span>
|
376
416
|
<span class="ruby-identifier">lines</span>
|
377
417
|
<span class="ruby-keyword">end</span></pre>
|
378
418
|
</div><!-- generate_sqlite_load_script-source -->
|
@@ -400,7 +440,7 @@ DDL generated in method 'generate_sqlite_ddl'.</p>
|
|
400
440
|
|
401
441
|
<p>Return lines in CSV format which contain the list of transactions within
|
402
442
|
the given input_list Array. Each Hash within the input_list should contain
|
403
|
-
keys :owner, :filename, and :source. Specify either
|
443
|
+
keys :owner, :filename, and :source. Specify either the value
|
404
444
|
Qiflib::SOURCE_IBANK or Qiflib::SOURCE_QUICKEN for :source.</p>
|
405
445
|
|
406
446
|
|
@@ -413,7 +453,7 @@ Qiflib::SOURCE_IBANK or Qiflib::SOURCE_QUICKEN for :source.</p>
|
|
413
453
|
<span class="ruby-identifier">csv_lines</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Transaction</span>.<span class="ruby-identifier">csv_header</span>
|
414
454
|
<span class="ruby-keyword">if</span> <span class="ruby-identifier">input_list</span>
|
415
455
|
<span class="ruby-identifier">input_list</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">input_hash</span> <span class="ruby-operator">|</span>
|
416
|
-
<span class="ruby-identifier">owner</span> = <span class="ruby-identifier">input_hash</span>[<span class="ruby-value">:owner</span>]
|
456
|
+
<span class="ruby-identifier">owner</span> = <span class="ruby-identifier">input_hash</span>[<span class="ruby-value">:owner</span>]
|
417
457
|
<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">input_hash</span>[<span class="ruby-value">:filename</span>]
|
418
458
|
<span class="ruby-identifier">source</span> = <span class="ruby-identifier">input_hash</span>[<span class="ruby-value">:source</span>]
|
419
459
|
<span class="ruby-identifier">process_file_for_transactions</span>(<span class="ruby-identifier">owner</span>, <span class="ruby-identifier">filename</span>, <span class="ruby-identifier">source</span>, <span class="ruby-identifier">transactions</span>)
|
@@ -449,7 +489,7 @@ Qiflib::SOURCE_IBANK or Qiflib::SOURCE_QUICKEN for :source.</p>
|
|
449
489
|
|
450
490
|
<p>Return lines in ^-delimited format which contain the list of transactions
|
451
491
|
within the given input_list Array. Each Hash within the input_list should
|
452
|
-
contain keys :owner, :filename, and :source. Specify either
|
492
|
+
contain keys :owner, :filename, and :source. Specify either the value
|
453
493
|
Qiflib::SOURCE_IBANK or Qiflib::SOURCE_QUICKEN for :source.</p>
|
454
494
|
|
455
495
|
|
data/html/Qiflib.html
CHANGED
@@ -74,6 +74,8 @@
|
|
74
74
|
|
75
75
|
<li ><a href="#method-c-csv_category_field_names">::csv_category_field_names</a>
|
76
76
|
|
77
|
+
<li ><a href="#method-c-csv_transaction_field_map">::csv_transaction_field_map</a>
|
78
|
+
|
77
79
|
<li ><a href="#method-c-csv_transaction_field_names">::csv_transaction_field_names</a>
|
78
80
|
|
79
81
|
</ul>
|
@@ -215,6 +217,43 @@ the csv and delimited files.</p>
|
|
215
217
|
</div><!-- csv_category_field_names-method -->
|
216
218
|
|
217
219
|
|
220
|
+
<div id="method-c-csv_transaction_field_map" class="method-detail ">
|
221
|
+
|
222
|
+
<div class="method-heading">
|
223
|
+
<span class="method-name">csv_transaction_field_map</span><span
|
224
|
+
class="method-args">()</span>
|
225
|
+
|
226
|
+
<span class="method-click-advice">click to toggle source</span>
|
227
|
+
|
228
|
+
</div>
|
229
|
+
|
230
|
+
|
231
|
+
<div class="method-description">
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
<div class="method-source-code" id="csv_transaction_field_map-source">
|
239
|
+
<pre><span class="ruby-comment"># File lib/qiflib_constants.rb, line 51</span>
|
240
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">csv_transaction_field_map</span>
|
241
|
+
<span class="ruby-identifier">hash</span> = {}
|
242
|
+
<span class="ruby-constant">Qiflib</span>.<span class="ruby-identifier">csv_transaction_field_names</span>.<span class="ruby-identifier">each_with_index</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">field</span>, <span class="ruby-identifier">index</span> <span class="ruby-operator">|</span>
|
243
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">index</span>] = <span class="ruby-identifier">field</span>
|
244
|
+
}
|
245
|
+
<span class="ruby-identifier">hash</span>
|
246
|
+
<span class="ruby-keyword">end</span></pre>
|
247
|
+
</div><!-- csv_transaction_field_map-source -->
|
248
|
+
|
249
|
+
</div>
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
</div><!-- csv_transaction_field_map-method -->
|
255
|
+
|
256
|
+
|
218
257
|
<div id="method-c-csv_transaction_field_names" class="method-detail ">
|
219
258
|
|
220
259
|
<div class="method-heading">
|
data/html/README_rdoc.html
CHANGED
@@ -52,7 +52,8 @@
|
|
52
52
|
<li><a href="#label-Install">Install</a>
|
53
53
|
<li><a href="#label-Synopsis">Synopsis</a>
|
54
54
|
<li><a href="#label-Generated+DDL">Generated DDL</a>
|
55
|
-
<li><a href="#label-
|
55
|
+
<li><a href="#label-CSV+fields">CSV fields</a>
|
56
|
+
<li><a href="#label-Generated+shell+script">Generated shell script</a>
|
56
57
|
<li><a href="#label-Copyright+and+License">Copyright and License</a>
|
57
58
|
</ul>
|
58
59
|
</nav>
|
@@ -97,6 +98,8 @@
|
|
97
98
|
|
98
99
|
<h2 id="label-Qiflib"><a href="Qiflib.html">Qiflib</a><span><a href="#label-Qiflib">¶</a> <a href="#documentation">↑</a></span></h2>
|
99
100
|
|
101
|
+
<p>version 0.4.0, released 12-14-2013</p>
|
102
|
+
|
100
103
|
<p>A ruby library for reading and parsing qif files.</p>
|
101
104
|
|
102
105
|
<p>Transaction parsing is supported, including address fields, and up to three
|
@@ -105,9 +108,12 @@ each transaction.</p>
|
|
105
108
|
|
106
109
|
<p>Category-name parsing is also supported.</p>
|
107
110
|
|
108
|
-
<p>Also includes DDL generation for importing the parsed categories and
|
111
|
+
<p>Also includes DDL generation for importing the parsed categories and
|
109
112
|
transactions into a sqlite3 database.</p>
|
110
113
|
|
114
|
+
<p>Version 0.4.0 includes support for iBank version 4.7.5, this version
|
115
|
+
exports silightly differently than previous versions.</p>
|
116
|
+
|
111
117
|
<h2 id="label-Install">Install<span><a href="#label-Install">¶</a> <a href="#documentation">↑</a></span></h2>
|
112
118
|
|
113
119
|
<pre>gem install qiflib</pre>
|
@@ -120,24 +126,24 @@ transactions into a sqlite3 database.</p>
|
|
120
126
|
<span class="ruby-comment"># Qiflib::SOURCE_QUICKEN as the :source.</span>
|
121
127
|
|
122
128
|
<span class="ruby-identifier">input_list</span> = []
|
123
|
-
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
129
|
+
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
124
130
|
:<span class="ruby-identifier">owner</span> =<span class="ruby-operator">></span> <span class="ruby-string">'Chris'</span>,
|
125
131
|
:<span class="ruby-identifier">filename</span> =<span class="ruby-operator">></span> <span class="ruby-string">'data/ibank_cj.qif'</span>,
|
126
132
|
:<span class="ruby-identifier">source</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">SOURCE_IBANK</span> }
|
127
|
-
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
133
|
+
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
128
134
|
:<span class="ruby-identifier">owner</span> =<span class="ruby-operator">></span> <span class="ruby-string">'Teri'</span>,
|
129
135
|
:<span class="ruby-identifier">filename</span> =<span class="ruby-operator">></span> <span class="ruby-string">'data/ibank_tj.qif'</span>,
|
130
136
|
:<span class="ruby-identifier">source</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">SOURCE_QUICKEN</span> }
|
131
137
|
|
132
|
-
<span class="ruby-identifier">csv_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">transactions_to_csv</span>(<span class="ruby-identifier">input_list</span>)
|
138
|
+
<span class="ruby-identifier">csv_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">transactions_to_csv</span>(<span class="ruby-identifier">input_list</span>)
|
133
139
|
|
134
140
|
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">csv_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>
|
135
141
|
|
136
|
-
<span class="ruby-comment"># Parse the transactions from one or more files to ^-delimited text
|
142
|
+
<span class="ruby-comment"># Parse the transactions from one or more files to ^-delimited text.</span>
|
137
143
|
<span class="ruby-comment"># The text lines are suitable for loading to sqlite3.</span>
|
138
144
|
|
139
145
|
<span class="ruby-identifier">input_list</span> = []
|
140
|
-
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
146
|
+
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
141
147
|
:<span class="ruby-identifier">owner</span> =<span class="ruby-operator">></span> <span class="ruby-string">'Chris'</span>,
|
142
148
|
:<span class="ruby-identifier">filename</span> =<span class="ruby-operator">></span> <span class="ruby-string">'data/ibank_cj.qif'</span>,
|
143
149
|
:<span class="ruby-identifier">source</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">SOURCE_IBANK</span> }
|
@@ -151,26 +157,26 @@ transactions into a sqlite3 database.</p>
|
|
151
157
|
<span class="ruby-identifier">input_list</span> = [ <span class="ruby-string">'data/ibank_cj.qif'</span> ]
|
152
158
|
<span class="ruby-identifier">csv_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">catetory_names_to_csv</span>(<span class="ruby-identifier">input_list</span>)
|
153
159
|
|
154
|
-
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">csv_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>
|
160
|
+
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">csv_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>
|
155
161
|
|
156
|
-
<span class="ruby-comment"># Parse the categories from one or more files to ^-delimited text
|
157
|
-
<span class="ruby-comment"># The text lines are suitable for loading to sqlite3
|
162
|
+
<span class="ruby-comment"># Parse the categories from one or more files to ^-delimited text.</span>
|
163
|
+
<span class="ruby-comment"># The text lines are suitable for loading to sqlite3.</span>
|
158
164
|
|
159
165
|
<span class="ruby-identifier">input_list</span> = [ <span class="ruby-string">'data/ibank_cj.qif'</span> ]
|
160
166
|
<span class="ruby-identifier">delim_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">catetory_names_to_delim</span>(<span class="ruby-identifier">input_list</span>)
|
161
167
|
|
162
|
-
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">delim_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>
|
168
|
+
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">delim_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>
|
163
169
|
|
164
170
|
<span class="ruby-comment"># Generate the DDL for a sqlite3 database with categories and transactions tables.</span>
|
165
171
|
|
166
172
|
<span class="ruby-identifier">ddl_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">generate_sqlite_ddl</span>
|
167
173
|
|
168
|
-
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">ddl_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>; <span class="ruby-identifier">use</span> <span class="ruby-identifier">it</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">following</span> <span class="ruby-identifier">bash</span><span class="ruby-operator">-</span><span class="ruby-identifier">shell</span> <span class="ruby-identifier">script</span>
|
174
|
+
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">ddl_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>; <span class="ruby-identifier">use</span> <span class="ruby-identifier">it</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">following</span> <span class="ruby-identifier">bash</span><span class="ruby-operator">-</span><span class="ruby-identifier">shell</span> <span class="ruby-identifier">script</span>
|
169
175
|
|
170
|
-
<span class="ruby-comment"># Generate a bash-shell script to load the categories and transactions
|
176
|
+
<span class="ruby-comment"># Generate a bash-shell script to load the categories and transactions</span>
|
171
177
|
<span class="ruby-comment"># delimited files into a sqlite3 database, using the above DDL.</span>
|
172
178
|
|
173
|
-
<span class="ruby-identifier">sh_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">generate_sqlite_load_script</span>
|
179
|
+
<span class="ruby-identifier">sh_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">generate_sqlite_load_script</span>
|
174
180
|
|
175
181
|
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">sh_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>; <span class="ruby-identifier">chmod</span> <span class="ruby-value">744</span>; <span class="ruby-identifier">run</span> <span class="ruby-identifier">it</span>.
|
176
182
|
</pre>
|
@@ -220,12 +226,43 @@ create table categories(
|
|
220
226
|
|
221
227
|
.separator '^'
|
222
228
|
|
223
|
-
.import qiflib_transactions.txt transactions
|
224
|
-
.import qiflib_categories.txt categories</pre>
|
225
|
-
|
226
|
-
<h2 id="label-
|
227
|
-
|
228
|
-
<pre
|
229
|
+
.import private/qiflib_transactions.txt transactions
|
230
|
+
.import private/qiflib_categories.txt categories</pre>
|
231
|
+
|
232
|
+
<h2 id="label-CSV+fields">CSV fields<span><a href="#label-CSV+fields">¶</a> <a href="#documentation">↑</a></span></h2>
|
233
|
+
|
234
|
+
<pre>csv field index 0 = id
|
235
|
+
csv field index 1 = acct_owner
|
236
|
+
csv field index 2 = acct_name
|
237
|
+
csv field index 3 = acct_type
|
238
|
+
csv field index 4 = date
|
239
|
+
csv field index 5 = amount
|
240
|
+
csv field index 6 = number
|
241
|
+
csv field index 7 = ibank_n
|
242
|
+
csv field index 8 = cleared
|
243
|
+
csv field index 9 = payee
|
244
|
+
csv field index 10 = category
|
245
|
+
csv field index 11 = memo
|
246
|
+
csv field index 12 = split1_amount
|
247
|
+
csv field index 13 = split1_category
|
248
|
+
csv field index 14 = split1_memo
|
249
|
+
csv field index 15 = split2_amount
|
250
|
+
csv field index 16 = split2_category
|
251
|
+
csv field index 17 = split2_memo
|
252
|
+
csv field index 18 = split3_amount
|
253
|
+
csv field index 19 = split3_category
|
254
|
+
csv field index 20 = split3_memo
|
255
|
+
csv field index 21 = address1
|
256
|
+
csv field index 22 = address2
|
257
|
+
csv field index 23 = address3
|
258
|
+
csv field index 24 = address4
|
259
|
+
csv field index 25 = address5
|
260
|
+
csv field index 26 = address6
|
261
|
+
csv field index 27 = eol_ind</pre>
|
262
|
+
|
263
|
+
<h2 id="label-Generated+shell+script">Generated shell script<span><a href="#label-Generated+shell+script">¶</a> <a href="#documentation">↑</a></span></h2>
|
264
|
+
|
265
|
+
<pre># bash-shell script
|
229
266
|
|
230
267
|
#!/bin/bash
|
231
268
|
|
data/html/index.html
CHANGED
@@ -81,6 +81,8 @@
|
|
81
81
|
|
82
82
|
<h2 id="label-Qiflib"><a href="Qiflib.html">Qiflib</a><span><a href="#label-Qiflib">¶</a> <a href="#documentation">↑</a></span></h2>
|
83
83
|
|
84
|
+
<p>version 0.4.0, released 12-14-2013</p>
|
85
|
+
|
84
86
|
<p>A ruby library for reading and parsing qif files.</p>
|
85
87
|
|
86
88
|
<p>Transaction parsing is supported, including address fields, and up to three
|
@@ -89,9 +91,12 @@ each transaction.</p>
|
|
89
91
|
|
90
92
|
<p>Category-name parsing is also supported.</p>
|
91
93
|
|
92
|
-
<p>Also includes DDL generation for importing the parsed categories and
|
94
|
+
<p>Also includes DDL generation for importing the parsed categories and
|
93
95
|
transactions into a sqlite3 database.</p>
|
94
96
|
|
97
|
+
<p>Version 0.4.0 includes support for iBank version 4.7.5, this version
|
98
|
+
exports silightly differently than previous versions.</p>
|
99
|
+
|
95
100
|
<h2 id="label-Install">Install<span><a href="#label-Install">¶</a> <a href="#documentation">↑</a></span></h2>
|
96
101
|
|
97
102
|
<pre>gem install qiflib</pre>
|
@@ -104,24 +109,24 @@ transactions into a sqlite3 database.</p>
|
|
104
109
|
<span class="ruby-comment"># Qiflib::SOURCE_QUICKEN as the :source.</span>
|
105
110
|
|
106
111
|
<span class="ruby-identifier">input_list</span> = []
|
107
|
-
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
112
|
+
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
108
113
|
:<span class="ruby-identifier">owner</span> =<span class="ruby-operator">></span> <span class="ruby-string">'Chris'</span>,
|
109
114
|
:<span class="ruby-identifier">filename</span> =<span class="ruby-operator">></span> <span class="ruby-string">'data/ibank_cj.qif'</span>,
|
110
115
|
:<span class="ruby-identifier">source</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">SOURCE_IBANK</span> }
|
111
|
-
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
116
|
+
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
112
117
|
:<span class="ruby-identifier">owner</span> =<span class="ruby-operator">></span> <span class="ruby-string">'Teri'</span>,
|
113
118
|
:<span class="ruby-identifier">filename</span> =<span class="ruby-operator">></span> <span class="ruby-string">'data/ibank_tj.qif'</span>,
|
114
119
|
:<span class="ruby-identifier">source</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">SOURCE_QUICKEN</span> }
|
115
120
|
|
116
|
-
<span class="ruby-identifier">csv_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">transactions_to_csv</span>(<span class="ruby-identifier">input_list</span>)
|
121
|
+
<span class="ruby-identifier">csv_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">transactions_to_csv</span>(<span class="ruby-identifier">input_list</span>)
|
117
122
|
|
118
123
|
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">csv_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>
|
119
124
|
|
120
|
-
<span class="ruby-comment"># Parse the transactions from one or more files to ^-delimited text
|
125
|
+
<span class="ruby-comment"># Parse the transactions from one or more files to ^-delimited text.</span>
|
121
126
|
<span class="ruby-comment"># The text lines are suitable for loading to sqlite3.</span>
|
122
127
|
|
123
128
|
<span class="ruby-identifier">input_list</span> = []
|
124
|
-
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
129
|
+
<span class="ruby-identifier">input_list</span> <span class="ruby-operator"><<</span> {
|
125
130
|
:<span class="ruby-identifier">owner</span> =<span class="ruby-operator">></span> <span class="ruby-string">'Chris'</span>,
|
126
131
|
:<span class="ruby-identifier">filename</span> =<span class="ruby-operator">></span> <span class="ruby-string">'data/ibank_cj.qif'</span>,
|
127
132
|
:<span class="ruby-identifier">source</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">SOURCE_IBANK</span> }
|
@@ -135,26 +140,26 @@ transactions into a sqlite3 database.</p>
|
|
135
140
|
<span class="ruby-identifier">input_list</span> = [ <span class="ruby-string">'data/ibank_cj.qif'</span> ]
|
136
141
|
<span class="ruby-identifier">csv_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">catetory_names_to_csv</span>(<span class="ruby-identifier">input_list</span>)
|
137
142
|
|
138
|
-
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">csv_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>
|
143
|
+
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">csv_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>
|
139
144
|
|
140
|
-
<span class="ruby-comment"># Parse the categories from one or more files to ^-delimited text
|
141
|
-
<span class="ruby-comment"># The text lines are suitable for loading to sqlite3
|
145
|
+
<span class="ruby-comment"># Parse the categories from one or more files to ^-delimited text.</span>
|
146
|
+
<span class="ruby-comment"># The text lines are suitable for loading to sqlite3.</span>
|
142
147
|
|
143
148
|
<span class="ruby-identifier">input_list</span> = [ <span class="ruby-string">'data/ibank_cj.qif'</span> ]
|
144
149
|
<span class="ruby-identifier">delim_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">catetory_names_to_delim</span>(<span class="ruby-identifier">input_list</span>)
|
145
150
|
|
146
|
-
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">delim_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>
|
151
|
+
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">delim_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>
|
147
152
|
|
148
153
|
<span class="ruby-comment"># Generate the DDL for a sqlite3 database with categories and transactions tables.</span>
|
149
154
|
|
150
155
|
<span class="ruby-identifier">ddl_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">generate_sqlite_ddl</span>
|
151
156
|
|
152
|
-
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">ddl_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>; <span class="ruby-identifier">use</span> <span class="ruby-identifier">it</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">following</span> <span class="ruby-identifier">bash</span><span class="ruby-operator">-</span><span class="ruby-identifier">shell</span> <span class="ruby-identifier">script</span>
|
157
|
+
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">ddl_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>; <span class="ruby-identifier">use</span> <span class="ruby-identifier">it</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">following</span> <span class="ruby-identifier">bash</span><span class="ruby-operator">-</span><span class="ruby-identifier">shell</span> <span class="ruby-identifier">script</span>
|
153
158
|
|
154
|
-
<span class="ruby-comment"># Generate a bash-shell script to load the categories and transactions
|
159
|
+
<span class="ruby-comment"># Generate a bash-shell script to load the categories and transactions</span>
|
155
160
|
<span class="ruby-comment"># delimited files into a sqlite3 database, using the above DDL.</span>
|
156
161
|
|
157
|
-
<span class="ruby-identifier">sh_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">generate_sqlite_load_script</span>
|
162
|
+
<span class="ruby-identifier">sh_lines</span> = <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">generate_sqlite_load_script</span>
|
158
163
|
|
159
164
|
<span class="ruby-operator">...</span> <span class="ruby-identifier">write</span> <span class="ruby-identifier">sh_lines</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">file</span>; <span class="ruby-identifier">chmod</span> <span class="ruby-value">744</span>; <span class="ruby-identifier">run</span> <span class="ruby-identifier">it</span>.
|
160
165
|
</pre>
|
@@ -204,12 +209,43 @@ create table categories(
|
|
204
209
|
|
205
210
|
.separator '^'
|
206
211
|
|
207
|
-
.import qiflib_transactions.txt transactions
|
208
|
-
.import qiflib_categories.txt categories</pre>
|
209
|
-
|
210
|
-
<h2 id="label-
|
211
|
-
|
212
|
-
<pre
|
212
|
+
.import private/qiflib_transactions.txt transactions
|
213
|
+
.import private/qiflib_categories.txt categories</pre>
|
214
|
+
|
215
|
+
<h2 id="label-CSV+fields">CSV fields<span><a href="#label-CSV+fields">¶</a> <a href="#documentation">↑</a></span></h2>
|
216
|
+
|
217
|
+
<pre>csv field index 0 = id
|
218
|
+
csv field index 1 = acct_owner
|
219
|
+
csv field index 2 = acct_name
|
220
|
+
csv field index 3 = acct_type
|
221
|
+
csv field index 4 = date
|
222
|
+
csv field index 5 = amount
|
223
|
+
csv field index 6 = number
|
224
|
+
csv field index 7 = ibank_n
|
225
|
+
csv field index 8 = cleared
|
226
|
+
csv field index 9 = payee
|
227
|
+
csv field index 10 = category
|
228
|
+
csv field index 11 = memo
|
229
|
+
csv field index 12 = split1_amount
|
230
|
+
csv field index 13 = split1_category
|
231
|
+
csv field index 14 = split1_memo
|
232
|
+
csv field index 15 = split2_amount
|
233
|
+
csv field index 16 = split2_category
|
234
|
+
csv field index 17 = split2_memo
|
235
|
+
csv field index 18 = split3_amount
|
236
|
+
csv field index 19 = split3_category
|
237
|
+
csv field index 20 = split3_memo
|
238
|
+
csv field index 21 = address1
|
239
|
+
csv field index 22 = address2
|
240
|
+
csv field index 23 = address3
|
241
|
+
csv field index 24 = address4
|
242
|
+
csv field index 25 = address5
|
243
|
+
csv field index 26 = address6
|
244
|
+
csv field index 27 = eol_ind</pre>
|
245
|
+
|
246
|
+
<h2 id="label-Generated+shell+script">Generated shell script<span><a href="#label-Generated+shell+script">¶</a> <a href="#documentation">↑</a></span></h2>
|
247
|
+
|
248
|
+
<pre># bash-shell script
|
213
249
|
|
214
250
|
#!/bin/bash
|
215
251
|
|
data/html/table_of_contents.html
CHANGED
@@ -34,7 +34,8 @@
|
|
34
34
|
<li><a href="README_rdoc.html#label-Install">Install</a>
|
35
35
|
<li><a href="README_rdoc.html#label-Synopsis">Synopsis</a>
|
36
36
|
<li><a href="README_rdoc.html#label-Generated+DDL">Generated DDL</a>
|
37
|
-
<li><a href="README_rdoc.html#label-
|
37
|
+
<li><a href="README_rdoc.html#label-CSV+fields">CSV fields</a>
|
38
|
+
<li><a href="README_rdoc.html#label-Generated+shell+script">Generated shell script</a>
|
38
39
|
<li><a href="README_rdoc.html#label-Copyright+and+License">Copyright and License</a>
|
39
40
|
</ul>
|
40
41
|
</li>
|
@@ -77,18 +78,22 @@
|
|
77
78
|
|
78
79
|
<li class="method"><a href="Qiflib/Transaction.html#method-c-csv_header">::csv_header — Qiflib::Transaction</a>
|
79
80
|
|
81
|
+
<li class="method"><a href="Qiflib.html#method-c-csv_transaction_field_map">::csv_transaction_field_map — Qiflib</a>
|
82
|
+
|
80
83
|
<li class="method"><a href="Qiflib.html#method-c-csv_transaction_field_names">::csv_transaction_field_names — Qiflib</a>
|
81
84
|
|
85
|
+
<li class="method"><a href="Qiflib/Util.html#method-c-describe_csv_field_array">::describe_csv_field_array — Qiflib::Util</a>
|
86
|
+
|
82
87
|
<li class="method"><a href="Qiflib/Util.html#method-c-generate_sqlite_ddl">::generate_sqlite_ddl — Qiflib::Util</a>
|
83
88
|
|
84
89
|
<li class="method"><a href="Qiflib/Util.html#method-c-generate_sqlite_load_script">::generate_sqlite_load_script — Qiflib::Util</a>
|
85
90
|
|
91
|
+
<li class="method"><a href="Qiflib/Money.html#method-c-new">::new — Qiflib::Money</a>
|
92
|
+
|
86
93
|
<li class="method"><a href="Qiflib/Transaction.html#method-c-new">::new — Qiflib::Transaction</a>
|
87
94
|
|
88
95
|
<li class="method"><a href="Qiflib/Category.html#method-c-new">::new — Qiflib::Category</a>
|
89
96
|
|
90
|
-
<li class="method"><a href="Qiflib/Money.html#method-c-new">::new — Qiflib::Money</a>
|
91
|
-
|
92
97
|
<li class="method"><a href="Qiflib/Date.html#method-c-new">::new — Qiflib::Date</a>
|
93
98
|
|
94
99
|
<li class="method"><a href="Qiflib/Util.html#method-c-transactions_to_csv">::transactions_to_csv — Qiflib::Util</a>
|
@@ -97,10 +102,10 @@
|
|
97
102
|
|
98
103
|
<li class="method"><a href="Qiflib/Transaction.html#method-i-add_line">#add_line — Qiflib::Transaction</a>
|
99
104
|
|
100
|
-
<li class="method"><a href="Qiflib/Category.html#method-i-as_array">#as_array — Qiflib::Category</a>
|
101
|
-
|
102
105
|
<li class="method"><a href="Qiflib/Transaction.html#method-i-as_array">#as_array — Qiflib::Transaction</a>
|
103
106
|
|
107
|
+
<li class="method"><a href="Qiflib/Category.html#method-i-as_array">#as_array — Qiflib::Category</a>
|
108
|
+
|
104
109
|
<li class="method"><a href="Qiflib/Money.html#method-i-cents">#cents — Qiflib::Money</a>
|
105
110
|
|
106
111
|
<li class="method"><a href="Qiflib/Transaction.html#method-i-current_split">#current_split — Qiflib::Transaction</a>
|
@@ -113,10 +118,10 @@
|
|
113
118
|
|
114
119
|
<li class="method"><a href="Qiflib/Transaction.html#method-i-to_csv">#to_csv — Qiflib::Transaction</a>
|
115
120
|
|
116
|
-
<li class="method"><a href="Qiflib/Date.html#method-i-to_s">#to_s — Qiflib::Date</a>
|
117
|
-
|
118
121
|
<li class="method"><a href="Qiflib/Money.html#method-i-to_s">#to_s — Qiflib::Money</a>
|
119
122
|
|
123
|
+
<li class="method"><a href="Qiflib/Date.html#method-i-to_s">#to_s — Qiflib::Date</a>
|
124
|
+
|
120
125
|
<li class="method"><a href="Qiflib/Transaction.html#method-i-valid-3F">#valid? — Qiflib::Transaction</a>
|
121
126
|
|
122
127
|
</ul>
|
data/lib/qiflib_constants.rb
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
|
5
5
|
module Qiflib
|
6
6
|
|
7
|
-
VERSION = '0.
|
8
|
-
DATE = '2013-
|
7
|
+
VERSION = '0.4.0'
|
8
|
+
DATE = '2013-12-14'
|
9
9
|
AUTHOR = 'Chris Joakim'
|
10
10
|
EMAIL = 'cjoakim@bellsouth.net'
|
11
11
|
SOURCE_QUICKEN = 'quicken'
|
@@ -48,4 +48,12 @@ module Qiflib
|
|
48
48
|
)
|
49
49
|
end
|
50
50
|
|
51
|
+
def self.csv_transaction_field_map
|
52
|
+
hash = {}
|
53
|
+
Qiflib.csv_transaction_field_names.each_with_index { | field, index |
|
54
|
+
hash[index] = field
|
55
|
+
}
|
56
|
+
hash
|
57
|
+
end
|
58
|
+
|
51
59
|
end
|
data/lib/qiflib_transaction.rb
CHANGED
@@ -3,20 +3,20 @@ module Qiflib
|
|
3
3
|
|
4
4
|
# Instances of this class represent a transaction parsed within an
|
5
5
|
# !Account section of a qif file.
|
6
|
-
|
6
|
+
|
7
7
|
class Transaction
|
8
8
|
|
9
9
|
attr_accessor :id # computed field
|
10
10
|
attr_accessor :acct_owner, :acct_name, :acct_type, :source_app # constructor arg fields
|
11
|
-
attr_reader :date, :amount, :cleared, :category, :number, :payee, :memo # data fields
|
12
|
-
attr_reader :splits, :address, :ibank_n
|
13
|
-
|
11
|
+
attr_reader :date, :amount, :cleared, :category, :number, :payee, :memo # data fields
|
12
|
+
attr_reader :splits, :address, :ibank_n
|
13
|
+
|
14
14
|
def self.csv_header
|
15
15
|
CSV.generate do | csv |
|
16
16
|
csv << Qiflib::csv_transaction_field_names
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
20
|
def initialize(acct_owner=nil, acct_name=nil, acct_type=nil, source_app='quicken')
|
21
21
|
if acct_owner
|
22
22
|
@acct_owner = "#{acct_owner}".downcase
|
@@ -27,23 +27,23 @@ module Qiflib
|
|
27
27
|
@splits, @curr_split, @address, @ibank_n = [], {}, [], ''
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def add_line(line)
|
32
32
|
if line
|
33
33
|
stripped = line.strip
|
34
34
|
if stripped.size > 0
|
35
|
-
# Field Indicator Explanations:
|
36
|
-
# D Date
|
37
|
-
# T Amount
|
38
|
-
# C Cleared status
|
39
|
-
# N Num (check or reference number)
|
40
|
-
# P Payee
|
41
|
-
# M Memo
|
35
|
+
# Field Indicator Explanations:
|
36
|
+
# D Date
|
37
|
+
# T Amount
|
38
|
+
# C Cleared status
|
39
|
+
# N Num (check or reference number)
|
40
|
+
# P Payee
|
41
|
+
# M Memo
|
42
42
|
# A Address (up to five lines; the sixth line is an optional message)
|
43
|
-
# L Category (Category/Subcategory/Transfer/Class)
|
44
|
-
# S Category in split (Category/Transfer/Class)
|
45
|
-
# E Memo in split
|
46
|
-
# $ Dollar amount of split
|
43
|
+
# L Category (Category/Subcategory/Transfer/Class)
|
44
|
+
# S Category in split (Category/Transfer/Class)
|
45
|
+
# E Memo in split
|
46
|
+
# $ Dollar amount of split
|
47
47
|
# ^ End of the entry
|
48
48
|
if (stripped.match(/^D/))
|
49
49
|
@date = Qiflib::Date.new(line_value(stripped))
|
@@ -52,22 +52,16 @@ module Qiflib
|
|
52
52
|
elsif (stripped.match(/^P/))
|
53
53
|
@payee = line_value(stripped)
|
54
54
|
elsif (stripped.match(/^C/))
|
55
|
-
|
56
|
-
@number = line_value(stripped)
|
57
|
-
else
|
58
|
-
@cleared = line_value(stripped)
|
59
|
-
end
|
55
|
+
@cleared = line_value(stripped)
|
60
56
|
elsif (stripped.match(/^N/))
|
61
|
-
|
62
|
-
|
63
|
-
else
|
64
|
-
@number = line_value(stripped)
|
65
|
-
end
|
57
|
+
@ibank_n = line_value(stripped)
|
58
|
+
@number = line_value(stripped)
|
66
59
|
elsif (stripped.match(/^M/))
|
67
60
|
@memo = line_value(stripped)
|
68
61
|
elsif (stripped.match(/^L/))
|
69
62
|
@category = line_value(stripped).downcase
|
70
63
|
elsif (stripped.match(/^S/))
|
64
|
+
@category = line_value(stripped).downcase if @category.size == 0 # default to first split category
|
71
65
|
current_split['category'] = line_value(stripped).downcase
|
72
66
|
elsif (stripped.match(/^E/))
|
73
67
|
current_split['memo'] = line_value(stripped)
|
@@ -78,32 +72,32 @@ module Qiflib
|
|
78
72
|
splits << current_split
|
79
73
|
@curr_split = {}
|
80
74
|
end
|
81
|
-
end
|
82
|
-
end
|
75
|
+
end
|
76
|
+
end
|
83
77
|
end
|
84
|
-
|
78
|
+
|
85
79
|
def ibank?
|
86
80
|
@source_app == 'ibank'
|
87
81
|
end
|
88
|
-
|
82
|
+
|
89
83
|
def valid?
|
90
84
|
return false if date.nil?
|
91
|
-
return false if date.to_s.size < 8
|
85
|
+
return false if date.to_s.size < 8
|
92
86
|
return false if date.to_s == '0000-00-00'
|
93
87
|
true
|
94
|
-
end
|
95
|
-
|
88
|
+
end
|
89
|
+
|
96
90
|
def current_split
|
97
91
|
@curr_split = {} if @curr_split.nil?
|
98
92
|
@curr_split
|
99
93
|
end
|
100
|
-
|
94
|
+
|
101
95
|
def to_csv(idx=0)
|
102
96
|
CSV.generate do | csv |
|
103
97
|
csv << as_array(idx)
|
104
|
-
end
|
98
|
+
end
|
105
99
|
end
|
106
|
-
|
100
|
+
|
107
101
|
def as_array(idx=0)
|
108
102
|
array = []
|
109
103
|
array << idx + 1
|
@@ -120,9 +114,9 @@ module Qiflib
|
|
120
114
|
array << memo
|
121
115
|
3.times { | i |
|
122
116
|
if i < splits.size
|
123
|
-
array << splits[i]['amount']
|
124
|
-
array << splits[i]['category']
|
125
|
-
array << splits[i]['memo']
|
117
|
+
array << splits[i]['amount'].to_s
|
118
|
+
array << splits[i]['category']
|
119
|
+
array << splits[i]['memo']
|
126
120
|
else
|
127
121
|
array << '0.0'
|
128
122
|
array << ''
|
@@ -139,12 +133,12 @@ module Qiflib
|
|
139
133
|
array << 'x'
|
140
134
|
array
|
141
135
|
end
|
142
|
-
|
136
|
+
|
143
137
|
def line_value(s)
|
144
138
|
return '' if s.nil? || s.size < 1
|
145
139
|
s[1, s.size].strip
|
146
140
|
end
|
147
|
-
|
141
|
+
|
148
142
|
end
|
149
|
-
|
143
|
+
|
150
144
|
end
|
data/lib/qiflib_util.rb
CHANGED
@@ -173,6 +173,16 @@ module Qiflib
|
|
173
173
|
lines
|
174
174
|
end
|
175
175
|
|
176
|
+
# For testing purposes: Qiflib::Util::describe_csv_field_array(array)
|
177
|
+
|
178
|
+
def self.describe_csv_field_array(array)
|
179
|
+
field_map = Qiflib::csv_transaction_field_map
|
180
|
+
array.each_with_index { | val, idx |
|
181
|
+
field_name = field_map[idx]
|
182
|
+
puts "array[#{idx}].should == '#{val}' # #{field_name}"
|
183
|
+
}
|
184
|
+
end
|
185
|
+
|
176
186
|
private
|
177
187
|
|
178
188
|
def self.process_file_for_transactions(owner, filename, source, transactions)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiflib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Joakim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|