moneymanager 0.2.0 → 0.3.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.md +49 -46
- data/exe/mm +16 -38
- data/lib/moneymanager/layout.rb +13 -16
- data/lib/moneymanager/report.rb +35 -0
- data/lib/moneymanager/version.rb +1 -1
- data/lib/moneymanager.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d12b2140748dad9d3d6eda4bdc9bb3000932eeba
|
4
|
+
data.tar.gz: 59f8c42433720e5875a1098a40a49b2a2572323a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57ae82ff42ba946498532d090b752293eaf5134e3a63afb986de516a7df120df2a92516ec3ce481a36f7823047c7249320863880f451b991f4ee89f8d0a2b0af
|
7
|
+
data.tar.gz: 489c85decc4ae67e7d2ec5314681a2088a1e6ce0fc8f84e43339fa885b35036305050e872b064f9ccb9bf6ddacd19c3a24262755f23a993e19f85081a17ccc63
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ I ended up writing my own tool instead of using MoneyWiz et simila is that all t
|
|
17
17
|
|
18
18
|
* The database is just a plain, non-encrypted file.
|
19
19
|
* There are no fancy charts.
|
20
|
-
* The
|
20
|
+
* The filter is _monthly_ based. If you have undreds of transaction per month this tool can be tedious.
|
21
21
|
*
|
22
22
|
|
23
23
|
## Usage
|
@@ -117,61 +117,59 @@ Assign a tag to each (or not) transaction. To generate hierarchy of tags, use a
|
|
117
117
|
|
118
118
|
## Reporting
|
119
119
|
|
120
|
-
####
|
120
|
+
#### Total
|
121
121
|
|
122
122
|
$ mm report --month 8
|
123
123
|
|
124
124
|
$ mm report --month 8
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
125
|
+
Which type of report? (Use arrow keys, press Enter to select)
|
126
|
+
‣ Total (Incomes)
|
127
|
+
Total (Expenses)
|
128
|
+
All Incomes
|
129
|
+
All Expenses
|
130
|
+
Specific Tag
|
129
131
|
|
130
132
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
| Expense | -5678.0 € |
|
136
|
-
| Delta | 9999.0 € |
|
137
|
-
+---------+-----------+
|
133
|
+
Which type of report? Total (Incomes)
|
134
|
+
+-----------+
|
135
|
+
| 99999.0 € |
|
136
|
+
+-----------+
|
138
137
|
|
139
|
-
####
|
138
|
+
#### All Incomes/Expenses
|
140
139
|
|
141
140
|
|
142
141
|
$ mm report
|
143
142
|
Which type of report? (Use arrow keys, press Enter to select)
|
144
|
-
|
145
|
-
|
146
|
-
|
143
|
+
Total (Incomes)
|
144
|
+
Total (Expenses)
|
145
|
+
‣ All Incomes
|
146
|
+
All Expenses
|
147
|
+
Specific Tag
|
147
148
|
|
149
|
+
|
148
150
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
| Heating | -99.0 € |
|
160
|
-
| Mortage | -99.0 € |
|
161
|
-
| Car/Gasoline | -99.0 € |
|
162
|
-
| Car/Insurace | -9999.0 € |
|
163
|
-
| Car/Tire | -999.0 € |
|
164
|
-
+-------------------+-----------+
|
151
|
+
Which type of report? All Incomes
|
152
|
+
+--------------+----------+
|
153
|
+
| Kindergeld | 999.0 € |
|
154
|
+
| Rimborsi | 998.0 € |
|
155
|
+
| Stipendio | 8998.0 € |
|
156
|
+
| Stockoptions | 9999.0 € |
|
157
|
+
| Unknown | 888.0 € |
|
158
|
+
+--------------+----------+
|
159
|
+
| 9999999.0 € |
|
160
|
+
+--------------+----------+
|
165
161
|
|
166
162
|
|
167
|
-
####
|
163
|
+
#### One tag grouped by month
|
168
164
|
|
169
165
|
|
170
166
|
$ mm report
|
171
167
|
Which type of report? (Use arrow keys, press Enter to select)
|
172
|
-
|
173
|
-
|
174
|
-
|
168
|
+
Total (Incomes)
|
169
|
+
Total (Expenses)
|
170
|
+
All Incomes
|
171
|
+
All Expenses
|
172
|
+
‣ Specific Tag
|
175
173
|
|
176
174
|
Select a tag. (Use arrow keys, press Enter to select)
|
177
175
|
‣ Heating
|
@@ -180,20 +178,25 @@ Assign a tag to each (or not) transaction. To generate hierarchy of tags, use a
|
|
180
178
|
Car/Insurance
|
181
179
|
Car/Tire
|
182
180
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
181
|
+
Select a tag. Kita
|
182
|
+
+---+---------+
|
183
|
+
| 8 | -99.0 € |
|
184
|
+
| 9 | -99.0 € |
|
185
|
+
+---+---------+
|
186
|
+
| -198.0 € |
|
187
|
+
+---+---------+
|
188
188
|
|
189
189
|
|
190
190
|
|
191
191
|
|
192
|
-
##
|
192
|
+
## To do
|
193
193
|
|
194
|
-
* Report for nested tags ( Car/Gasoline, Car/Insurance etc)
|
195
|
-
* Multiple tags
|
196
|
-
* Report for one tag splitted by month
|
194
|
+
* [ ] Report for nested tags ( Car/Gasoline, Car/Insurance etc)
|
195
|
+
* [ ] Multiple tags
|
196
|
+
* [x] Report for one tag splitted by month
|
197
|
+
* [ ] Add a backup options
|
198
|
+
* [ ] Manage multiple banck account
|
199
|
+
* [ ] Exclude account transfer from the list of expenses/incomes
|
197
200
|
|
198
201
|
## Contributing
|
199
202
|
|
data/exe/mm
CHANGED
@@ -67,54 +67,32 @@ command :report do |c|
|
|
67
67
|
|
68
68
|
prompt = TTY::Prompt.new
|
69
69
|
command = prompt.select('Which type of report?') do |menu|
|
70
|
-
menu.choice '
|
71
|
-
menu.choice '
|
72
|
-
menu.choice '
|
70
|
+
menu.choice 'Total (Incomes)', :global_incomes
|
71
|
+
menu.choice 'Total (Expenses)', :global_expenses
|
72
|
+
menu.choice 'All Incomes', :all_incomes
|
73
|
+
menu.choice 'All Expenses', :all_expenses
|
74
|
+
menu.choice 'Specific Tag', :one_tag
|
73
75
|
end
|
74
|
-
|
76
|
+
report = Report.new
|
75
77
|
case command
|
76
|
-
when :
|
77
|
-
|
78
|
-
when :
|
79
|
-
|
80
|
-
when :
|
78
|
+
when :global_incomes
|
79
|
+
report.print_total_report(entries, true)
|
80
|
+
when :global_expenses
|
81
|
+
report.print_total_report(entries, false)
|
82
|
+
when :all_incomes
|
83
|
+
report.print_group_by_categories_report(entries, true)
|
84
|
+
when :all_expenses
|
85
|
+
report.print_group_by_categories_report(entries, false)
|
86
|
+
when :one_tag
|
81
87
|
archiver = Moneymanager::Archiver.new
|
82
88
|
tags = archiver.tags.sort!
|
83
89
|
tag = prompt.select('Select a tag.', tags, per_page: 30)
|
84
|
-
|
90
|
+
report.print_group_by_month_report(entries,tag)
|
85
91
|
end
|
86
92
|
end
|
87
93
|
end
|
88
94
|
|
89
|
-
def print_global_report(entries)
|
90
|
-
expenses = entries.reject(&:income?).map(&:amount).reduce(:+)
|
91
|
-
incomes = entries.reject(&:expense?).map(&:amount).reduce(:+)
|
92
|
-
Layout.print_summary(incomes, expenses)
|
93
|
-
end
|
94
|
-
|
95
|
-
def print_all_categories_report(entries)
|
96
|
-
expenses = entries.reject(&:income?).each_with_object(Hash.new(0)) do |current, sum|
|
97
|
-
tag = current.tag ||= 'Unknown'
|
98
|
-
sum[tag] += current.amount
|
99
|
-
end
|
100
|
-
incomes = entries.reject(&:expense?).each_with_object(Hash.new(0)) do |current, sum|
|
101
|
-
tag = current.tag ||= 'Unknown'
|
102
|
-
sum[tag] += current.amount
|
103
|
-
end
|
104
|
-
|
105
|
-
incomes = incomes.map { |x, v| [x, v] }
|
106
|
-
Layout.print_summary_per_category('Incomes', incomes)
|
107
|
-
|
108
|
-
expenses = expenses.map { |x, v| [x, v] }
|
109
|
-
Layout.print_summary_per_category('Expenses', expenses)
|
110
|
-
end
|
111
95
|
|
112
|
-
def print_one_category_report(entries, tag)
|
113
|
-
entries = entries.select do |entry|
|
114
|
-
entry.tag == tag
|
115
|
-
end
|
116
|
-
print_all_categories_report(entries)
|
117
|
-
end
|
118
96
|
|
119
97
|
def get_entries(month)
|
120
98
|
archiver = Moneymanager::Archiver.new
|
data/lib/moneymanager/layout.rb
CHANGED
@@ -28,28 +28,25 @@ class Layout
|
|
28
28
|
amount < 0 ? s.red : s.green
|
29
29
|
end
|
30
30
|
|
31
|
-
def self.
|
32
|
-
delta = income + expenses
|
31
|
+
def self.print_single_value(total)
|
33
32
|
table = Terminal::Table.new do |t|
|
34
|
-
t << [
|
35
|
-
t << ['Expense', formatted_amount(expenses)]
|
36
|
-
t << ['Delta', formatted_amount(delta)]
|
33
|
+
t << [formatted_amount(total)]
|
37
34
|
end
|
38
|
-
table.align_column(
|
39
|
-
table.title = 'Summary'
|
35
|
+
table.align_column(0, :right)
|
40
36
|
puts table
|
41
37
|
end
|
42
38
|
|
43
|
-
def self.
|
39
|
+
def self.print_generic_rows(rows)
|
44
40
|
return unless rows.count > 0
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
table.
|
41
|
+
sum = rows.reduce(0) { | tot, row | tot + row.last }
|
42
|
+
table = Terminal::Table.new
|
43
|
+
rows = rows.each { |row|
|
44
|
+
table.add_row [
|
45
|
+
{ :value => row[0], :alignment => :left},
|
46
|
+
{ :value => formatted_amount(row.last), :alignment => :right }]
|
47
|
+
}
|
48
|
+
table.add_separator
|
49
|
+
table.add_row [{ :value => formatted_amount(sum), :colspan => 2, :alignment => :right }]
|
53
50
|
|
54
51
|
puts table
|
55
52
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Report
|
2
|
+
|
3
|
+
def print_total_report(entries, onlyIncome)
|
4
|
+
total = 0
|
5
|
+
if (onlyIncome)
|
6
|
+
total = entries.reject(&:expense?).map(&:amount).reduce(:+)
|
7
|
+
else
|
8
|
+
total = entries.reject(&:income?).map(&:amount).reduce(:+)
|
9
|
+
end
|
10
|
+
Layout.print_single_value(total)
|
11
|
+
end
|
12
|
+
|
13
|
+
def print_group_by_categories_report(entries, onlyIncome)
|
14
|
+
|
15
|
+
entries = entries.select { |entry|
|
16
|
+
entry.income? == onlyIncome
|
17
|
+
}.each_with_object(Hash.new(0)) { |current, sum|
|
18
|
+
tag = current.tag ||= 'Unknown'
|
19
|
+
sum[tag] += current.amount
|
20
|
+
}.map { |x, v|
|
21
|
+
[x, v]
|
22
|
+
}.sort! { |r1, r2| r1.first <=> r2.first }
|
23
|
+
Layout.print_generic_rows(entries)
|
24
|
+
end
|
25
|
+
|
26
|
+
def print_group_by_month_report(entries, tag)
|
27
|
+
entries = entries.select { |entry|
|
28
|
+
entry.tag == tag
|
29
|
+
}.each_with_object(Hash.new(0)) { | current, sum |
|
30
|
+
month = current.date.month
|
31
|
+
sum[month] += current.amount
|
32
|
+
}
|
33
|
+
Layout.print_generic_rows(entries)
|
34
|
+
end
|
35
|
+
end
|
data/lib/moneymanager/version.rb
CHANGED
data/lib/moneymanager.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moneymanager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ignazioc
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/moneymanager/entry.rb
|
133
133
|
- lib/moneymanager/layout.rb
|
134
134
|
- lib/moneymanager/parser.rb
|
135
|
+
- lib/moneymanager/report.rb
|
135
136
|
- lib/moneymanager/reviewer.rb
|
136
137
|
- lib/moneymanager/tagger.rb
|
137
138
|
- lib/moneymanager/version.rb
|