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
@@ -1,82 +0,0 @@
1
- require_relative '../documents/chart_of_accounts'
2
- require_relative '../documents/journal'
3
- require_relative 'reporter'
4
- require_relative 'report_context'
5
-
6
- module RockBooks
7
-
8
- class TxByAccount
9
-
10
- include Reporter
11
-
12
- attr_accessor :context
13
-
14
-
15
- def initialize(report_context)
16
- @context = report_context
17
- end
18
-
19
-
20
- def generate_header
21
- lines = [banner_line]
22
- lines << center(context.entity || 'Unspecified Entity')
23
- lines << center("Transactions by Account")
24
- lines << banner_line
25
- lines << ''
26
- lines << ''
27
- lines << ''
28
- lines.join("\n")
29
- end
30
-
31
-
32
- def account_header(account, account_total)
33
- total_string = "%.2f" % account_total
34
- title = "Total: #{total_string} -- #{account_code_name_type_string(account)}"
35
-
36
- <<~HEREDOC
37
- #{banner_line}
38
- #{center(title)}
39
- #{banner_line}
40
-
41
- HEREDOC
42
- end
43
-
44
-
45
- def account_total_line(account_code, account_total)
46
- account_name = context.chart_of_accounts.name_for_code(account_code)
47
- "%.2f Total for account: %s - %s" % [account_total, account_code, account_name]
48
- end
49
-
50
-
51
- def generate_report
52
- output = generate_header
53
-
54
- all_entries = Journal.entries_in_documents(context.journals)
55
-
56
- context.chart_of_accounts.accounts.each do |account|
57
- code = account.code
58
- account_entries = JournalEntry.entries_containing_account_code(all_entries, code)
59
- account_total = JournalEntry.total_for_code(account_entries, code)
60
- output << account_header(account, account_total)
61
-
62
- account_entries.each do |entry|
63
- output << format_multidoc_entry(entry) << "\n"
64
- output << "\n" if entry.description && entry.description.length > 0
65
- end
66
- output << account_total_line(code, account_total) << "\n"
67
- output << "\n\n\n"
68
- end
69
-
70
- totals = AcctAmount.aggregate_amounts_by_account(JournalEntry.entries_acct_amounts(all_entries))
71
- output << generate_and_format_totals('Totals', totals)
72
-
73
- output
74
- end
75
-
76
- alias_method :to_s, :generate_report
77
- alias_method :call, :generate_report
78
-
79
-
80
- end
81
-
82
- end