banco 1.0.0 → 1.0.1
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 +5 -5
- data/README +3 -3
- data/bin/banco +2 -3
- data/lib/banco/get_file.rb +2 -1
- data/lib/banco/reader.rb +31 -29
- data/lib/banco/reporter.rb +42 -36
- data/lib/banco/transaction.rb +6 -6
- data/lib/banco/viewable.rb +161 -161
- data/spec/banco/transaction_spec.rb +2 -2
- metadata +11 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 60bd4d04204c93b4dbae3ee5becb5def771886eb36c88a75834b71dc8743aeb5
|
|
4
|
+
data.tar.gz: c4b8d7afc258181edac4d231ce2bf4a5e8108794bcbc3f1a5b71acf3c37aa12f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a58423aa15b4f3fc8d77f7ed6f671f1949bbe4afb8f479fd363be2cd945ac3875d352ff4d3b11f9a2686539be541636b4df5605417bcbfff3c78941b3378cb1
|
|
7
|
+
data.tar.gz: 5c6da026e9223430eaf325c2f3d0b758ba43dd0aaae7dc75efc57307e614ddf5f5d74c8ee64b6653c85bb5c2aeabe920d0b992b2c407b0e616ac038457a5ebfd
|
data/README
CHANGED
|
@@ -5,8 +5,8 @@ Install as a Rubygem, navigate to the directory your .csv files are in and execu
|
|
|
5
5
|
|
|
6
6
|
Banco will only accept comma seperated value files (.csv) and will produce a summary for the period uploaded from the file.
|
|
7
7
|
|
|
8
|
-
Remove the header line from your downloaded bank statement
|
|
8
|
+
Remove the header line from your downloaded bank statement, ensure the columns are ordered date, description, type of charge, money in an money out from left to right, any columns right of the fifth will be ignored. Banco will total the incoming & outgoing transactions for the period. Reporting the bottom line aswell as summing up the values for similar transactions. This is achieved by matching the description name, currently set at the first 9 characters of the string, you can change this to be more or less exact.
|
|
9
9
|
|
|
10
10
|
Hope your numbers are positive !
|
|
11
|
-
|
|
12
|
-
https://
|
|
11
|
+
https://github.com/s33dco/banco
|
|
12
|
+
https://rubygems.org/gems/banco
|
data/bin/banco
CHANGED
|
@@ -6,16 +6,15 @@ require_relative '../lib/banco/reader'
|
|
|
6
6
|
require_relative '../lib/banco/reporter'
|
|
7
7
|
|
|
8
8
|
module Banco
|
|
9
|
+
|
|
9
10
|
def self.starter
|
|
10
11
|
Viewable::prompt
|
|
11
12
|
file = GetFile.new
|
|
12
|
-
file.make_name
|
|
13
|
-
reader = file.name
|
|
14
13
|
reader = Reader.new(file.csv_file_name, file.summary_name)
|
|
15
14
|
reader.read_in_csv_data
|
|
16
|
-
report = reader.report_name
|
|
17
15
|
report = Reporter.new(reader.csv_file_name, reader.report_name, reader.all_from_csv)
|
|
18
16
|
end
|
|
17
|
+
|
|
19
18
|
Viewable::hello
|
|
20
19
|
report = starter
|
|
21
20
|
loop do
|
data/lib/banco/get_file.rb
CHANGED
|
@@ -2,7 +2,7 @@ module Banco
|
|
|
2
2
|
class GetFile
|
|
3
3
|
attr_reader :name, :csv_file_name, :summary_name
|
|
4
4
|
|
|
5
|
-
def
|
|
5
|
+
def initialize
|
|
6
6
|
@csv_file_name = gets.chomp.downcase
|
|
7
7
|
if @csv_file_name == 'q'
|
|
8
8
|
Viewable::farewell
|
|
@@ -25,6 +25,7 @@ module Banco
|
|
|
25
25
|
make_name
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
|
+
|
|
28
29
|
end
|
|
29
30
|
end
|
|
30
31
|
|
data/lib/banco/reader.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require_relative 'transaction'
|
|
2
2
|
require_relative 'viewable'
|
|
3
|
-
|
|
4
3
|
require 'csv'
|
|
5
4
|
|
|
6
5
|
module Banco
|
|
@@ -16,36 +15,39 @@ module Banco
|
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
def read_in_csv_data
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
18
|
+
begin
|
|
19
|
+
@csv_row_count = 1
|
|
20
|
+
|
|
21
|
+
CSV.foreach(csv_file_name) do |row|
|
|
22
|
+
all_from_csv << Transaction.new(row[0],row[1],row[2],row[3],row[4],@csv_row_count)
|
|
23
|
+
@csv_row_count += 1
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
rescue ArgumentError => e
|
|
27
|
+
non_numeric_in_csv(e, @csv_row_count)
|
|
28
|
+
puts "sorted ? ('y' to continue or 'q' to exit)".rjust(54)
|
|
29
|
+
input = gets.chomp.downcase
|
|
30
|
+
@all_from_csv = []
|
|
31
|
+
input == "y" ? retry : Viewable::farewell
|
|
32
|
+
|
|
33
|
+
rescue Errno::ENOENT => e
|
|
34
|
+
puts "Can't find file #{@csv_file_name} - have another go or (q) quit\n\n"
|
|
35
|
+
loop do
|
|
36
|
+
input = gets.chomp.downcase
|
|
37
|
+
case input
|
|
38
|
+
when 'q'
|
|
39
|
+
Viewable::farewell
|
|
40
|
+
exit
|
|
41
|
+
when /([^\s]+(\.csv)$)/
|
|
40
42
|
@csv_file_name = input
|
|
41
43
|
break
|
|
42
|
-
else
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
else
|
|
45
|
+
puts "\ninvalid file - try again or 'q' to quit\n\n"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
retry
|
|
49
|
+
end
|
|
50
|
+
end
|
|
49
51
|
|
|
50
52
|
def non_numeric_in_csv(exception, row_number)
|
|
51
53
|
reason = exception.message.split(':')
|
data/lib/banco/reporter.rb
CHANGED
|
@@ -4,49 +4,55 @@ require_relative 'viewable'
|
|
|
4
4
|
require 'csv'
|
|
5
5
|
|
|
6
6
|
module Banco
|
|
7
|
-
|
|
7
|
+
class Reporter
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
include Viewable
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
attr_reader :all_transactions,
|
|
12
|
+
:outgoing_trans,
|
|
13
|
+
:incoming_trans,
|
|
14
|
+
:outgoings,
|
|
15
|
+
:incomings,
|
|
16
|
+
:outgoing_total,
|
|
17
|
+
:incoming_total,
|
|
18
|
+
:name,
|
|
19
|
+
:csv_file_name
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
def initialize(csv_file_name, report_name, transactions)
|
|
22
|
+
@csv_file_name = csv_file_name
|
|
23
|
+
@name = report_name
|
|
24
|
+
@all_transactions = transactions
|
|
25
|
+
@outgoing_trans = []
|
|
26
|
+
@incoming_trans = []
|
|
27
|
+
@outgoings = Hash.new(0)
|
|
28
|
+
@incomings = Hash.new(0)
|
|
29
|
+
puts "formating data..."
|
|
30
|
+
remove_blank_lines
|
|
31
|
+
split_in_out
|
|
32
|
+
total_outgoing
|
|
33
|
+
total_incoming
|
|
34
|
+
puts "\n\n"
|
|
35
|
+
end
|
|
30
36
|
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
def remove_blank_lines
|
|
39
|
+
@all_transactions.delete_if{|trans| trans.moneyin == 0 && trans.moneyout == 0}
|
|
40
|
+
end
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
def split_in_out
|
|
43
|
+
@outgoing_trans, @incoming_trans = @all_transactions.partition{|trans| trans.moneyin == 0 && trans.moneyout > 0}
|
|
44
|
+
end
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
def total_outgoing
|
|
47
|
+
@outgoing_trans.each{|trans| @outgoings[trans.description[0..8]] += trans.moneyout}
|
|
48
|
+
@outgoing_total = @outgoings.values.map.reduce(:+)
|
|
49
|
+
end
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
def total_incoming
|
|
52
|
+
@incoming_trans.each{|trans| @incomings[trans.description[0..8]] += trans.moneyin}
|
|
53
|
+
@incoming_total = @incomings.values.map.reduce(:+)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
50
56
|
end
|
|
51
57
|
|
|
52
58
|
|
|
@@ -60,7 +66,7 @@ if __FILE__ == $0
|
|
|
60
66
|
puts "\n\nall transactions array\n"
|
|
61
67
|
p report.all_transactions
|
|
62
68
|
puts "\n\noutgoings array\n"
|
|
63
|
-
p report.outgoing_trans
|
|
69
|
+
p report.outgoing_trans
|
|
64
70
|
puts "\n\nincomings array\n"
|
|
65
71
|
p report.incoming_trans
|
|
66
72
|
puts "\n\nOutgoings hash\n"
|
data/lib/banco/transaction.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Banco
|
|
|
14
14
|
|
|
15
15
|
def convert(money)
|
|
16
16
|
money.nil? ? money = BigDecimal('0') : money = BigDecimal(money)
|
|
17
|
-
|
|
17
|
+
end
|
|
18
18
|
|
|
19
19
|
def to_s
|
|
20
20
|
"#{date} #{type} #{description}"
|
|
@@ -23,9 +23,9 @@ module Banco
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
if __FILE__ == $0
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
trans = Banco::Transaction.new("01/01/17", "Supermarket","Purchase", "72.90", "0","1")
|
|
27
|
+
p trans
|
|
28
|
+
t = Banco::Transaction.new
|
|
29
|
+
t.send(:initialize, "02/02/18", "new way", "credit", "0", '111.11','2')
|
|
30
|
+
p t
|
|
31
31
|
end
|
data/lib/banco/viewable.rb
CHANGED
|
@@ -1,180 +1,180 @@
|
|
|
1
1
|
module Banco
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
module Viewable
|
|
3
|
+
def menu
|
|
4
|
+
puts "Enter :\n"
|
|
5
|
+
puts "'a' to view all transactions"
|
|
6
|
+
puts "'o' to view all outgoing transactions"
|
|
7
|
+
puts "'i' to view all incoming transactions"
|
|
8
|
+
puts "'m' for money out summary"
|
|
9
|
+
puts "'n' for money in summary"
|
|
10
|
+
puts "'b' for the bottom line"
|
|
11
|
+
puts "'s' to save summaries to file"
|
|
12
|
+
puts "'t' to save transactions to file"
|
|
13
|
+
puts "\n'l' to load a new file\n"
|
|
14
|
+
puts "\nor 'q' to quit\n\n\n"
|
|
15
|
+
end
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
def to_pounds(money)
|
|
18
|
+
format = sprintf("%10.2f", money.truncate(2))
|
|
19
|
+
"£#{format}"
|
|
20
|
+
end
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
def dashes
|
|
23
|
+
"---".center(55,"-")
|
|
24
|
+
end
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
def date_range
|
|
27
|
+
"(#{self.all_transactions.last.date} - #{self.all_transactions.first.date})"
|
|
28
|
+
end
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
def facts(transactions)
|
|
31
|
+
"#{transactions.size} transactions for period #{date_range}"
|
|
32
|
+
end
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
def money_out_summary
|
|
35
|
+
print_summary("Outgoings", self.outgoings, self.outgoing_total)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def money_in_summary
|
|
39
|
+
print_summary("Incomings", self.incomings, self.incoming_total)
|
|
40
|
+
end
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
end
|
|
42
|
+
def transactions_all
|
|
43
|
+
output = output_s = ""
|
|
44
|
+
output << dashes
|
|
45
|
+
output << "\n"
|
|
46
|
+
output << "All transactions:\n"
|
|
47
|
+
output << "#{facts(self.all_transactions)}\n\n"
|
|
48
|
+
self.all_transactions.each do |trans|
|
|
49
|
+
if trans.moneyout == 0
|
|
50
|
+
output << "#{trans} + #{to_pounds(trans.moneyin)}\n"
|
|
51
|
+
else
|
|
52
|
+
output << "#{trans} - #{to_pounds(trans.moneyout)}\n"
|
|
54
53
|
end
|
|
55
|
-
output << dashes
|
|
56
|
-
output << "\n\n"
|
|
57
54
|
end
|
|
55
|
+
output << dashes
|
|
56
|
+
output << "\n\n"
|
|
57
|
+
end
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
def transactions_out
|
|
60
|
+
output = output_s = ""
|
|
61
|
+
output << dashes
|
|
62
|
+
output << "\n"
|
|
63
|
+
output << "Outgoing Transactions:\n"
|
|
64
|
+
output << "#{facts(self.outgoing_trans)}\n\n"
|
|
65
|
+
self.outgoing_trans.each{|trans| output << "#{trans} - #{to_pounds(trans.moneyout)}\n"}
|
|
66
|
+
output << dashes
|
|
67
|
+
output << "\n\n"
|
|
68
|
+
end
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
def transactions_in
|
|
71
|
+
output = output_s = ""
|
|
72
|
+
output << dashes
|
|
73
|
+
output << "\n"
|
|
74
|
+
output << "Incoming Transactions :\n"
|
|
75
|
+
output << "#{facts(self.incoming_trans)}\n\n"
|
|
76
|
+
self.incoming_trans.each{|trans| output << "#{trans} + #{to_pounds(trans.moneyin)}\n"}
|
|
77
|
+
output << dashes
|
|
78
|
+
output << "\n\n"
|
|
79
|
+
end
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
81
|
+
def print_summary(kind, hash, total)
|
|
82
|
+
output = output_s = ""
|
|
83
|
+
output << dashes
|
|
84
|
+
output << "\n"
|
|
85
|
+
output << "#{kind} Summary, totals from #{hash.size} different sources :\n"
|
|
86
|
+
output << "#{date_range}\n"
|
|
87
|
+
hash.sort_by{|_k,v| v}.reverse.each{|k,v| output << "#{k} #{to_pounds(v)}\n".rjust(54)}
|
|
88
|
+
output << "\n"
|
|
89
|
+
output << "Total #{kind}: #{to_pounds(total)}\n".rjust(54)
|
|
90
|
+
output << dashes
|
|
91
|
+
output << "\n\n"
|
|
92
|
+
end
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
94
|
+
def bottom_line
|
|
95
|
+
output = output_s = ""
|
|
96
|
+
output << dashes
|
|
97
|
+
output << "\n"
|
|
98
|
+
output << "#{facts(self.all_transactions)}".rjust(54)
|
|
99
|
+
output << "\n\n"
|
|
100
|
+
output << "Money In : #{to_pounds(self.incoming_total)}".rjust(54)
|
|
101
|
+
output << "\n"
|
|
102
|
+
output << "Money Out : #{to_pounds(self.outgoing_total)}".rjust(54)
|
|
103
|
+
output << "\n\n"
|
|
104
|
+
diff = self.incoming_total - self.outgoing_total
|
|
105
|
+
if self.outgoing_total > self.incoming_total
|
|
106
|
+
output << "Outgoings exceed Incomings, DEFICIT of #{to_pounds(diff)}".rjust(54)
|
|
107
|
+
else
|
|
108
|
+
output << "Incomings exceed Outgoings, SURPLUS of #{to_pounds(diff)}".rjust(54)
|
|
109
|
+
end
|
|
110
|
+
output << "\n"
|
|
111
|
+
output << dashes
|
|
112
|
+
output << "\n\n"
|
|
113
|
+
end
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
def self.farewell
|
|
116
|
+
puts "\n\n"
|
|
117
|
+
puts "*".center(55,'*')
|
|
118
|
+
puts " Banco ".center(55,'*')
|
|
119
|
+
puts " hope your numbers were positive ".center(55,'*')
|
|
120
|
+
puts " code@s33d.co ".center(55,'*')
|
|
121
|
+
puts "*".center(55,'*')
|
|
122
|
+
puts "\n\n\n"
|
|
123
|
+
exit
|
|
124
|
+
end
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
126
|
+
def self.hello
|
|
127
|
+
puts "\n\n"
|
|
128
|
+
puts "Banco will summarize your bank statements.".center(55)
|
|
129
|
+
puts "import a .csv file for review".center(55)
|
|
130
|
+
puts "\n\n"
|
|
131
|
+
puts "the .csv file should have :".center(55)
|
|
132
|
+
puts "NO headers".center(55)
|
|
133
|
+
puts "with columns ordered (left to right)".center(55)
|
|
134
|
+
puts "date - description - type - money in - money out".center(55)
|
|
135
|
+
puts "all additional columns will be ignored".center(55)
|
|
136
|
+
end
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def save_summary_to_file(to_file="#{self.name}_summary.txt")
|
|
147
|
-
File.open(to_file, "w") do |file|
|
|
148
|
-
t = Time.now
|
|
149
|
-
file.puts t.strftime("\n\nprinted : %d %b %y at %I:%M%P")
|
|
150
|
-
file.puts "summarized by Banco from #{self.csv_file_name}"
|
|
151
|
-
file.puts "\n"
|
|
152
|
-
file.puts self.money_out_summary
|
|
153
|
-
file.puts "\n"
|
|
154
|
-
file.puts self.money_in_summary
|
|
155
|
-
file.puts "\n"
|
|
156
|
-
file.puts self.bottom_line
|
|
157
|
-
file.puts "\n"
|
|
158
|
-
file.puts "code@s33d.co".rjust(54)
|
|
159
|
-
end
|
|
160
|
-
puts "\n\nfile saved as #{self.name}_summary.txt\n\n"
|
|
161
|
-
end
|
|
138
|
+
def self.prompt
|
|
139
|
+
puts "\n\n"
|
|
140
|
+
puts "Enter the name of you .csv file to review".center(54)
|
|
141
|
+
puts "(use 'test.csv' for the test file)".center(54)
|
|
142
|
+
puts "or 'q' to quit...".center(55)
|
|
143
|
+
puts "\n\n"
|
|
144
|
+
end
|
|
162
145
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
146
|
+
def save_summary_to_file(to_file="#{self.name}_summary.txt")
|
|
147
|
+
File.open(to_file, "w") do |file|
|
|
148
|
+
t = Time.now
|
|
149
|
+
file.puts t.strftime("\n\nprinted : %d %b %y at %I:%M%P")
|
|
150
|
+
file.puts "summarized by Banco from #{self.csv_file_name}"
|
|
151
|
+
file.puts "\n"
|
|
152
|
+
file.puts self.money_out_summary
|
|
153
|
+
file.puts "\n"
|
|
154
|
+
file.puts self.money_in_summary
|
|
155
|
+
file.puts "\n"
|
|
156
|
+
file.puts self.bottom_line
|
|
157
|
+
file.puts "\n"
|
|
158
|
+
file.puts "code@s33d.co".rjust(54)
|
|
159
|
+
end
|
|
160
|
+
puts "\n\nfile saved as #{self.name}_summary.txt\n\n"
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def save_transactions_to_file(to_file="#{self.name}_transactions.txt")
|
|
164
|
+
File.open(to_file, "w") do |file|
|
|
165
|
+
t = Time.now
|
|
166
|
+
file.puts t.strftime("\n\nprinted : %d %b %y at %I:%M%P")
|
|
167
|
+
file.puts "summarized by Banco from #{self.csv_file_name}"
|
|
168
|
+
file.puts "\n"
|
|
169
|
+
file.puts self.transactions_out
|
|
170
|
+
file.puts "\n"
|
|
171
|
+
file.puts self.transactions_in
|
|
172
|
+
file.puts "\n"
|
|
173
|
+
file.puts self.bottom_line
|
|
174
|
+
file.puts "\n"
|
|
175
|
+
file.puts "code@s33d.co".rjust(54)
|
|
176
|
+
end
|
|
177
|
+
puts "\n\nfile saved as #{self.name}_transactions.txt\n\n"
|
|
178
|
+
end
|
|
179
179
|
end
|
|
180
180
|
end
|
|
@@ -2,7 +2,7 @@ require 'banco/transaction'
|
|
|
2
2
|
|
|
3
3
|
module Banco
|
|
4
4
|
describe Transaction do
|
|
5
|
-
before do
|
|
5
|
+
before do
|
|
6
6
|
@trans1 = Transaction.new("12/01/17","some transaction", "credit", "57.91", "0.00", "1")
|
|
7
7
|
@trans2 = Transaction.new("13/01/17","some other transaction", "debit", "0.00", "57.91",'2')
|
|
8
8
|
end
|
|
@@ -23,7 +23,7 @@ module Banco
|
|
|
23
23
|
it "Should have a type string upcased and 8 characters long" do
|
|
24
24
|
expect(@trans2.type).to eq("DEBIT ")
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
it "Should have a date string" do
|
|
28
28
|
expect(@trans1.date).to eq("12/01/17")
|
|
29
29
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: banco
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- s33d
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-06-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -29,11 +29,13 @@ description: "Welcome to Banco !\n\nBanco has been developed to summarize statem
|
|
|
29
29
|
.csv files are in and execute from the command line with 'banco'.\n\nBanco will
|
|
30
30
|
only accept comma seperated value files (.csv) and will produce a summary for the
|
|
31
31
|
period uploaded from the file. \n\nRemove the header line from your downloaded bank
|
|
32
|
-
statement
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
statement, ensure the columns are ordered date, description, type of charge, money
|
|
33
|
+
in an money out from left to right, any columns right of the fifth will be ignored.
|
|
34
|
+
Banco will total the incoming & outgoing transactions for the period. Reporting
|
|
35
|
+
the bottom line aswell as summing up the values for similar transactions. This is
|
|
36
|
+
achieved by matching the description name, currently set at the first 9 characters
|
|
37
|
+
of the string, you can change this to be more or less exact.\n\nHope your numbers
|
|
38
|
+
are positive !\nhttps://github.com/s33dco/banco\nhttps://rubygems.org/gems/banco"
|
|
37
39
|
email: code@s33d.co
|
|
38
40
|
executables:
|
|
39
41
|
- banco
|
|
@@ -70,12 +72,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
70
72
|
- !ruby/object:Gem::Version
|
|
71
73
|
version: '0'
|
|
72
74
|
requirements: []
|
|
73
|
-
|
|
74
|
-
rubygems_version: 2.6.12
|
|
75
|
+
rubygems_version: 3.0.3
|
|
75
76
|
signing_key:
|
|
76
77
|
specification_version: 4
|
|
77
78
|
summary: Make your bank's .csv file statement more readable
|
|
78
79
|
test_files:
|
|
79
80
|
- spec/banco/reader_spec.rb
|
|
80
|
-
- spec/banco/reporter_spec.rb
|
|
81
81
|
- spec/banco/transaction_spec.rb
|
|
82
|
+
- spec/banco/reporter_spec.rb
|