rock_books 0.2.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/LICENSE.txt +201 -21
  4. data/README.md +4 -2
  5. data/RELEASE_NOTES.md +41 -0
  6. data/assets/fonts/JetBrainsMono-Medium.ttf +0 -0
  7. data/lib/rock_books/cmd_line/command_line_interface.rb +24 -13
  8. data/lib/rock_books/cmd_line/main.rb +1 -9
  9. data/lib/rock_books/documents/book_set.rb +5 -131
  10. data/lib/rock_books/documents/chart_of_accounts.rb +69 -37
  11. data/lib/rock_books/documents/journal.rb +47 -46
  12. data/lib/rock_books/documents/journal_entry.rb +7 -2
  13. data/lib/rock_books/documents/journal_entry_builder.rb +4 -0
  14. data/lib/rock_books/helpers/book_set_loader.rb +3 -3
  15. data/lib/rock_books/helpers/html_helper.rb +35 -0
  16. data/lib/rock_books/reports/balance_sheet.rb +8 -42
  17. data/lib/rock_books/reports/book_set_reporter.rb +218 -0
  18. data/lib/rock_books/reports/data/bs_is_data.rb +61 -0
  19. data/lib/rock_books/reports/data/bs_is_section_data.rb +28 -0
  20. data/lib/rock_books/reports/data/journal_data.rb +37 -0
  21. data/lib/rock_books/reports/data/multidoc_txn_by_account_data.rb +40 -0
  22. data/lib/rock_books/reports/data/multidoc_txn_report_data.rb +39 -0
  23. data/lib/rock_books/reports/data/receipts_report_data.rb +47 -0
  24. data/lib/rock_books/reports/data/tx_one_account_data.rb +37 -0
  25. data/lib/rock_books/reports/helpers/erb_helper.rb +26 -0
  26. data/lib/rock_books/reports/helpers/reporter.rb +134 -0
  27. data/lib/rock_books/reports/income_statement.rb +8 -46
  28. data/lib/rock_books/reports/journal_report.rb +72 -0
  29. data/lib/rock_books/reports/multidoc_txn_by_account_report.rb +32 -0
  30. data/lib/rock_books/reports/multidoc_txn_report.rb +25 -0
  31. data/lib/rock_books/reports/receipts_report.rb +5 -41
  32. data/lib/rock_books/reports/report_context.rb +1 -4
  33. data/lib/rock_books/reports/templates/html/index.html.erb +141 -0
  34. data/lib/rock_books/reports/templates/html/report_page.html.erb +12 -0
  35. data/lib/rock_books/reports/templates/text/_receipt_section.txt.erb +17 -0
  36. data/lib/rock_books/reports/templates/text/_totals.txt.erb +8 -0
  37. data/lib/rock_books/reports/templates/text/balance_sheet.txt.erb +21 -0
  38. data/lib/rock_books/reports/templates/text/income_statement.txt.erb +21 -0
  39. data/lib/rock_books/reports/templates/text/journal.txt.erb +20 -0
  40. data/lib/rock_books/reports/templates/text/multidoc_txn_by_account_report.txt.erb +28 -0
  41. data/lib/rock_books/reports/templates/text/multidoc_txn_report.txt.erb +22 -0
  42. data/lib/rock_books/reports/templates/text/receipts_report.txt.erb +13 -0
  43. data/lib/rock_books/reports/templates/text/tx_one_account.txt.erb +18 -0
  44. data/lib/rock_books/reports/tx_one_account.rb +9 -44
  45. data/lib/rock_books/types/account.rb +13 -1
  46. data/lib/rock_books/types/account_type.rb +18 -7
  47. data/lib/rock_books/version.rb +1 -1
  48. data/rock_books.gemspec +5 -3
  49. data/sample_data/minimal/rockbooks-reports/html/ck_hsbc_disb.html +40 -0
  50. data/sample_data/minimal/rockbooks-reports/html/index.html +271 -0
  51. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_accts_rec.html +27 -0
  52. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_bank_fees.html +27 -0
  53. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_books_refs.html +27 -0
  54. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_cc_hsbc_visa.html +74 -0
  55. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_cc_proc.html +27 -0
  56. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_ck_hsbc.html +45 -0
  57. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_conf_fees.html +36 -0
  58. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_cowork_fees.html +42 -0
  59. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_govt_fees.html +27 -0
  60. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_inet_fees.html +27 -0
  61. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_int_exp.html +27 -0
  62. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_loan_to_sh.html +47 -0
  63. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_meals_ent.html +27 -0
  64. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_misc_exp.html +27 -0
  65. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_mktng_exp.html +27 -0
  66. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_own_equity.html +35 -0
  67. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_prof_fees.html +27 -0
  68. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_repair_maint.html +27 -0
  69. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_ret_earn.html +27 -0
  70. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_ship_exp.html +27 -0
  71. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_sls_cons.html +35 -0
  72. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_sw_exp.html +27 -0
  73. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_airfare.html +35 -0
  74. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_autorent.html +27 -0
  75. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_gas_etc.html +27 -0
  76. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_govt.html +27 -0
  77. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_lodging.html +36 -0
  78. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_m_e.html +27 -0
  79. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_m_i.html +27 -0
  80. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_mileage.html +35 -0
  81. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_misc.html +27 -0
  82. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_parking.html +27 -0
  83. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_perdiem_mi.html +35 -0
  84. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_taxi.html +27 -0
  85. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_trainfare.html +27 -0
  86. data/sample_data/minimal/rockbooks-reports/html/single-account/acct_tr_unclass.html +27 -0
  87. data/sample_data/minimal/rockbooks-reports/pdf/all_txns_by_acct.pdf +0 -0
  88. data/sample_data/minimal/rockbooks-reports/pdf/all_txns_by_amount.pdf +0 -0
  89. data/sample_data/minimal/rockbooks-reports/pdf/all_txns_by_date.pdf +0 -0
  90. data/sample_data/minimal/rockbooks-reports/pdf/balance_sheet.pdf +0 -0
  91. data/sample_data/minimal/rockbooks-reports/pdf/ck_hsbc_disb.pdf +0 -0
  92. data/sample_data/minimal/rockbooks-reports/pdf/general.pdf +0 -0
  93. data/sample_data/minimal/rockbooks-reports/pdf/hsbc_visa.pdf +0 -0
  94. data/sample_data/minimal/rockbooks-reports/pdf/income_statement.pdf +0 -0
  95. data/sample_data/minimal/rockbooks-reports/pdf/receipts.pdf +0 -0
  96. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_accts_rec.pdf +0 -0
  97. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_bank_fees.pdf +0 -0
  98. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_books_refs.pdf +0 -0
  99. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_cc_hsbc_visa.pdf +0 -0
  100. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_cc_proc.pdf +0 -0
  101. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_ck_hsbc.pdf +0 -0
  102. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_conf_fees.pdf +0 -0
  103. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_cowork_fees.pdf +0 -0
  104. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_govt_fees.pdf +0 -0
  105. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_inet_fees.pdf +0 -0
  106. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_insurance.pdf +0 -0
  107. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_int_exp.pdf +0 -0
  108. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_loan_to_sh.pdf +0 -0
  109. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_meals_ent.pdf +0 -0
  110. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_misc_exp.pdf +0 -0
  111. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_mktng_exp.pdf +0 -0
  112. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_own_equity.pdf +0 -0
  113. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_paypal.pdf +0 -0
  114. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_prof_fees.pdf +0 -0
  115. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_repair_maint.pdf +0 -0
  116. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_ret_earn.pdf +0 -0
  117. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_ship_exp.pdf +0 -0
  118. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_sls_cons.pdf +0 -0
  119. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_supplies.pdf +0 -0
  120. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_sw_exp.pdf +0 -0
  121. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_airfare.pdf +0 -0
  122. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_autorent.pdf +0 -0
  123. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_gas_etc.pdf +0 -0
  124. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_govt.pdf +0 -0
  125. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_lodging.pdf +0 -0
  126. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_m_e.pdf +0 -0
  127. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_m_i.pdf +0 -0
  128. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_mileage.pdf +0 -0
  129. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_misc.pdf +0 -0
  130. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_parking.pdf +0 -0
  131. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_perdiem_mi.pdf +0 -0
  132. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_taxi.pdf +0 -0
  133. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_trainfare.pdf +0 -0
  134. data/sample_data/minimal/rockbooks-reports/pdf/single-account/acct_tr_unclass.pdf +0 -0
  135. data/sample_data/minimal/rockbooks-reports/txt/ck_hsbc_disb.txt +24 -0
  136. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_accts_rec.txt +11 -0
  137. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_bank_fees.txt +11 -0
  138. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_books_refs.txt +11 -0
  139. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_cc_hsbc_visa.txt +58 -0
  140. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_cc_proc.txt +11 -0
  141. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_ck_hsbc.txt +29 -0
  142. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_conf_fees.txt +20 -0
  143. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_cowork_fees.txt +26 -0
  144. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_govt_fees.txt +11 -0
  145. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_inet_fees.txt +11 -0
  146. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_int_exp.txt +11 -0
  147. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_loan_to_sh.txt +31 -0
  148. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_meals_ent.txt +11 -0
  149. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_misc_exp.txt +11 -0
  150. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_mktng_exp.txt +11 -0
  151. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_own_equity.txt +19 -0
  152. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_prof_fees.txt +11 -0
  153. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_repair_maint.txt +11 -0
  154. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_ret_earn.txt +11 -0
  155. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_ship_exp.txt +11 -0
  156. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_sls_cons.txt +19 -0
  157. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_sw_exp.txt +11 -0
  158. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_airfare.txt +19 -0
  159. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_autorent.txt +11 -0
  160. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_gas_etc.txt +11 -0
  161. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_govt.txt +11 -0
  162. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_lodging.txt +20 -0
  163. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_m_e.txt +11 -0
  164. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_m_i.txt +11 -0
  165. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_mileage.txt +19 -0
  166. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_misc.txt +11 -0
  167. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_parking.txt +11 -0
  168. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_perdiem_mi.txt +19 -0
  169. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_taxi.txt +11 -0
  170. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_trainfare.txt +11 -0
  171. data/sample_data/minimal/rockbooks-reports/txt/single-account/acct_tr_unclass.txt +11 -0
  172. metadata +176 -16
  173. data/lib/rock_books/documents/index.html.erb +0 -156
  174. data/lib/rock_books/documents/receipts.html.erb +0 -54
  175. data/lib/rock_books/reports/multidoc_transaction_report.rb +0 -66
  176. data/lib/rock_books/reports/reporter.rb +0 -118
  177. data/lib/rock_books/reports/transaction_report.rb +0 -103
  178. data/lib/rock_books/reports/tx_by_account.rb +0 -82
@@ -0,0 +1,8 @@
1
+ Totals
2
+ ------
3
+
4
+ <% totals.keys.sort.each do |acct_code| -%>
5
+ <%= sprintf(line_item_format_string, totals[acct_code], acct_code, fn_acct_name.(acct_code)) %>
6
+ <% end -%>
7
+ ------------
8
+ <%= fn_total_with_ok_or_discrepancy.(grand_total) %>
@@ -0,0 +1,21 @@
1
+ <%= banner_line %>
2
+ <%= fn_center.(entity || 'Unspecified Entity') %>
3
+ <%= fn_center.("Balance Sheet for Period Ending #{end_date}") %>
4
+ <%= banner_line %>
5
+
6
+ <% %i(asset liability equity).each do |section_type| -%>
7
+ <%= fn_section_heading.(section_type) %>
8
+
9
+ <% section_data = sections[section_type] -%>
10
+ <% section_data[:acct_totals].each do |code, amount| -%>
11
+ <%= line_item_format_string % [amount, code, fn_acct_name.(code)] %>
12
+ <% end -%>
13
+ ------------
14
+ <%= sprintf(line_item_format_string, section_data[:total], '', '') %>
15
+ <% end %>
16
+
17
+
18
+ Assets - (Liabilities + Equity)
19
+
20
+ <%= fn_total_with_ok_or_discrepancy.(grand_total) %>
21
+ ============
@@ -0,0 +1,21 @@
1
+ <%= banner_line %>
2
+ <%= fn_center.(entity || 'Unspecified Entity') %>
3
+ <%= fn_center.("Income Statement -- #{start_date} to #{end_date}") %>
4
+ <%= banner_line %>
5
+
6
+ <% %i(income expense).each do |section_type| -%>
7
+ <%= fn_section_heading.(section_type) %>
8
+
9
+ <% section_data = sections[section_type] -%>
10
+ <% section_data[:acct_totals].each do |code, amount| -%>
11
+ <%= line_item_format_string % [amount, code, fn_acct_name.(code)] %>
12
+ <% end -%>
13
+ ------------
14
+ <%= sprintf(line_item_format_string, section_data[:total], '', '') %>
15
+ <% end %>
16
+
17
+
18
+ Net Income
19
+
20
+ <%= sprintf(line_item_format_string, net_income, '', '') %>
21
+ ============
@@ -0,0 +1,20 @@
1
+ <%= banner_line %>
2
+ <%= fn_center.(entity || 'Unspecified Entity') %>
3
+ <%= fn_center.(title) %>
4
+ <% if code && name -%>
5
+ <%= fn_center.("Account: #{name} (#{code})") %>
6
+ <% end -%>
7
+ <% if short_name -%>
8
+ <%= fn_center.("Journal Short Name: #{short_name}") %>
9
+ <% end -%>
10
+ <%= fn_center.("#{start_date} to #{end_date}"
11
+ ) %>
12
+ <%= banner_line %>
13
+
14
+
15
+ <% entries.each do |entry| -%>
16
+ <%= fn_format_entry.(entry) %>
17
+ <% end %>
18
+
19
+ <%= fn_erb_render_binding.('text/_totals.txt.erb', binding) %>
20
+
@@ -0,0 +1,28 @@
1
+ <%= banner_line %>
2
+ <%= fn_center.(entity || 'Unspecified Entity') %>
3
+ <%= fn_center.('Multi Document Transaction Report by Account') %>
4
+
5
+ <%= fn_center.('Source Documents') %>
6
+
7
+ <% journals.each do |journal| -%>
8
+ <% short_name = sprintf(short_name_format_string, journal.short_name) -%>
9
+ <%= fn_center.("#{short_name} -- #{journal.title}") %>
10
+ <% end -%>
11
+ <%= banner_line %>
12
+
13
+ <% acct_sections.each do |acct| %>
14
+
15
+
16
+ <%= banner_line %>
17
+ <% total_string = "%.2f" % acct[:total] -%>
18
+ <%= fn_center.("Total: #{total_string} -- #{fn_account_code_name_type_string_for_code.(acct[:code])}") %>
19
+ <%= banner_line %>
20
+
21
+ <% acct[:entries].each do |entry| -%>
22
+ <%= fn_format_multidoc_entry.(entry) %>
23
+ <% end %>
24
+ <%= fn_account_total_line.(acct[:code], acct[:total]) %>
25
+ <% end %>
26
+
27
+
28
+ <%= fn_erb_render_binding.('text/_totals.txt.erb', binding) %>
@@ -0,0 +1,22 @@
1
+ <%= banner_line %>
2
+ <%= fn_center.(entity || 'Unspecified Entity') %>
3
+ <%= fn_center.('Multi Document Transaction Report') %>
4
+
5
+ <%= fn_center.('Source Documents') %>
6
+
7
+ <% journals.each do |journal| -%>
8
+ <% short_name = sprintf(short_name_format_string, journal.short_name) -%>
9
+ <%= fn_center.("#{short_name} -- #{journal.title}") %>
10
+ <% end -%>
11
+ <%= banner_line %>
12
+
13
+
14
+ Date Document Amount Account
15
+ ---- -------- ------ -------
16
+
17
+ <% entries.each do |entry| -%>
18
+ <%= fn_format_multidoc_entry.(entry) %>
19
+ <% end %>
20
+
21
+
22
+ <%= fn_erb_render_binding.('text/_totals.txt.erb', binding) %>
@@ -0,0 +1,13 @@
1
+ <% create_section = ->(name, list) do
2
+ fn_erb_render_hashes.('text/_receipt_section.txt.erb', { name: name, list: list }, {})
3
+ end -%>
4
+ <%= banner_line %>
5
+ <%= fn_center.(entity || 'Unspecified Entity') %>
6
+ <%= fn_center.('Receipts Report') %>
7
+ <%= banner_line %>
8
+
9
+ <% # Unlike existing and missing, which arrays of hashes with keys :receipt and :journal, unused is an array of receipt filespecs %>
10
+
11
+ <%= create_section.('Missing', missing) %>
12
+ <%= create_section.('Unused', unused.map { |receipt| { receipt: receipt, journal: nil } }) %>
13
+ <%= create_section.('Existing', existing) %>
@@ -0,0 +1,18 @@
1
+ <%= banner_line %>
2
+ <%= fn_center.(entity || 'Unspecified Entity') %>
3
+ <%= fn_center.("Transactions for Account #{account_string}") %>
4
+ <%= fn_center.(sprintf("Total: %.2f", total)) %>
5
+ <%= banner_line %>
6
+
7
+
8
+ <% if entries.empty? %>
9
+ There were no transactions for this account.
10
+
11
+
12
+ <% else -%>
13
+ <% entries.each do |entry| -%>
14
+ <%= fn_format_multidoc_entry.(entry) %>
15
+ <% end -%>
16
+
17
+ <%= fn_erb_render_binding.('text/_totals.txt.erb', binding) %>
18
+ <% end %>
@@ -1,6 +1,8 @@
1
+ require_relative 'data/tx_one_account_data'
1
2
  require_relative '../documents/chart_of_accounts'
2
3
  require_relative '../documents/journal'
3
- require_relative 'reporter'
4
+ require_relative 'helpers/erb_helper'
5
+ require_relative 'helpers/reporter'
4
6
  require_relative 'report_context'
5
7
 
6
8
  module RockBooks
@@ -8,56 +10,19 @@ module RockBooks
8
10
  class TxOneAccount
9
11
 
10
12
  include Reporter
13
+ include ErbHelper
11
14
 
12
- attr_reader :context, :account_code, :account
15
+ attr_reader :context, :account_code, :data
13
16
 
14
17
 
15
- def initialize(report_context, account_code)
18
+ def initialize(data, report_context)
19
+ @data = data
16
20
  @context = report_context
17
- @account_code = account_code
18
- @account = context.chart_of_accounts.account_for_code(account_code)
19
21
  end
20
22
 
21
23
 
22
- def generate_header(account_total)
23
- lines = [banner_line]
24
- lines << center(context.entity || 'Unspecified Entity')
25
- lines << center("Transactions for Account #{account_code_name_type_string(account)}")
26
- lines << center("Total: %.2f" % account_total)
27
- lines << banner_line
28
- lines << ''
29
- lines << ''
30
- lines << ''
31
- lines.join("\n")
24
+ def generate
25
+ ErbHelper.render_hashes('text/tx_one_account.txt.erb', data, template_presentation_context)
32
26
  end
33
-
34
-
35
- def process_account(entries)
36
- entries.each_with_object('') do |entry, output|
37
- output << format_multidoc_entry(entry) << "\n"
38
- output << "\n" if entry.description && entry.description.length > 0
39
- end
40
- end
41
-
42
-
43
- def generate_report
44
- entries = Journal.entries_in_documents(context.journals, JournalEntryFilters.account_code(account_code))
45
- account_total = JournalEntry.total_for_code(entries, account_code)
46
- output = generate_header(account_total)
47
-
48
- if entries.empty?
49
- output << "There were no transactions for this account.\n\n\n\n"
50
- else
51
- output << process_account(entries)
52
- totals = AcctAmount.aggregate_amounts_by_account(JournalEntry.entries_acct_amounts(entries))
53
- output << generate_and_format_totals('Totals', totals)
54
- end
55
-
56
- output
57
- end
58
-
59
- alias_method :to_s, :generate_report
60
- alias_method :call, :generate_report
61
27
  end
62
-
63
28
  end
@@ -2,6 +2,18 @@ module RockBooks
2
2
 
3
3
  # The ChartOfAccount holds the set of all these accounts for the entity.
4
4
  class Account < Struct.new(:code, :type, :name)
5
- end
6
5
 
6
+ PERMITTED_CODE_CHAR_REGEX = /[\w\-\.]$/ # word chars (letters, numbers, underscores), hyphens, periods
7
+
8
+ def validate_code(code)
9
+ unless PERMITTED_CODE_CHAR_REGEX.match(code)
10
+ raise "Code {#{code}} may only contain letters, numbers, underscores, hyphens, and periods."
11
+ end
12
+ end
13
+
14
+ def initialize(code, type, name)
15
+ validate_code(code)
16
+ super
17
+ end
18
+ end
7
19
  end
@@ -12,7 +12,7 @@ module RockBooks
12
12
 
13
13
  ALL_TYPES = [ASSET, LIABILITY, EQUITY, INCOME, EXPENSE]
14
14
 
15
- TYPE_HASH = {
15
+ LETTER_TO_TYPE = {
16
16
  'A' => ASSET,
17
17
  'L' => LIABILITY,
18
18
  'O' => EQUITY,
@@ -20,14 +20,25 @@ module RockBooks
20
20
  'E' => EXPENSE
21
21
  }
22
22
 
23
- # Converts strings
24
- def self.to_type(string)
25
- type = TYPE_HASH[string[0].upcase]
26
- if type.nil?
23
+ SYMBOL_TO_TYPE = {
24
+ :asset => ASSET,
25
+ :liability => LIABILITY,
26
+ :equity => EQUITY,
27
+ :income => INCOME,
28
+ :expense => EXPENSE
29
+ }
30
+
31
+ # Converts type upper case letter representation to a type object (e.g. 'A' => ASSET)
32
+ def self.letter_to_type(string)
33
+ key = string[0].upcase
34
+ LETTER_TO_TYPE.fetch(key) do
27
35
  raise Error.new("Account type of #{string} not valid. " +
28
- "Must be one of #{TYPE_HASH.keys} (#{ALL_TYPES.map(&:singular_name)})")
36
+ "Must be one of #{LETTER_TO_TYPE.keys} (#{ALL_TYPES.map(&:singular_name)})")
29
37
  end
30
- type
38
+ end
39
+
40
+ def self.symbol_to_type(symbol)
41
+ SYMBOL_TO_TYPE[symbol]
31
42
  end
32
43
  end
33
44
  end
@@ -1,3 +1,3 @@
1
1
  module RockBooks
2
- VERSION = "0.2.1"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -30,10 +30,12 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_dependency 'awesome_print', '> 0'
33
+ spec.add_dependency 'amazing_print', '> 0'
34
+ spec.add_dependency 'os', '> 1.0.0'
34
35
  spec.add_dependency 'pry', '> 0.0.0'
36
+ spec.add_dependency 'prawn', '>= 2.1'
35
37
 
36
- spec.add_development_dependency "bundler", "~> 1.16"
37
- spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "bundler", "~> 2.0"
39
+ spec.add_development_dependency "rake", ">= 12.3.3"
38
40
  spec.add_development_dependency "rspec", "~> 3.0"
39
41
  end
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <meta http-equiv="Content-Style-Type" content="text/css">
6
+ <title></title>
7
+ <meta name="Generator" content="Cocoa HTML Writer">
8
+ <meta name="CocoaVersion" content="1671.2">
9
+ <style type="text/css">
10
+ p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px 'Courier New'}
11
+ p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px 'Courier New'; min-height: 16.0px}
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <p class="p1"><b>--------------------------------------------------------------------------------</b></p>
16
+ <p class="p1"><b><span class="Apple-converted-space">                              </span>XYZ Consulting, Inc.</b></p>
17
+ <p class="p1"><b><span class="Apple-converted-space">                   </span>HSBC Checking Disbursements Journal - 2018</b></p>
18
+ <p class="p1"><b><span class="Apple-converted-space">               </span>Transactions for Account #ck.hsbc -- HSBC Checking</b></p>
19
+ <p class="p1"><b>--------------------------------------------------------------------------------</b></p>
20
+ <p class="p2"><b></b><br></p>
21
+ <p class="p2"><b></b><br></p>
22
+ <p class="p1"><b>2018-01-01<span class="Apple-converted-space">    </span>5000.00<span class="Apple-converted-space">        </span>ck.hsbc<span class="Apple-converted-space">  </span>HSBC Checking</b></p>
23
+ <p class="p1"><b>Initial Deposit from Shareholder</b></p>
24
+ <p class="p2"><b></b><br></p>
25
+ <p class="p1"><b>2018-01-05 <span class="Apple-converted-space">  </span>-2000.00<span class="Apple-converted-space">        </span>ck.hsbc<span class="Apple-converted-space">  </span>HSBC Checking</b></p>
26
+ <p class="p2"><b></b><br></p>
27
+ <p class="p1"><b>2018-01-07 <span class="Apple-converted-space">  </span>10000.00<span class="Apple-converted-space">        </span>ck.hsbc<span class="Apple-converted-space">  </span>HSBC Checking</b></p>
28
+ <p class="p1"><b>Invoice #437, Dec. 2017 work, ABC, Inc.</b></p>
29
+ <p class="p2"><b></b><br></p>
30
+ <p class="p1"><b>Totals</b></p>
31
+ <p class="p1"><b>------</b></p>
32
+ <p class="p2"><b></b><br></p>
33
+ <p class="p1"><b><span class="Apple-converted-space">     </span>2000.00 <span class="Apple-converted-space">  </span>cc.hsbc.visa<span class="Apple-converted-space">    </span>Visa Credit Card</b></p>
34
+ <p class="p1"><b><span class="Apple-converted-space">    </span>13000.00 <span class="Apple-converted-space">  </span>ck.hsbc <span class="Apple-converted-space">        </span>HSBC Checking</b></p>
35
+ <p class="p1"><b><span class="Apple-converted-space">    </span>-5000.00 <span class="Apple-converted-space">  </span>own.equity<span class="Apple-converted-space">      </span>Owner's Equity</b></p>
36
+ <p class="p1"><b><span class="Apple-converted-space">   </span>-10000.00 <span class="Apple-converted-space">  </span>sls.cons<span class="Apple-converted-space">        </span>Sales - Consulting</b></p>
37
+ <p class="p1"><b>------------</b></p>
38
+ <p class="p1"><b><span class="Apple-converted-space">        </span>0.00</b></p>
39
+ </body>
40
+ </html>
@@ -0,0 +1,271 @@
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>XYZ Consulting, Inc.</h1>
41
+ <p class="muted">Reports Generated at 2019-03-04 12:09:49 by RockBooks version 0.2.1</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
+
55
+ <a href=/Users/kbennett/work/rock_books/sample_data/minimal/receipts class="btn btn-success">Receipts</a>
56
+
57
+
58
+ </div>
59
+
60
+
61
+ <h2>All Transactions Reports</h2>
62
+ <div id="all-transactions">
63
+ <a href="all_txns_by_acct.html" class="btn btn-success">By Account</a>
64
+ <a href="all_txns_by_amount.html" class="btn btn-success">By Amount</a>
65
+ <a href="all_txns_by_date.html" class="btn btn-success">By Date</a>
66
+ </div>
67
+
68
+
69
+
70
+ <br /><br />
71
+ <div class="collapsible-heading">
72
+ <div class="container-fluid">
73
+ <div class="row">
74
+
75
+ <div class="col-sm2" style="margin-right: 12px;">
76
+ <a class="btn btn-success" data-toggle="collapse" href="#journal-reports" role="button" aria-expanded="false" aria-controls="collapseExample">
77
+ +/-
78
+ </a>
79
+ </div>
80
+
81
+ <div class="col-sm10">
82
+ <h2 style="margin: 0px;">Journal Reports</h2>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </div>
87
+
88
+
89
+ </div>
90
+ <div class="collapse" id="journal-reports">
91
+ <div class="card card-body this_page_style">
92
+ <ul>
93
+
94
+ <li><a href="ck.hsbc.disb.html" class="this_page_style" target="_blank">HSBC Checking Disbursements Journal - 2018 -- ck.hsbc.disb -- ck.hsbc</a></li>
95
+
96
+ <li><a href="hsbc_visa.html" class="this_page_style" target="_blank">HSBC Visa Journal - 2018 -- hsbc_visa -- cc.hsbc.visa</a></li>
97
+
98
+ <li><a href="general.html" class="this_page_style" target="_blank">General Journal - 2018 -- general -- </a></li>
99
+
100
+ </ul>
101
+ </div>
102
+ </div>
103
+
104
+
105
+ <br /><br />
106
+ <div class="collapsible-heading">
107
+ <div class="container-fluid">
108
+ <div class="row">
109
+
110
+ <div class="col-sm2" style="margin-right: 12px;">
111
+ <a class="btn btn-success" data-toggle="collapse" href="#individual-accounts" role="button" aria-expanded="false" aria-controls="collapseExample">
112
+ +/-
113
+ </a>
114
+ </div>
115
+
116
+ <div class="col-sm10">
117
+ <h2 style="margin: 0px;">Individual Accounts</h2>
118
+ </div>
119
+ </div>
120
+ </div>
121
+ </div>
122
+
123
+
124
+ <div class="collapse" id="individual-accounts">
125
+ <div class="card card-body this_page_style">
126
+ <ul>
127
+
128
+
129
+ <li><a href="single-account/acct_ck.hsbc.html" class="this_page_style">HSBC Checking (ck.hsbc)</a></li>
130
+
131
+ <li><a href="single-account/acct_paypal.html" class="this_page_style">Paypal (paypal)</a></li>
132
+
133
+ <li><a href="single-account/acct_accts.rec.html" class="this_page_style">Accounts Receivable (accts.rec)</a></li>
134
+
135
+ <li><a href="single-account/acct_cc.hsbc.visa.html" class="this_page_style">Visa Credit Card (cc.hsbc.visa)</a></li>
136
+
137
+ <li><a href="single-account/acct_loan.to.sh.html" class="this_page_style">Loan Payable to Shareholder (loan.to.sh)</a></li>
138
+
139
+ <li><a href="single-account/acct_own.equity.html" class="this_page_style">Owner's Equity (own.equity)</a></li>
140
+
141
+ <li><a href="single-account/acct_ret.earn.html" class="this_page_style">Retained Earnings (ret.earn)</a></li>
142
+
143
+ <li><a href="single-account/acct_sls.cons.html" class="this_page_style">Sales - Consulting (sls.cons)</a></li>
144
+
145
+ <li><a href="single-account/acct_bank.fees.html" class="this_page_style">Bank Charges (bank.fees)</a></li>
146
+
147
+ <li><a href="single-account/acct_books.refs.html" class="this_page_style">Books, Screencasts, References (books.refs)</a></li>
148
+
149
+ <li><a href="single-account/acct_conf.fees.html" class="this_page_style">Conference Fees (conf.fees)</a></li>
150
+
151
+ <li><a href="single-account/acct_cowork.fees.html" class="this_page_style">Coworking Fees (cowork.fees)</a></li>
152
+
153
+ <li><a href="single-account/acct_govt.fees.html" class="this_page_style">Government Fees (govt.fees)</a></li>
154
+
155
+ <li><a href="single-account/acct_inet.fees.html" class="this_page_style">Internet Service, Domain, and Hosting Fees (inet.fees)</a></li>
156
+
157
+ <li><a href="single-account/acct_insurance.html" class="this_page_style">Insurance (insurance)</a></li>
158
+
159
+ <li><a href="single-account/acct_int.exp.html" class="this_page_style">Interest Expense (int.exp)</a></li>
160
+
161
+ <li><a href="single-account/acct_mktng.exp.html" class="this_page_style">Marketing Expenses (mktng.exp)</a></li>
162
+
163
+ <li><a href="single-account/acct_meals.ent.html" class="this_page_style">Meals & Entertainment (meals.ent)</a></li>
164
+
165
+ <li><a href="single-account/acct_misc.exp.html" class="this_page_style">Miscellaneous Expenses (misc.exp)</a></li>
166
+
167
+ <li><a href="single-account/acct_prof.fees.html" class="this_page_style">Professional Fees (prof.fees)</a></li>
168
+
169
+ <li><a href="single-account/acct_repair.maint.html" class="this_page_style">Repair & Maintenance (repair.maint)</a></li>
170
+
171
+ <li><a href="single-account/acct_ship.exp.html" class="this_page_style">Shipping and Mailing Expenses (ship.exp)</a></li>
172
+
173
+ <li><a href="single-account/acct_sw.exp.html" class="this_page_style">Software Expense (sw.exp)</a></li>
174
+
175
+ <li><a href="single-account/acct_supplies.html" class="this_page_style">Supplies (supplies)</a></li>
176
+
177
+ <li><a href="single-account/acct_cc.proc.html" class="this_page_style">Credit Card Processing Fees (cc.proc)</a></li>
178
+
179
+ <li><a href="single-account/acct_tr.airfare.html" class="this_page_style">Travel - Air Fares (tr.airfare)</a></li>
180
+
181
+ <li><a href="single-account/acct_tr.autorent.html" class="this_page_style">Travel - Auto Rental (tr.autorent)</a></li>
182
+
183
+ <li><a href="single-account/acct_tr.gas.etc.html" class="this_page_style">Travel - Gas, Oil, Tolls, etc. (tr.gas.etc)</a></li>
184
+
185
+ <li><a href="single-account/acct_tr.govt.html" class="this_page_style">Travel - Government Fees (tr.govt)</a></li>
186
+
187
+ <li><a href="single-account/acct_tr.lodging.html" class="this_page_style">Travel - Lodging (tr.lodging)</a></li>
188
+
189
+ <li><a href="single-account/acct_tr.m.i.html" class="this_page_style">Travel - Meals & Incidentals (tr.m.i)</a></li>
190
+
191
+ <li><a href="single-account/acct_tr.mileage.html" class="this_page_style">Travel - Mileage Allowance (tr.mileage)</a></li>
192
+
193
+ <li><a href="single-account/acct_tr.misc.html" class="this_page_style">Travel - Miscellaneous (tr.misc)</a></li>
194
+
195
+ <li><a href="single-account/acct_tr.parking.html" class="this_page_style">Travel - Parking (tr.parking)</a></li>
196
+
197
+ <li><a href="single-account/acct_tr.perdiem.mi.html" class="this_page_style">Travel - Per Diem (Meals and Incidentals) (tr.perdiem.mi)</a></li>
198
+
199
+ <li><a href="single-account/acct_tr.taxi.html" class="this_page_style">Travel - Taxi (tr.taxi)</a></li>
200
+
201
+ <li><a href="single-account/acct_tr.trainfare.html" class="this_page_style">Travel - Train Fare (tr.trainfare)</a></li>
202
+
203
+ <li><a href="single-account/acct_tr.m.e.html" class="this_page_style">Meals and Entertainment (tr.m.e)</a></li>
204
+
205
+ <li><a href="single-account/acct_tr.unclass.html" class="this_page_style">Expenses Not Yet Classified (tr.unclass)</a></li>
206
+
207
+ </ul>
208
+ </div>
209
+ </div>
210
+ </div>
211
+
212
+
213
+ <br /><br />
214
+ <div class="collapsible-heading">
215
+ <div class="container-fluid">
216
+ <div class="row">
217
+
218
+ <div class="col-sm2" style="margin-right: 12px;">
219
+ <a class="btn btn-success" data-toggle="collapse" href="#other" role="button" aria-expanded="false" aria-controls="collapseExample">
220
+ +/-
221
+ </a>
222
+ </div>
223
+
224
+ <div class="col-sm10">
225
+ <h2 style="margin: 0px;">Other</h2>
226
+ </div>
227
+ </div>
228
+ </div>
229
+ </div>
230
+
231
+
232
+ <div class="collapse" id="other">
233
+ <div class="card card-body this_page_style">
234
+ <ul>
235
+
236
+ <li><a href="receipts.html" class="this_page_style">Missing and Existing Receipts</a></li>
237
+
238
+ </ul>
239
+ </div>
240
+ </div>
241
+
242
+ <br /><br />
243
+ <div class="collapsible-heading">
244
+ <div class="container-fluid">
245
+ <div class="row">
246
+
247
+ <div class="col-sm2" style="margin-right: 12px;">
248
+ <a class="btn btn-success" data-toggle="collapse" href="#other-formats" role="button" aria-expanded="false" aria-controls="collapseExample">
249
+ +/-
250
+ </a>
251
+ </div>
252
+
253
+ <div class="col-sm10">
254
+ <h2 style="margin: 0px;">Reports in PDF and Text Formats</h2>
255
+ </div>
256
+ </div>
257
+ </div>
258
+ </div>
259
+
260
+
261
+ <div class="collapse" id="other-formats">
262
+ <div class="card card-body this_page_style">
263
+ <ul>
264
+ <li><a href="../pdf" class="this_page_style" target="_blank">PDF Format</a></li>
265
+ <li><a href="../txt" class="this_page_style" target="_blank">Text Format</a></li>
266
+ </ul>
267
+ </div>
268
+ </div>
269
+
270
+ </body>
271
+ </html>