class RockBooks::MultidocTxnReportData
Attributes
context[R]
entries[R]
totals[R]
Public Class Methods
new(context, sort_by, filter = nil)
click to toggle source
# File lib/rock_books/reports/data/multidoc_txn_report_data.rb, line 9 def initialize(context, sort_by, filter = nil) @context = context @entries = fetch_entries(sort_by, filter) @totals = fetch_totals(filter) end
Public Instance Methods
fetch()
click to toggle source
# File lib/rock_books/reports/data/multidoc_txn_report_data.rb, line 15 def fetch { journals: context.journals, entries: entries, totals: totals, grand_total: totals.values.sum.round(2), } end
Private Instance Methods
fetch_entries(sort_by, filter)
click to toggle source
# File lib/rock_books/reports/data/multidoc_txn_report_data.rb, line 24 def fetch_entries(sort_by, filter) entries = Journal.entries_in_documents(context.journals, filter) if sort_by == :amount JournalEntry.sort_entries_by_amount_descending!(entries) else JournalEntry.sort_entries_by_date!(entries) end entries end
fetch_totals(filter)
click to toggle source
# File lib/rock_books/reports/data/multidoc_txn_report_data.rb, line 34 def fetch_totals(filter) acct_amounts = Journal.acct_amounts_in_documents(context.journals, filter) AcctAmount.aggregate_amounts_by_account(acct_amounts) end