Class: RockBooks::BookSetReporter

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_setObject (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

#contextObject (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

#filterObject (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_dirObject (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_barObject (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
  @progress_bar
end

Instance Method Details

#generateObject



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_receipts_report
  progress_bar.advance(caption: 'Finished generating reports.')
  progress_bar.finish
end

#get_all_report_dataObject



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 |, single_accts|
    single_accts[.code.to_sym] = TxOneAccountData.new(context, .code).fetch
  end

  reports[:receipts] = ReceiptsReportData.new(book_set.all_entries, run_options.receipt_dir).fetch
  reports
end

#report_countObject



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
   = chart_of_accounts.accounts.size
  receipt_report_count = 1
  bal_sheet_income_statement + journal_count + txn_report_count +  + receipt_report_count
end