Class: RockBooks::JournalData
- Inherits:
-
Object
- Object
- RockBooks::JournalData
- Defined in:
- lib/rock_books/reports/data/journal_data.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#journal ⇒ Object
readonly
Returns the value of attribute journal.
Instance Method Summary collapse
- #entries ⇒ Object
- #fetch ⇒ Object
-
#initialize(journal, report_context, filter = nil) ⇒ JournalData
constructor
A new instance of JournalData.
Constructor Details
#initialize(journal, report_context, filter = nil) ⇒ JournalData
Returns a new instance of JournalData.
8 9 10 11 12 |
# File 'lib/rock_books/reports/data/journal_data.rb', line 8 def initialize(journal, report_context, filter = nil) @journal = journal @context = report_context @filter = filter end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/rock_books/reports/data/journal_data.rb', line 6 def context @context end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
6 7 8 |
# File 'lib/rock_books/reports/data/journal_data.rb', line 6 def filter @filter end |
#journal ⇒ Object (readonly)
Returns the value of attribute journal.
6 7 8 |
# File 'lib/rock_books/reports/data/journal_data.rb', line 6 def journal @journal end |
Instance Method Details
#entries ⇒ Object
14 15 16 17 18 19 |
# File 'lib/rock_books/reports/data/journal_data.rb', line 14 def entries return @entries if @entries @entries = journal.entries @entries = @entries.select { |entry| filter.(entry) } if filter @entries end |
#fetch ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rock_books/reports/data/journal_data.rb', line 21 def fetch totals = AcctAmount.aggregate_amounts_by_account(JournalEntry.entries_acct_amounts(entries)) { code: journal.account_code, name: journal.chart_of_accounts.name_for_code(journal.account_code), title: journal.title, short_name: journal.short_name, debit_or_credit: journal.debit_or_credit, start_date: context.chart_of_accounts.start_date, end_date: context.chart_of_accounts.end_date, entries: entries, totals: totals, grand_total: totals.values.sum.round(2), max_acct_code_len: context.chart_of_accounts.max_account_code_length } end |