Class: RockBooks::TxOneAccount

Inherits:
Object
  • Object
show all
Includes:
Reporter
Defined in:
lib/rock_books/reports/tx_one_account.rb

Constant Summary

Constants included from Reporter

Reporter::SHORT_NAME_FORMAT_STRING, Reporter::SHORT_NAME_MAX_LENGTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Reporter

account_code_name_type_string, banner_line, center, format_account_code, format_acct_amount, format_amount, format_multidoc_entry, generate_account_type_section, generate_and_format_totals, max_account_code_length, page_width

Constructor Details

#initialize(report_context, account_code) ⇒ TxOneAccount

Returns a new instance of TxOneAccount.



15
16
17
18
19
# File 'lib/rock_books/reports/tx_one_account.rb', line 15

def initialize(report_context, )
  @context = report_context
  @account_code = 
  @account = context.chart_of_accounts.()
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



12
13
14
# File 'lib/rock_books/reports/tx_one_account.rb', line 12

def 
  @account
end

#account_codeObject (readonly)

Returns the value of attribute account_code.



12
13
14
# File 'lib/rock_books/reports/tx_one_account.rb', line 12

def 
  @account_code
end

#contextObject (readonly)

Returns the value of attribute context.



12
13
14
# File 'lib/rock_books/reports/tx_one_account.rb', line 12

def context
  @context
end

Instance Method Details

#generate_header(account_total) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rock_books/reports/tx_one_account.rb', line 22

def generate_header()
  lines = [banner_line]
  lines << center(context.entity || 'Unspecified Entity')
  lines << center("Transactions for Account #{()}")
  lines << center("Total: %.2f" % )
  lines << banner_line
  lines << ''
  lines << ''
  lines << ''
  lines.join("\n")
end

#generate_reportObject Also known as: to_s, call



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rock_books/reports/tx_one_account.rb', line 43

def generate_report
  entries = Journal.entries_in_documents(context.journals, JournalEntryFilters.())
   = JournalEntry.total_for_code(entries, )
  output = generate_header()

  if entries.empty?
    output << "There were no transactions for this account.\n\n\n\n"
  else
    output << (entries)
    totals = AcctAmount.(JournalEntry.entries_acct_amounts(entries))
    output << generate_and_format_totals('Totals', totals)
  end

  output
end

#process_account(entries) ⇒ Object



35
36
37
38
39
40
# File 'lib/rock_books/reports/tx_one_account.rb', line 35

def (entries)
  entries.each_with_object('') do |entry, output|
    output << format_multidoc_entry(entry) << "\n"
    output << "\n" if entry.description && entry.description.length > 0
  end
end