rock_books 0.6.1 → 0.10.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 +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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 974a379630080a4b8ec174d0b79fe46ce629f0c0fab0c6e147e3b1e4cd472c3f
|
4
|
+
data.tar.gz: 289a1cccf88c3ab27fccac9bfd98c9b4e88f4d14d791d92ebcf52dfd6d7509ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57489817b4cae0dd70db00ee4fc10f8fc432ebb1a6ed01a93b6c1f646b681ae5eb456d171c5a7fe2d981bada1771da33eccba7ed08cebceee57925c5c1bb7560
|
7
|
+
data.tar.gz: 2f530db52499773bae28f24f6ee4cf0a243056b6e8df9a83723826b132b4cecc558451bcf357840946e437e6e22740aa4b7d417789df84ec3bbba6050917fe57
|
data/README.md
CHANGED
@@ -33,10 +33,8 @@ To simplify its implementation, RockBooks assumes some conventions:
|
|
33
33
|
|
34
34
|
#### Supported Operating Systems
|
35
35
|
|
36
|
-
At this time, RockBooks is
|
36
|
+
At this time, RockBooks is tested only on Mac OS and Linux. However, it will probably work fine on Windows.
|
37
37
|
|
38
|
-
If you get an error message saying that an external command is missing, install that command using your system's package manager (e.g. `sudo apt install txt2html`). For `wkhtmltopdf` on Linux, see [https://wkhtmltopdf.org/](https://wkhtmltopdf.org/).
|
39
|
-
|
40
38
|
#### Text Files as Input
|
41
39
|
|
42
40
|
Instead of a web interface, data input is done in plain text files. This isn't as fancy but has the following advantages:
|
@@ -49,17 +47,17 @@ Instead of a web interface, data input is done in plain text files. This isn't a
|
|
49
47
|
|
50
48
|
* Users can use their favorite text editors.
|
51
49
|
|
52
|
-
* All data entry can be done without moving the hands away from the keyboard.
|
50
|
+
* All data entry can be done without moving the hands away from the keyboard (assuming the editor software supports it, as does `vim`).
|
53
51
|
|
54
52
|
|
55
53
|
#### The Accounting Period
|
56
54
|
|
57
|
-
There is no handling of end of year closings or the like; the entire set of data in the input files is considered included in the reporting period when generating the reports. Therefore, the best approach is to create a new data set for each year. The chart of accounts and journal files can be copied and modified as necessary.
|
55
|
+
There is no handling of end of year closings or the like; the entire set of data in the input files is considered included in the reporting period when generating the reports. Therefore, the best approach is to create a new data set for each year. The chart of accounts and journal files can be copied from the previous year and modified as necessary.
|
58
56
|
|
59
57
|
#### RockBooks Help Text
|
60
58
|
|
61
59
|
```
|
62
|
-
Command Line Switches: [rock-books version 0.
|
60
|
+
Command Line Switches: [rock-books version 0.10.0 at https://github.com/keithrbennett/rock_books]
|
63
61
|
|
64
62
|
-i input directory specification, default: './rockbooks-inputs'
|
65
63
|
-o output (reports) directory specification, default: './rockbooks-reports'
|
@@ -68,14 +66,13 @@ Command Line Switches: [rock-books version 0.2.1 at https://g
|
|
68
66
|
|
69
67
|
Commands:
|
70
68
|
|
71
|
-
rec[eipts] - receipts: a/:a all, m/:m missing, e/:e existing
|
69
|
+
rec[eipts] - receipts: a/:a all, m/:m missing, e/:e existing, u/:u unused
|
72
70
|
rep[orts] - return an OpenStruct containing all reports (interactive shell mode only)
|
73
|
-
d[isplay_reports] - display all reports on stdout
|
74
71
|
w[rite_reports] - write all reports to the output directory (see -o option)
|
75
72
|
c[hart_of_accounts] - chart of accounts
|
76
73
|
h[elp] - prints this help
|
77
74
|
jo[urnals] - list of the journals' short names
|
78
|
-
proj[ect_page] -
|
75
|
+
proj[ect_page] - prints the RockBooks Github project page URL
|
79
76
|
rel[oad_data] - reload data from input files
|
80
77
|
q[uit] - exits this program (interactive shell mode only) (see also 'x')
|
81
78
|
x[it] - exits this program (interactive shell mode only) (see also 'q')
|
@@ -90,7 +87,8 @@ When in interactive shell mode:
|
|
90
87
|
|
91
88
|
## What RockBooks Is Not
|
92
89
|
|
93
|
-
As a product written by a single developer in his spare time,
|
90
|
+
As a product written by a single developer in his spare time,
|
91
|
+
RockBooks lacks many conveniences of traditional accounting software programs, such as:
|
94
92
|
|
95
93
|
* Import of data from financial institutions
|
96
94
|
* On the fly data validation
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,3 +1,50 @@
|
|
1
|
+
### v0.10.0
|
2
|
+
|
3
|
+
* Add invoice hyperlinks to generated HTML.
|
4
|
+
* Improve documentation.
|
5
|
+
* Add progress bar to report generation.
|
6
|
+
* Change 'proj[ect]' command to print the project home page URL, rather than call `open` on it. This makes the command useful in more cases and removes environment dependency.
|
7
|
+
* Remove interactive 'display reports' option. It's not that useful and easy enough to write all reports to disk and selectively view them.
|
8
|
+
* Fix rep[orts] interactive option.
|
9
|
+
* Fix and refactor handling of receipt data on command line.
|
10
|
+
* Add styling to report HTML pages, mostly for centering the reports, increasing the font size, and providing a faint blue background.
|
11
|
+
|
12
|
+
|
13
|
+
### v0.9.0
|
14
|
+
|
15
|
+
* Center generated index.html's content.
|
16
|
+
* Improve report headings.
|
17
|
+
* Fix index.html hyperlinks to resource (receipts, invoices, statements, worksheets) directories.
|
18
|
+
* Fix cases where split journal entries were not included in the journal report.
|
19
|
+
|
20
|
+
|
21
|
+
### v0.8.0
|
22
|
+
|
23
|
+
* Add metadata to PDF and HTML reports
|
24
|
+
* Add report generation timestamp and accounting period to all reports.
|
25
|
+
* Refactoring and cleanup.
|
26
|
+
|
27
|
+
|
28
|
+
### v0.7.1
|
29
|
+
|
30
|
+
* Refactor report helpers.
|
31
|
+
* Improve/reduce text output during reporting.
|
32
|
+
* Add title to HTML reports.
|
33
|
+
* Minor fixes.
|
34
|
+
|
35
|
+
|
36
|
+
### v0.7.0
|
37
|
+
|
38
|
+
* Dependencies on external commands in Linux and Mac OS for generating PDF and HTML files has been eliminated,
|
39
|
+
using the prawn gem for PDF and simple ERB templating for HTML.
|
40
|
+
* Massive refactoring of reports to separate data generation from presentation.
|
41
|
+
* Reports are now computed and then written one at a time. Previously they were all computed, then all written.
|
42
|
+
* ERB is now used for generating text reports.
|
43
|
+
* Fix receipt hyperlinks in HTML output.
|
44
|
+
* Improve some error output.
|
45
|
+
* Various minor improvements and bug fixes.
|
46
|
+
|
47
|
+
|
1
48
|
### v0.6.1
|
2
49
|
|
3
50
|
* Linux PDF generation fixed by using wkhtmltopdf instead of cupsfilter.
|
@@ -11,7 +58,7 @@
|
|
11
58
|
* Add receipt hyperlinks to HTML output.
|
12
59
|
|
13
60
|
|
14
|
-
|
61
|
+
### v0.4.0
|
15
62
|
|
16
63
|
* Sort unused receipts alphanumerically.
|
17
64
|
* Add 'x' receipts option for reporting both missing and unused receipts.
|
@@ -19,7 +66,7 @@
|
|
19
66
|
* Improve Receipts report.
|
20
67
|
|
21
68
|
|
22
|
-
|
69
|
+
### v0.3.0
|
23
70
|
|
24
71
|
* Added ability to report unused receipts.
|
25
72
|
* Errors now include more context information.
|
@@ -27,12 +74,12 @@
|
|
27
74
|
* Change license from MIT to Apache 2.
|
28
75
|
|
29
76
|
|
30
|
-
|
77
|
+
### v0.2.1
|
31
78
|
|
32
79
|
* Add help text to readme.
|
33
80
|
|
34
81
|
|
35
|
-
|
82
|
+
### v0.2.0
|
36
83
|
|
37
84
|
* Add instruction manual, modify readme.
|
38
85
|
* Overhaul generated index.html.
|
@@ -40,18 +87,18 @@
|
|
40
87
|
* Add validation of transaction dates to ensure within configured date range.
|
41
88
|
* Make report hash / OpenStruct keys consistently symbols.
|
42
89
|
|
43
|
-
|
90
|
+
### v0.1.6
|
44
91
|
|
45
92
|
* Fixed PDF output; PDF files were corrupt because cupsfilter starting sending
|
46
93
|
output to stderr at some point.
|
47
94
|
|
48
95
|
|
49
|
-
|
96
|
+
### v0.1.4, v0.1.5
|
50
97
|
|
51
98
|
* Intermediate unsatisfactory fixes, these versions were published but yanked.
|
52
99
|
|
53
100
|
|
54
|
-
|
101
|
+
### v0.1.3
|
55
102
|
|
56
103
|
* Report output now goes to separate txt, html, and pdf subdirectories.
|
57
104
|
* Add vendor.yml to exclude generated report files from language reporting.
|
@@ -66,17 +113,17 @@ output to stderr at some point.
|
|
66
113
|
* Add 'from_string' methods to Journal and ChartOfAccounts.
|
67
114
|
|
68
115
|
|
69
|
-
|
116
|
+
### v0.1.2
|
70
117
|
|
71
118
|
* Improve error message when the needed directories do not exist.
|
72
119
|
|
73
120
|
|
74
|
-
|
121
|
+
### v0.1.1
|
75
122
|
|
76
123
|
* Fix startup error.
|
77
124
|
|
78
125
|
|
79
|
-
|
126
|
+
### v0.1.0
|
80
127
|
|
81
128
|
* First release.
|
82
129
|
|
Binary file
|
@@ -4,7 +4,8 @@ require 'ostruct'
|
|
4
4
|
|
5
5
|
require_relative '../../rock_books'
|
6
6
|
require_relative '../version'
|
7
|
-
require_relative '../reports/
|
7
|
+
require_relative '../reports/data/receipts_report_data'
|
8
|
+
require_relative '../reports/helpers/text_report_helper'
|
8
9
|
require_relative '../helpers/book_set_loader'
|
9
10
|
|
10
11
|
module RockBooks
|
@@ -51,12 +52,11 @@ Commands:
|
|
51
52
|
|
52
53
|
rec[eipts] - receipts: a/:a all, m/:m missing, e/:e existing, u/:u unused
|
53
54
|
rep[orts] - return an OpenStruct containing all reports (interactive shell mode only)
|
54
|
-
d[isplay_reports] - display all reports on stdout
|
55
55
|
w[rite_reports] - write all reports to the output directory (see -o option)
|
56
56
|
c[hart_of_accounts] - chart of accounts
|
57
57
|
h[elp] - prints this help
|
58
58
|
jo[urnals] - list of the journals' short names
|
59
|
-
proj[ect_page] -
|
59
|
+
proj[ect_page] - prints the RockBooks Github project page URL
|
60
60
|
rel[oad_data] - reload data from input files
|
61
61
|
q[uit] - exits this program (interactive shell mode only) (see also 'x')
|
62
62
|
x[it] - exits this program (interactive shell mode only) (see also 'q')
|
@@ -105,7 +105,7 @@ When in interactive shell mode:
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
|
108
|
+
validate_receipt_dir = -> do
|
109
109
|
File.directory?(options.receipt_dir) ? nil : \
|
110
110
|
"Receipts directory '#{options.receipt_dir}' does not exist. "
|
111
111
|
end
|
@@ -114,7 +114,7 @@ When in interactive shell mode:
|
|
114
114
|
output << validate_input_dir.()
|
115
115
|
output << validate_output_dir.()
|
116
116
|
if run_options.do_receipts
|
117
|
-
output <<
|
117
|
+
output << validate_receipt_dir.()
|
118
118
|
end
|
119
119
|
|
120
120
|
output.compact!
|
@@ -281,7 +281,7 @@ When in interactive shell mode:
|
|
281
281
|
# All reports as Ruby objects; only makes sense in shell mode.
|
282
282
|
def cmd_rep
|
283
283
|
unless run_options.interactive_mode
|
284
|
-
raise Error.new("Option 'all_reports' is only available in shell mode. Try '
|
284
|
+
raise Error.new("Option 'all_reports' is only available in shell mode. Try 'write_reports'.")
|
285
285
|
end
|
286
286
|
|
287
287
|
os = OpenStruct.new(book_set.all_reports($filter))
|
@@ -297,18 +297,8 @@ When in interactive shell mode:
|
|
297
297
|
end
|
298
298
|
|
299
299
|
|
300
|
-
def cmd_d
|
301
|
-
book_set.all_reports($filter).each do |short_name, report_text|
|
302
|
-
puts "#{short_name}:\n\n"
|
303
|
-
puts report_text
|
304
|
-
puts "\n\n\n"
|
305
|
-
end
|
306
|
-
nil
|
307
|
-
end
|
308
|
-
|
309
|
-
|
310
300
|
def cmd_proj
|
311
|
-
|
301
|
+
puts 'https://github.com/keithrbennett/rock_books'
|
312
302
|
end
|
313
303
|
|
314
304
|
|
@@ -317,7 +307,9 @@ When in interactive shell mode:
|
|
317
307
|
raise Error.new("Receipt processing was requested but has been disabled with --no-receipts.")
|
318
308
|
end
|
319
309
|
|
320
|
-
|
310
|
+
data = ReceiptsReportData.new(all_entries, run_options.receipt_dir).fetch
|
311
|
+
|
312
|
+
missing, existing, unused = data[:missing], data[:existing], data[:unused]
|
321
313
|
|
322
314
|
print_missing = -> { puts "\n\nMissing Receipts:"; ap missing }
|
323
315
|
print_existing = -> { puts "\n\nExisting Receipts:"; ap existing }
|
@@ -326,11 +318,11 @@ When in interactive shell mode:
|
|
326
318
|
case options.first.to_s
|
327
319
|
when 'a' # all
|
328
320
|
if run_options.interactive_mode
|
329
|
-
|
321
|
+
data
|
330
322
|
else
|
331
|
-
|
332
|
-
|
333
|
-
|
323
|
+
print_missing.()
|
324
|
+
print_existing.()
|
325
|
+
print_unused.()
|
334
326
|
end
|
335
327
|
|
336
328
|
when 'm'
|
@@ -358,7 +350,7 @@ When in interactive shell mode:
|
|
358
350
|
end
|
359
351
|
|
360
352
|
def cmd_w
|
361
|
-
BookSetReporter.new(book_set, run_options.output_dir, $filter).
|
353
|
+
BookSetReporter.new(book_set, run_options.output_dir, $filter).generate
|
362
354
|
nil
|
363
355
|
end
|
364
356
|
|
@@ -372,7 +364,6 @@ When in interactive shell mode:
|
|
372
364
|
@commands_ ||= [
|
373
365
|
Command.new('rec', 'receipts', -> (*options) { cmd_rec(options) }),
|
374
366
|
Command.new('rep', 'reports', -> (*_options) { cmd_rep }),
|
375
|
-
Command.new('d', 'display_reports', -> (*_options) { cmd_d }),
|
376
367
|
Command.new('w', 'write_reports', -> (*_options) { cmd_w }),
|
377
368
|
Command.new('c', 'chart_of_accounts', -> (*_options) { cmd_c }),
|
378
369
|
Command.new('jo', 'journals', -> (*_options) { cmd_j }),
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'amazing_print'
|
2
2
|
require 'optparse'
|
3
3
|
require 'pry'
|
4
4
|
require 'shellwords'
|
@@ -67,10 +67,6 @@ class Main
|
|
67
67
|
options.verbose_mode = v
|
68
68
|
end
|
69
69
|
|
70
|
-
parser.on('-y', '--[no-]say', 'Say error messages.') do |v|
|
71
|
-
options.say = v
|
72
|
-
end
|
73
|
-
|
74
70
|
parser.on('', '--[no-]receipts', 'Include report on existing and missing receipts.') do |v|
|
75
71
|
options.do_receipts = v
|
76
72
|
end
|
@@ -101,10 +97,6 @@ class Main
|
|
101
97
|
|
102
98
|
HEREDOC
|
103
99
|
|
104
|
-
if run_options.say
|
105
|
-
`say #{error}`
|
106
|
-
end
|
107
|
-
|
108
100
|
exit(-1)
|
109
101
|
binding.pry
|
110
102
|
raise error
|
@@ -1,10 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'amazing_print'
|
2
2
|
require 'os'
|
3
3
|
|
4
4
|
require_relative 'chart_of_accounts'
|
5
5
|
require_relative 'journal'
|
6
6
|
require_relative '../filters/journal_entry_filters' # for shell mode
|
7
|
-
require_relative '../helpers/html_helper'
|
8
7
|
require_relative '../helpers/parse_helper'
|
9
8
|
require_relative '../reports/book_set_reporter'
|
10
9
|
|
@@ -39,6 +38,10 @@ module RockBooks
|
|
39
38
|
@all_entries ||= Journal.entries_in_documents(journals)
|
40
39
|
end
|
41
40
|
|
41
|
+
|
42
|
+
def all_reports(filter = nil)
|
43
|
+
BookSetReporter.new(self, nil, filter).get_all_report_data
|
44
|
+
end
|
42
45
|
end
|
43
46
|
end
|
44
47
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'stringio'
|
1
2
|
require_relative '../types/account'
|
2
3
|
require_relative '../types/account_type'
|
3
4
|
require_relative '../errors/error'
|
@@ -10,8 +11,8 @@ class ChartOfAccounts
|
|
10
11
|
REQUIRED_FIELDS.each { |field| attr_reader(field) }
|
11
12
|
|
12
13
|
|
13
|
-
def self.from_file(
|
14
|
-
self.new(File.readlines(
|
14
|
+
def self.from_file(filespec)
|
15
|
+
self.new(File.readlines(filespec).map(&:chomp), filespec)
|
15
16
|
end
|
16
17
|
|
17
18
|
|
@@ -20,11 +21,16 @@ class ChartOfAccounts
|
|
20
21
|
end
|
21
22
|
|
22
23
|
|
23
|
-
def initialize(input_lines)
|
24
|
+
def initialize(input_lines, filespec = nil)
|
25
|
+
@filespec = filespec
|
24
26
|
@accounts = []
|
25
|
-
input_lines
|
27
|
+
parse_lines(input_lines)
|
26
28
|
# TODO: Add validation for required fields.
|
29
|
+
check_for_missing_fields
|
30
|
+
end
|
31
|
+
|
27
32
|
|
33
|
+
def check_for_missing_fields
|
28
34
|
missing_fields = REQUIRED_FIELDS.select do |field|
|
29
35
|
instance_variable_get("@#{field}").nil?
|
30
36
|
end
|
@@ -35,6 +41,19 @@ class ChartOfAccounts
|
|
35
41
|
end
|
36
42
|
|
37
43
|
|
44
|
+
def parse_lines(input_lines)
|
45
|
+
input_lines.each_with_index do |line, line_num|
|
46
|
+
begin
|
47
|
+
parse_line(line)
|
48
|
+
rescue => e
|
49
|
+
file_message_fragment = (@filespec ? " in file '#{@filespec}'" : '')
|
50
|
+
puts "Error parsing chart of accounts#{file_message_fragment}. Bad line is line ##{line_num}, text is:\n#{line}\n\n"
|
51
|
+
raise
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
38
57
|
def parse_date(date_string)
|
39
58
|
# TODO: Add better handling for this error.
|
40
59
|
# begin
|
@@ -69,16 +88,14 @@ class ChartOfAccounts
|
|
69
88
|
rest = matcher[2]
|
70
89
|
|
71
90
|
matcher = rest.match(/^(\S+)\s+(.*)$/)
|
91
|
+
|
72
92
|
account_type_token = matcher[1]
|
73
|
-
account_type = AccountType.
|
93
|
+
account_type = AccountType.letter_to_type(account_type_token)
|
74
94
|
|
75
95
|
name = matcher[2]
|
76
96
|
|
77
|
-
accounts << Account.new(code, account_type, name)
|
97
|
+
accounts << Account.new(code, account_type.symbol, name)
|
78
98
|
end
|
79
|
-
rescue => e
|
80
|
-
puts "Error parsing chart of accounts. Line text is:\n#{line}\n\n"
|
81
|
-
raise
|
82
99
|
end
|
83
100
|
|
84
101
|
end
|
@@ -105,7 +122,7 @@ class ChartOfAccounts
|
|
105
122
|
|
106
123
|
|
107
124
|
def report_string
|
108
|
-
result =
|
125
|
+
result = StringIO.new
|
109
126
|
|
110
127
|
if title
|
111
128
|
result << title << "\n\n"
|
@@ -113,9 +130,9 @@ class ChartOfAccounts
|
|
113
130
|
|
114
131
|
code_width = @accounts.inject(0) { |width, a| width = [width, a.code.length].max }
|
115
132
|
format_string = "%-#{code_width}s %-10.10s %s\n"
|
116
|
-
accounts.each { |a| result << (format_string
|
133
|
+
accounts.each { |a| result << sprintf(format_string, a.code, a.type.to_s, a.name) }
|
117
134
|
|
118
|
-
result
|
135
|
+
result.string
|
119
136
|
end
|
120
137
|
|
121
138
|
|