bankstatement_txt 0.1.0 → 0.2.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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -4
- data/lib/bankstatement_txt.rb +62 -20
- metadata +27 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e49ec5aa9b3e52f149850c458b85ebeb0aae6cc
|
4
|
+
data.tar.gz: 353c107f42d660fb22fa41bd70c40a8d8eeffa75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f577a444167f7cfc41e4367e1af01de51c4c57c737152dffd027ae239bd708ea443f010b26b48dc138ab82c72f0984d408cadb43e6fd0a55ba0dfab5c9a3ec0
|
7
|
+
data.tar.gz: 4b5a40cbb8d1526996fed53ac2790683233b8bf70e510b0bcab51137576dcf8d58bbc8c1950e37d4b6aae540b78ca2fe208142dd54a8881b51b1bed8d7831abf
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,4 +1 @@
|
|
1
|
-
��
|
2
|
-
�t�\P��gڞZ�
|
3
|
-
#U�-�}�8<XZ7��)R+~�'֤��Uk��[x������
|
4
|
-
=�3��FOt�VI.���k���*�����r2��}��Bn�֦C�d}a>Q�A�iI��~��J*�8ܧhW�GW���<�Q��SRѡ�5)��7�b4:�
|
1
|
+
A��*�[�2 &�S����~���������یi����V��������������<;:�S�!4��&�HW��Ji�*���( ���?+�9@�^���&�An~�4�2�d�l�N�����87��>a��T����u�]F[i�0��L�8s��ו����#�0M�Rݒ�]We)v�s�V��cN�c�i��12���n�?����^��0T����T.f�Wv"�"I��k0x�����i�
|
data/lib/bankstatement_txt.rb
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
# file: bankstatement_txt.rb
|
4
4
|
|
5
5
|
require 'csv'
|
6
|
-
require '
|
6
|
+
require 'pxlite'
|
7
|
+
require 'dynarex'
|
7
8
|
|
8
9
|
|
9
10
|
class BankStatementTxt
|
@@ -18,6 +19,15 @@ class BankStatementTxt
|
|
18
19
|
new_import(filepath)
|
19
20
|
|
20
21
|
end
|
22
|
+
|
23
|
+
def inspect()
|
24
|
+
"<bankstatement #{object.id}>"
|
25
|
+
end
|
26
|
+
|
27
|
+
def summary()
|
28
|
+
@dx
|
29
|
+
end
|
30
|
+
|
21
31
|
|
22
32
|
private
|
23
33
|
|
@@ -34,40 +44,72 @@ class BankStatementTxt
|
|
34
44
|
|
35
45
|
a3 = a2.inject({}) do |r, pair|
|
36
46
|
|
37
|
-
year, x = pair
|
38
|
-
|
47
|
+
year, x = pair
|
39
48
|
r.merge(year => x.group_by {|y| Date.parse(y[:date]).month})
|
49
|
+
|
40
50
|
end
|
41
51
|
|
42
|
-
px =
|
43
|
-
"[date, type, desc, credit,
|
52
|
+
px = PxLite.new("statement[title,tags]/year[title]/month[title, " +
|
53
|
+
"credit, debit]/entry[date, type, desc, credit, " +
|
54
|
+
"debit, balance, tags]")
|
55
|
+
|
56
|
+
rec = []
|
44
57
|
|
45
58
|
a3.each do |year, year_entries|
|
59
|
+
|
60
|
+
rec << yearx = [{title: year.to_s}, []]
|
46
61
|
|
47
|
-
|
62
|
+
year_entries.each do |month, entries|
|
48
63
|
|
49
|
-
|
64
|
+
yearx.last << monthx = [{title: Date::ABBR_MONTHNAMES[month]}, []]
|
50
65
|
|
51
|
-
|
66
|
+
entries.each do |x|
|
52
67
|
|
53
|
-
|
68
|
+
v = x[:value]
|
69
|
+
credit, debit = v > 0 ? [v, nil] : [nil, v.abs]
|
70
|
+
monthx.last << [{date: x[:date], type: x[:type],
|
71
|
+
desc: x[:description], credit: credit,
|
72
|
+
debit: debit, balance: x[:balance]}, []]
|
73
|
+
end
|
54
74
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
# totalise each the credit and debit columns for each month
|
80
|
+
|
81
|
+
rec.each do |year, months|
|
82
|
+
months.each do |month, entries|
|
83
|
+
month[:credit] = entries.map {|x| x[0][:credit].to_f }.inject(:+)
|
84
|
+
month[:debit] = entries.map {|x| x[0][:debit].to_f }.inject(:+)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
# create a Dynarex document for the totals for each month
|
90
|
+
|
91
|
+
@dx = Dynarex.new('months[title]/month(uid, year, month, ' +
|
92
|
+
'debit, credit, net_income)')
|
60
93
|
|
61
|
-
|
94
|
+
rec.each do |year, months|
|
95
|
+
|
96
|
+
months.each do |month, entries|
|
62
97
|
|
63
|
-
|
98
|
+
debit, credit = month[:debit], month[:credit]
|
99
|
+
|
100
|
+
@dx.create year: year[:title], month: month[:title],
|
101
|
+
debit: debit.round(2), credit: credit.round(2),
|
102
|
+
net_income: (credit - debit).round(2)
|
64
103
|
|
65
|
-
end
|
66
104
|
end
|
67
|
-
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
px.records = rec
|
68
110
|
|
69
111
|
@px = px
|
70
|
-
|
112
|
+
|
71
113
|
end
|
72
114
|
|
73
|
-
end
|
115
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bankstatement_txt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,28 +31,48 @@ cert_chain:
|
|
31
31
|
l3bEsPWCwLg3hfh2htcob1/yVJznl1dJkzbh5zdU29szsFokcO1nP0dXHjhqM7JN
|
32
32
|
0JX4jQbOA03NMw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2017-02-
|
34
|
+
date: 2017-02-25 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
37
|
+
name: pxlite
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0.
|
42
|
+
version: '0.1'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.1.0
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '0.
|
52
|
+
version: '0.1'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
55
|
+
version: 0.1.0
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: dynarex
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.7'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.7.20
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '1.7'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.7.20
|
56
76
|
description:
|
57
77
|
email: james@jamesrobertson.eu
|
58
78
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|