Class: RockBooks::BookSetReporter
- Inherits:
-
Object
- Object
- RockBooks::BookSetReporter
- Extended by:
- Forwardable
- Defined in:
- lib/rock_books/reports/book_set_reporter.rb
Constant Summary collapse
- FONT_FILESPEC =
File.absolute_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'assets', 'fonts', 'JetBrainsMono-Medium.ttf'))
Instance Attribute Summary collapse
-
#book_set ⇒ Object
readonly
Returns the value of attribute book_set.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#progress_bar ⇒ Object
readonly
Returns the value of attribute progress_bar.
Instance Method Summary collapse
- #generate ⇒ Object
- #get_all_report_data ⇒ Object
-
#initialize(book_set, output_dir, filter = nil) ⇒ BookSetReporter
constructor
A new instance of BookSetReporter.
- #report_count ⇒ Object
Constructor Details
#initialize(book_set, output_dir, filter = nil) ⇒ BookSetReporter
Returns a new instance of BookSetReporter.
36 37 38 39 40 41 42 |
# File 'lib/rock_books/reports/book_set_reporter.rb', line 36 def initialize(book_set, output_dir, filter = nil) @book_set = book_set @output_dir = output_dir @filter = filter @context = ReportContext.new(book_set.chart_of_accounts, book_set.journals, 80) @progress_bar = TTY::ProgressBar.new("[:bar] :caption", total: report_count + 10) end |
Instance Attribute Details
#book_set ⇒ Object (readonly)
Returns the value of attribute book_set.
26 27 28 |
# File 'lib/rock_books/reports/book_set_reporter.rb', line 26 def book_set @book_set end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
26 27 28 |
# File 'lib/rock_books/reports/book_set_reporter.rb', line 26 def context @context end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
26 27 28 |
# File 'lib/rock_books/reports/book_set_reporter.rb', line 26 def filter @filter end |
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
26 27 28 |
# File 'lib/rock_books/reports/book_set_reporter.rb', line 26 def output_dir @output_dir end |
#progress_bar ⇒ Object (readonly)
Returns the value of attribute progress_bar.
26 27 28 |
# File 'lib/rock_books/reports/book_set_reporter.rb', line 26 def @progress_bar end |
Instance Method Details
#generate ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rock_books/reports/book_set_reporter.rb', line 45 def generate create_directories create_index_html do_statements do_journals do_transaction_reports do_single_account_reports do_receipts_report .advance(caption: 'Finished generating reports.') .finish end |
#get_all_report_data ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rock_books/reports/book_set_reporter.rb', line 69 def get_all_report_data reports = {} reports[:bs_is] = BsIsData.new(context) reports[:journals] = journals.each_with_object({}) do |journal, journals| journals[journal.short_name] = JournalData.new(journal, context, filter).fetch end reports[:txn_reports] = { by_account: MultidocTxnByAccountData.new(context).fetch, by_date: MultidocTxnReportData.new(context, :date, filter).fetch, by_amount: MultidocTxnReportData.new(context, :amount, filter).fetch } reports[:single_accounts] = chart_of_accounts.accounts.each_with_object({}) do |account, single_accts| single_accts[account.code.to_sym] = TxOneAccountData.new(context, account.code).fetch end reports[:receipts] = ReceiptsReportData.new(book_set.all_entries, .receipt_dir).fetch reports end |
#report_count ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/rock_books/reports/book_set_reporter.rb', line 59 def report_count bal_sheet_income_statement = 2 journal_count = journals.size txn_report_count = 3 single_account_count = chart_of_accounts.accounts.size receipt_report_count = 1 bal_sheet_income_statement + journal_count + txn_report_count + single_account_count + receipt_report_count end |