bankstatement_txt 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +4 -0
- data/lib/bankstatement_txt.rb +73 -0
- metadata +87 -0
- metadata.gz.sig +1 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9be783526c3188914ee33acdd9acc900750599f9
|
4
|
+
data.tar.gz: dc6eaa9ef38b0dca54b5bef864c27515ade394ba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77ede1d1862571fcccd1d1a79a3d61ac847ad2dc040b6dc879d4571413b871b3eb085a65112ec218274f89767cce21366b0329376d932c476c2c7b8ae2413b87
|
7
|
+
data.tar.gz: 72e00aff0bdb42e47591e70d899338c0a1070ecf905ba11eef945dde11466bec90dffa80f7d0687a4ee7382f1f89c640c84f5e1eca3add1ab90cba5cfc51b662
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
}�Y���濢�^[
|
data.tar.gz.sig
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: bankstatement_txt.rb
|
4
|
+
|
5
|
+
require 'csv'
|
6
|
+
require 'polyrex'
|
7
|
+
|
8
|
+
|
9
|
+
class BankStatementTxt
|
10
|
+
|
11
|
+
attr_reader :px
|
12
|
+
|
13
|
+
def initialize()
|
14
|
+
end
|
15
|
+
|
16
|
+
def import(filepath)
|
17
|
+
|
18
|
+
new_import(filepath)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def new_import(filepath)
|
25
|
+
|
26
|
+
|
27
|
+
data = File.read filepath
|
28
|
+
csv = CSV.new(data, :headers => true, :header_converters => :symbol,
|
29
|
+
:converters => :all)
|
30
|
+
a = csv.to_a.map(&:to_hash)
|
31
|
+
|
32
|
+
a.reject!(&:empty?)
|
33
|
+
a2 = a.group_by {|x| Date.parse(x[:date]).year }
|
34
|
+
|
35
|
+
a3 = a2.inject({}) do |r, pair|
|
36
|
+
|
37
|
+
year, x = pair
|
38
|
+
|
39
|
+
r.merge(year => x.group_by {|y| Date.parse(y[:date]).month})
|
40
|
+
end
|
41
|
+
|
42
|
+
px = Polyrex.new("statement[title,tags]/year[title]/month[title]/entry" +
|
43
|
+
"[date, type, desc, credit, debit, balance, tags]")
|
44
|
+
|
45
|
+
a3.each do |year, year_entries|
|
46
|
+
|
47
|
+
px.create_year(title: year.to_s) do |create1|
|
48
|
+
|
49
|
+
year_entries.each do |month, entries|
|
50
|
+
|
51
|
+
create1.month(title: Date::ABBR_MONTHNAMES[month]) do |create2|
|
52
|
+
|
53
|
+
entries.each do |x|
|
54
|
+
|
55
|
+
v = x[:value]
|
56
|
+
credit, debit = v > 0 ? [v, nil] : [nil, v.abs]
|
57
|
+
create2.entry date: x[:date], type: x[:type],
|
58
|
+
desc: x[:description], credit: credit,
|
59
|
+
debit: debit, balance: x[:balance]
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
@px = px
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bankstatement_txt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVyd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b9wCOgDANcu2HR1gJUPfOuJBIfsAks4iTM47uvG33nr5QBShlPwh8kz5QKt
|
30
|
+
8IO0CrwsNwbI49rsosNIgbZ2AWZxcUHBzxLy+1AdaL0OVznDxDxMSeTCxZRFgS9x
|
31
|
+
l3bEsPWCwLg3hfh2htcob1/yVJznl1dJkzbh5zdU29szsFokcO1nP0dXHjhqM7JN
|
32
|
+
0JX4jQbOA03NMw==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: polyrex
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.10'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.10.2
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.10'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.10.2
|
56
|
+
description:
|
57
|
+
email: james@jamesrobertson.eu
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/bankstatement_txt.rb
|
63
|
+
homepage: https://github.com/jrobertson/bankstatement_txt
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.6.8
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Experimental gem for querying a running bank statement.
|
87
|
+
test_files: []
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
X��˕n�0��Vd�DE-*�"앻�Ks'�k��s�e]/t���nb�����X����\�r?Ѣ^���'&On��/�8�
|