rock_books 0.6.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -10
- data/RELEASE_NOTES.md +57 -10
- data/assets/fonts/JetBrainsMono-Medium.ttf +0 -0
- data/lib/rock_books/cmd_line/command_line_interface.rb +15 -24
- data/lib/rock_books/cmd_line/main.rb +1 -9
- data/lib/rock_books/documents/book_set.rb +5 -2
- data/lib/rock_books/documents/chart_of_accounts.rb +29 -12
- data/lib/rock_books/documents/journal.rb +3 -8
- data/lib/rock_books/documents/journal_entry.rb +7 -2
- data/lib/rock_books/documents/journal_entry_builder.rb +4 -0
- data/lib/rock_books/helpers/book_set_loader.rb +3 -3
- data/lib/rock_books/reports/balance_sheet.rb +9 -43
- data/lib/rock_books/reports/book_set_reporter.rb +138 -106
- data/lib/rock_books/reports/data/bs_is_data.rb +61 -0
- data/lib/rock_books/reports/data/bs_is_section_data.rb +30 -0
- data/lib/rock_books/reports/data/journal_data.rb +38 -0
- data/lib/rock_books/reports/data/multidoc_txn_by_account_data.rb +40 -0
- data/lib/rock_books/reports/data/multidoc_txn_report_data.rb +39 -0
- data/lib/rock_books/reports/data/receipts_report_data.rb +47 -0
- data/lib/rock_books/reports/data/tx_one_account_data.rb +37 -0
- data/lib/rock_books/reports/helpers/erb_helper.rb +21 -0
- data/lib/rock_books/reports/helpers/receipts_hyperlink_converter.rb +59 -0
- data/lib/rock_books/reports/helpers/text_report_helper.rb +144 -0
- data/lib/rock_books/reports/income_statement.rb +9 -47
- data/lib/rock_books/reports/index_html_page.rb +27 -0
- data/lib/rock_books/reports/journal_report.rb +82 -0
- data/lib/rock_books/reports/multidoc_txn_by_account_report.rb +32 -0
- data/lib/rock_books/reports/multidoc_txn_report.rb +25 -0
- data/lib/rock_books/reports/receipts_report.rb +6 -55
- data/lib/rock_books/reports/templates/html/index.html.erb +158 -0
- data/lib/rock_books/reports/templates/html/report_page.html.erb +25 -0
- data/lib/rock_books/reports/templates/text/_receipt_section.txt.erb +17 -0
- data/lib/rock_books/reports/templates/text/_totals.txt.erb +8 -0
- data/lib/rock_books/reports/templates/text/balance_sheet.txt.erb +23 -0
- data/lib/rock_books/reports/templates/text/income_statement.txt.erb +23 -0
- data/lib/rock_books/reports/templates/text/journal.txt.erb +23 -0
- data/lib/rock_books/reports/templates/text/multidoc_txn_by_account_report.txt.erb +31 -0
- data/lib/rock_books/reports/templates/text/multidoc_txn_report.txt.erb +25 -0
- data/lib/rock_books/reports/templates/text/receipts_report.txt.erb +16 -0
- data/lib/rock_books/reports/templates/text/tx_one_account.txt.erb +21 -0
- data/lib/rock_books/reports/tx_one_account.rb +10 -45
- data/lib/rock_books/types/account.rb +13 -1
- data/lib/rock_books/types/account_type.rb +18 -7
- data/lib/rock_books/version.rb +2 -1
- data/manual.md +13 -16
- data/rock_books.gemspec +2 -0
- metadata +57 -10
- data/lib/rock_books/helpers/html_helper.rb +0 -29
- data/lib/rock_books/reports/index.html.erb +0 -156
- data/lib/rock_books/reports/multidoc_transaction_report.rb +0 -66
- data/lib/rock_books/reports/receipts.html.erb +0 -54
- data/lib/rock_books/reports/reporter.rb +0 -118
- data/lib/rock_books/reports/transaction_report.rb +0 -105
- data/lib/rock_books/reports/tx_by_account.rb +0 -82
data/rock_books.gemspec
CHANGED
@@ -33,6 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency 'amazing_print', '> 0'
|
34
34
|
spec.add_dependency 'os', '> 1.0.0'
|
35
35
|
spec.add_dependency 'pry', '> 0.0.0'
|
36
|
+
spec.add_dependency 'prawn', '>= 2.1'
|
37
|
+
spec.add_dependency 'tty-progressbar'
|
36
38
|
|
37
39
|
spec.add_development_dependency "bundler", "~> 2.0"
|
38
40
|
spec.add_development_dependency "rake", ">= 12.3.3"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rock_books
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Bennett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - ">"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: prawn
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: tty-progressbar
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: bundler
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,6 +139,7 @@ files:
|
|
111
139
|
- README.md
|
112
140
|
- RELEASE_NOTES.md
|
113
141
|
- Rakefile
|
142
|
+
- assets/fonts/JetBrainsMono-Medium.ttf
|
114
143
|
- bin/console
|
115
144
|
- bin/setup
|
116
145
|
- exe/rock_books
|
@@ -130,19 +159,37 @@ files:
|
|
130
159
|
- lib/rock_books/filters/acct_amount_filters.rb
|
131
160
|
- lib/rock_books/filters/journal_entry_filters.rb
|
132
161
|
- lib/rock_books/helpers/book_set_loader.rb
|
133
|
-
- lib/rock_books/helpers/html_helper.rb
|
134
162
|
- lib/rock_books/helpers/parse_helper.rb
|
135
163
|
- lib/rock_books/reports/balance_sheet.rb
|
136
164
|
- lib/rock_books/reports/book_set_reporter.rb
|
165
|
+
- lib/rock_books/reports/data/bs_is_data.rb
|
166
|
+
- lib/rock_books/reports/data/bs_is_section_data.rb
|
167
|
+
- lib/rock_books/reports/data/journal_data.rb
|
168
|
+
- lib/rock_books/reports/data/multidoc_txn_by_account_data.rb
|
169
|
+
- lib/rock_books/reports/data/multidoc_txn_report_data.rb
|
170
|
+
- lib/rock_books/reports/data/receipts_report_data.rb
|
171
|
+
- lib/rock_books/reports/data/tx_one_account_data.rb
|
172
|
+
- lib/rock_books/reports/helpers/erb_helper.rb
|
173
|
+
- lib/rock_books/reports/helpers/receipts_hyperlink_converter.rb
|
174
|
+
- lib/rock_books/reports/helpers/text_report_helper.rb
|
137
175
|
- lib/rock_books/reports/income_statement.rb
|
138
|
-
- lib/rock_books/reports/
|
139
|
-
- lib/rock_books/reports/
|
140
|
-
- lib/rock_books/reports/
|
176
|
+
- lib/rock_books/reports/index_html_page.rb
|
177
|
+
- lib/rock_books/reports/journal_report.rb
|
178
|
+
- lib/rock_books/reports/multidoc_txn_by_account_report.rb
|
179
|
+
- lib/rock_books/reports/multidoc_txn_report.rb
|
141
180
|
- lib/rock_books/reports/receipts_report.rb
|
142
181
|
- lib/rock_books/reports/report_context.rb
|
143
|
-
- lib/rock_books/reports/
|
144
|
-
- lib/rock_books/reports/
|
145
|
-
- lib/rock_books/reports/
|
182
|
+
- lib/rock_books/reports/templates/html/index.html.erb
|
183
|
+
- lib/rock_books/reports/templates/html/report_page.html.erb
|
184
|
+
- lib/rock_books/reports/templates/text/_receipt_section.txt.erb
|
185
|
+
- lib/rock_books/reports/templates/text/_totals.txt.erb
|
186
|
+
- lib/rock_books/reports/templates/text/balance_sheet.txt.erb
|
187
|
+
- lib/rock_books/reports/templates/text/income_statement.txt.erb
|
188
|
+
- lib/rock_books/reports/templates/text/journal.txt.erb
|
189
|
+
- lib/rock_books/reports/templates/text/multidoc_txn_by_account_report.txt.erb
|
190
|
+
- lib/rock_books/reports/templates/text/multidoc_txn_report.txt.erb
|
191
|
+
- lib/rock_books/reports/templates/text/receipts_report.txt.erb
|
192
|
+
- lib/rock_books/reports/templates/text/tx_one_account.txt.erb
|
146
193
|
- lib/rock_books/reports/tx_one_account.rb
|
147
194
|
- lib/rock_books/types/account.rb
|
148
195
|
- lib/rock_books/types/account_type.rb
|
@@ -431,7 +478,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
431
478
|
- !ruby/object:Gem::Version
|
432
479
|
version: '0'
|
433
480
|
requirements: []
|
434
|
-
rubygems_version: 3.
|
481
|
+
rubygems_version: 3.2.3
|
435
482
|
signing_key:
|
436
483
|
specification_version: 4
|
437
484
|
summary: Very basic accounting package.
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module RockBooks
|
2
|
-
module HtmlHelper
|
3
|
-
|
4
|
-
module_function
|
5
|
-
|
6
|
-
def self.convert_receipts_to_hyperlinks(html_text)
|
7
|
-
html_lines = html_text.split("\n")
|
8
|
-
replacements_made = false
|
9
|
-
|
10
|
-
html_lines.each_with_index do |line, index|
|
11
|
-
matches = /Receipt:\s*(.*?)</.match(line)
|
12
|
-
if matches
|
13
|
-
receipt_filespec = matches[1]
|
14
|
-
line_with_hyperlink = line.gsub( \
|
15
|
-
/Receipt:\s*#{receipt_filespec}/, \
|
16
|
-
%Q{Receipt: <a href="../../../receipts/#{receipt_filespec}">#{receipt_filespec}</a>})
|
17
|
-
html_lines[index] = line_with_hyperlink
|
18
|
-
replacements_made = true
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
if replacements_made
|
23
|
-
html_text = html_lines.join("\n")
|
24
|
-
end
|
25
|
-
|
26
|
-
[html_text, replacements_made]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,156 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
|
4
|
-
<html>
|
5
|
-
|
6
|
-
<head>
|
7
|
-
|
8
|
-
<!--Bootstrap:-->
|
9
|
-
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
|
10
|
-
|
11
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
12
|
-
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
|
13
|
-
|
14
|
-
<style>
|
15
|
-
body {
|
16
|
-
padding: 18px;
|
17
|
-
background-color: #e7f7cd;
|
18
|
-
color: darkgreen;
|
19
|
-
}
|
20
|
-
|
21
|
-
h2 {
|
22
|
-
margin-top: 32px;
|
23
|
-
margin-bottom: 12px;
|
24
|
-
}
|
25
|
-
|
26
|
-
.this_page_style {
|
27
|
-
background-color: #e7f7cd;
|
28
|
-
color: darkgreen;
|
29
|
-
border: 0px;
|
30
|
-
}
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
</style>
|
35
|
-
|
36
|
-
</head>
|
37
|
-
|
38
|
-
<body>
|
39
|
-
|
40
|
-
<h1><%= chart_of_accounts.entity %></h1>
|
41
|
-
<p class="muted">Reports Generated at <%= DateTime.now.strftime('%Y-%m-%d %H:%M:%S') %> by RockBooks version <%=RockBooks::VERSION %></p>
|
42
|
-
|
43
|
-
|
44
|
-
<h2>Financial Statements</h2>
|
45
|
-
<div id="financial-statements">
|
46
|
-
<a href='balance_sheet.html' class="btn btn-success">Balance Sheet</a>
|
47
|
-
<a href='income_statement.html' class="btn btn-success">Income Statement</a>
|
48
|
-
</div>
|
49
|
-
|
50
|
-
|
51
|
-
<h2>Supporting Documents</h2>
|
52
|
-
<div id="supporting-documents" style="display: inline ">
|
53
|
-
<%
|
54
|
-
subdir_link = ->(name, caption) do
|
55
|
-
dir_name = File.expand_path(File.join(Dir.pwd, name))
|
56
|
-
if Dir.exist?(dir_name)
|
57
|
-
%Q{<a href=#{dir_name} class="btn btn-success">#{caption}</a>}
|
58
|
-
end
|
59
|
-
end
|
60
|
-
%>
|
61
|
-
<%= subdir_link.('invoices', 'Invoices') %>
|
62
|
-
<%= subdir_link.('receipts', 'Receipts') %>
|
63
|
-
<%= subdir_link.('statements', 'Statements') %>
|
64
|
-
<%= subdir_link.('worksheets', 'Worksheets') %>
|
65
|
-
</div>
|
66
|
-
|
67
|
-
|
68
|
-
<h2>All Transactions Reports</h2>
|
69
|
-
<div id="all-transactions">
|
70
|
-
<a href="all_txns_by_acct.html" class="btn btn-success">By Account</a>
|
71
|
-
<a href="all_txns_by_amount.html" class="btn btn-success">By Amount</a>
|
72
|
-
<a href="all_txns_by_date.html" class="btn btn-success">By Date</a>
|
73
|
-
</div>
|
74
|
-
|
75
|
-
<% collapsible_heading = ->(caption, href) do
|
76
|
-
%Q{<br /><br />
|
77
|
-
<div class="collapsible-heading">
|
78
|
-
<div class="container-fluid">
|
79
|
-
<div class="row">
|
80
|
-
|
81
|
-
<div class="col-sm2" style="margin-right: 12px;">
|
82
|
-
<a class="btn btn-success" data-toggle="collapse" href="#{href}" role="button" aria-expanded="false" aria-controls="collapseExample">
|
83
|
-
+/-
|
84
|
-
</a>
|
85
|
-
</div>
|
86
|
-
|
87
|
-
<div class="col-sm10">
|
88
|
-
<h2 style="margin: 0px;">#{caption}</h2>
|
89
|
-
</div>
|
90
|
-
</div>
|
91
|
-
</div>
|
92
|
-
</div>
|
93
|
-
}
|
94
|
-
end
|
95
|
-
%>
|
96
|
-
|
97
|
-
<%= collapsible_heading.('Journal Reports', '#journal-reports') %>
|
98
|
-
|
99
|
-
</div>
|
100
|
-
<div class="collapse" id="journal-reports">
|
101
|
-
<div class="card card-body this_page_style">
|
102
|
-
<ul>
|
103
|
-
<% journals.each do |journal|
|
104
|
-
filespec = journal.short_name + '.html'
|
105
|
-
caption = "#{journal.title} -- #{journal.short_name} -- #{journal.account_code}"%>
|
106
|
-
<li><a href="<%= filespec %>" class="this_page_style" target="_blank"><%= caption %></a></li>
|
107
|
-
<% end %>
|
108
|
-
</ul>
|
109
|
-
</div>
|
110
|
-
</div>
|
111
|
-
|
112
|
-
|
113
|
-
<%= collapsible_heading.('Individual Accounts', '#individual-accounts') %>
|
114
|
-
|
115
|
-
<div class="collapse" id="individual-accounts">
|
116
|
-
<div class="card card-body this_page_style">
|
117
|
-
<ul>
|
118
|
-
|
119
|
-
<%
|
120
|
-
chart_of_accounts.accounts.each do |account|
|
121
|
-
filespec = File.join('single-account', "acct_#{account.code}.html")
|
122
|
-
caption = "#{account.name} (#{account.code})"
|
123
|
-
%>
|
124
|
-
<li><a href="<%= filespec %>" class="this_page_style"><%= caption %></a></li>
|
125
|
-
<% end %>
|
126
|
-
</ul>
|
127
|
-
</div>
|
128
|
-
</div>
|
129
|
-
</div>
|
130
|
-
|
131
|
-
|
132
|
-
<%= collapsible_heading.('Other', '#other') %>
|
133
|
-
|
134
|
-
<div class="collapse" id="other">
|
135
|
-
<div class="card card-body this_page_style">
|
136
|
-
<ul>
|
137
|
-
<% if run_options.do_receipts %>
|
138
|
-
<li><a href="receipts.html" class="this_page_style">Missing and Existing Receipts</a></li>
|
139
|
-
<% end %>
|
140
|
-
</ul>
|
141
|
-
</div>
|
142
|
-
</div>
|
143
|
-
|
144
|
-
<%= collapsible_heading.('Reports in PDF and Text Formats', '#other-formats') %>
|
145
|
-
|
146
|
-
<div class="collapse" id="other-formats">
|
147
|
-
<div class="card card-body this_page_style">
|
148
|
-
<ul>
|
149
|
-
<li><a href="../pdf" class="this_page_style" target="_blank">PDF Format</a></li>
|
150
|
-
<li><a href="../txt" class="this_page_style" target="_blank">Text Format</a></li>
|
151
|
-
</ul>
|
152
|
-
</div>
|
153
|
-
</div>
|
154
|
-
|
155
|
-
</body>
|
156
|
-
</html>
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require_relative '../documents/journal'
|
2
|
-
require_relative 'reporter'
|
3
|
-
require_relative 'report_context'
|
4
|
-
|
5
|
-
module RockBooks
|
6
|
-
|
7
|
-
class MultidocTransactionReport
|
8
|
-
|
9
|
-
include Reporter
|
10
|
-
|
11
|
-
attr_accessor :context
|
12
|
-
|
13
|
-
SORT_BY_VALID_OPTIONS = %i(date_and_account amount)
|
14
|
-
|
15
|
-
def initialize(report_context)
|
16
|
-
@context = report_context
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def generate_header(sort_by)
|
21
|
-
lines = [banner_line]
|
22
|
-
lines << center(context.entity || 'Unspecified Entity')
|
23
|
-
lines << center('Multi Document Transaction Report')
|
24
|
-
lines << center('Sorted by Amount Descending') if sort_by == :amount
|
25
|
-
lines << ''
|
26
|
-
lines << center('Source Documents:')
|
27
|
-
lines << ''
|
28
|
-
context.journals.each do |document|
|
29
|
-
short_name = SHORT_NAME_FORMAT_STRING % document.short_name
|
30
|
-
lines << center("#{short_name} -- #{document.title}")
|
31
|
-
end
|
32
|
-
lines << banner_line
|
33
|
-
lines << ''
|
34
|
-
lines << ' Date Document Amount Account'
|
35
|
-
lines << ' ---- -------- ------ -------'
|
36
|
-
lines.join("\n") << "\n\n"
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
def generate_report(filter = nil, sort_by = :date_and_account)
|
41
|
-
unless SORT_BY_VALID_OPTIONS.include?(sort_by)
|
42
|
-
raise Error.new("sort_by option '#{sort_by}' not in valid choices of #{SORT_BY_VALID_OPTIONS}.")
|
43
|
-
end
|
44
|
-
|
45
|
-
entries = Journal.entries_in_documents(context.journals, filter)
|
46
|
-
|
47
|
-
if sort_by == :amount
|
48
|
-
JournalEntry.sort_entries_by_amount_descending!(entries)
|
49
|
-
end
|
50
|
-
|
51
|
-
sio = StringIO.new
|
52
|
-
sio << generate_header(sort_by)
|
53
|
-
entries.each { |entry| sio << format_multidoc_entry(entry) << "\n" }
|
54
|
-
|
55
|
-
totals = AcctAmount.aggregate_amounts_by_account(JournalEntry.entries_acct_amounts(entries))
|
56
|
-
sio << generate_and_format_totals('Totals', totals)
|
57
|
-
|
58
|
-
sio << "\n"
|
59
|
-
sio.string
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
alias_method :to_s, :generate_report
|
64
|
-
alias_method :call, :generate_report
|
65
|
-
end
|
66
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<body>
|
4
|
-
|
5
|
-
<h1><%= chart_of_accounts.entity %> -- Receipts</h1>
|
6
|
-
<p>Reports Generated at <%= DateTime.now.strftime('%Y-%m-%d_%H-%M-%S') %> by RockBooks version <%=RockBooks::VERSION %></p>
|
7
|
-
<br />
|
8
|
-
|
9
|
-
<% receipts.each %>
|
10
|
-
<h2>Financial Statements</h2>
|
11
|
-
<ul>
|
12
|
-
<li><a href='balance_sheet.html'>Balance Sheet</a></li>
|
13
|
-
<li><a href='income_statement.html'>Income Statement</a></li>
|
14
|
-
</ul>
|
15
|
-
|
16
|
-
<h2>All Transactions</h2>
|
17
|
-
<ul>
|
18
|
-
<li><a href="all_txns_by_acct.html">By Account</a></li>
|
19
|
-
<li><a href="all_txns_by_amount.html">By Amount</a></li>
|
20
|
-
<li><a href="all_txns_by_date.html">By Date</a></li>
|
21
|
-
</ul>
|
22
|
-
|
23
|
-
<h2>Journals</h2>
|
24
|
-
<ul>
|
25
|
-
<% journals.each do |journal|
|
26
|
-
filespec = journal.short_name + '.html'
|
27
|
-
caption = "#{journal.title} -- #{journal.short_name} -- #{journal.account_code}"
|
28
|
-
%>
|
29
|
-
<li><a href="<%= filespec %>"><%= caption %></a></li>
|
30
|
-
<% end %>
|
31
|
-
</ul>
|
32
|
-
|
33
|
-
<h2>Individual Accounts</h2>
|
34
|
-
<ul>
|
35
|
-
|
36
|
-
<%
|
37
|
-
chart_of_accounts.accounts.each do |account|
|
38
|
-
filespec = File.join('single-account', "acct_#{account.code}.html")
|
39
|
-
caption = "#{account.name} (#{account.code})"
|
40
|
-
%>
|
41
|
-
<li><a href="<%= filespec %>"><%= caption %></a></li>
|
42
|
-
<% end %>
|
43
|
-
</ul>
|
44
|
-
|
45
|
-
|
46
|
-
<h2>Receipts</h2>
|
47
|
-
<ul>
|
48
|
-
<% if run_options.do_receipts %>
|
49
|
-
<li><a href="receipts.html">Missing and Existing Receipts</a></li>
|
50
|
-
<% end %>
|
51
|
-
</ul>
|
52
|
-
|
53
|
-
</body>
|
54
|
-
</html>
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require_relative '../documents/journal_entry'
|
2
|
-
|
3
|
-
module RockBooks
|
4
|
-
module Reporter
|
5
|
-
|
6
|
-
module_function
|
7
|
-
|
8
|
-
SHORT_NAME_MAX_LENGTH = 16
|
9
|
-
|
10
|
-
SHORT_NAME_FORMAT_STRING = "%#{SHORT_NAME_MAX_LENGTH}.#{SHORT_NAME_MAX_LENGTH}s"
|
11
|
-
|
12
|
-
|
13
|
-
def page_width
|
14
|
-
context.page_width || 80
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
def format_account_code(code)
|
19
|
-
"%*.*s" % [max_account_code_length, max_account_code_length, code]
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
def account_code_name_type_string(account)
|
24
|
-
"#{account.code} -- #{account.name} (#{account.type.to_s.capitalize})"
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
def format_amount(amount)
|
29
|
-
"%9.2f" % amount
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
# e.g. " 117.70 tr.mileage Travel - Mileage Allowance"
|
34
|
-
def format_acct_amount(acct_amount)
|
35
|
-
"%s %s %s" % [
|
36
|
-
format_amount(acct_amount.amount),
|
37
|
-
format_account_code(acct_amount.code),
|
38
|
-
context.chart_of_accounts.name_for_code(acct_amount.code)
|
39
|
-
]
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
def banner_line
|
44
|
-
@banner_line ||= '-' * page_width
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
def center(string)
|
49
|
-
indent = (page_width - string.length) / 2
|
50
|
-
indent = 0 if indent < 0
|
51
|
-
(' ' * indent) + string
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
def max_account_code_length
|
56
|
-
@max_account_code_length ||= context.chart_of_accounts.max_account_code_length
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
def generate_and_format_totals(section_caption, totals)
|
61
|
-
output = section_caption
|
62
|
-
output << "\n#{'-' * section_caption.length}\n\n"
|
63
|
-
format_string = "%12.2f %-#{context.chart_of_accounts.max_account_code_length}s %s\n"
|
64
|
-
totals.keys.sort.each do |account_code|
|
65
|
-
account_name = context.chart_of_accounts.name_for_code(account_code)
|
66
|
-
account_total = totals[account_code]
|
67
|
-
output << format_string % [account_total, account_code, account_name]
|
68
|
-
end
|
69
|
-
|
70
|
-
output << "------------\n"
|
71
|
-
output << "%12.2f\n" % totals.values.sum.round(2)
|
72
|
-
output
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
def generate_account_type_section(section_caption, totals, section_type, need_to_reverse_sign)
|
77
|
-
account_codes_this_section = context.chart_of_accounts.account_codes_of_type(section_type)
|
78
|
-
|
79
|
-
totals_this_section = totals.select do |account_code, _amount|
|
80
|
-
account_codes_this_section.include?(account_code)
|
81
|
-
end
|
82
|
-
|
83
|
-
if need_to_reverse_sign
|
84
|
-
totals_this_section.each { |code, amount| totals_this_section[code] = -amount }
|
85
|
-
end
|
86
|
-
|
87
|
-
section_total_amount = totals_this_section.map { |aa| aa.last }.sum
|
88
|
-
|
89
|
-
output = generate_and_format_totals(section_caption, totals_this_section)
|
90
|
-
[ output, section_total_amount ]
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
def format_multidoc_entry(entry)
|
95
|
-
acct_amounts = entry.acct_amounts
|
96
|
-
|
97
|
-
# "2017-10-29 hsbc_visa":
|
98
|
-
output = entry.date.to_s << ' ' << (SHORT_NAME_FORMAT_STRING % entry.doc_short_name) << ' '
|
99
|
-
|
100
|
-
indent = ' ' * output.length
|
101
|
-
|
102
|
-
output << format_acct_amount(acct_amounts.first) << "\n"
|
103
|
-
|
104
|
-
acct_amounts[1..-1].each do |acct_amount|
|
105
|
-
output << indent << format_acct_amount(acct_amount) << "\n"
|
106
|
-
end
|
107
|
-
|
108
|
-
if entry.description && entry.description.length > 0
|
109
|
-
output << entry.description
|
110
|
-
end
|
111
|
-
|
112
|
-
output
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
|