class RockBooks::BsIsData
Attributes
context[R]
end_date[R]
journals_acct_totals[R]
start_date[R]
totals[R]
Public Class Methods
new(context)
click to toggle source
# File lib/rock_books/reports/data/bs_is_data.rb, line 12 def initialize(context) @context = context @start_date = context.chart_of_accounts.start_date @end_date = context.chart_of_accounts.end_date filter = JournalEntryFilters.date_on_or_before(end_date) acct_amounts = Journal.acct_amounts_in_documents(context.journals, filter) @journals_acct_totals = AcctAmount.aggregate_amounts_by_account(acct_amounts) end
Public Instance Methods
bal_sheet_data()
click to toggle source
# File lib/rock_books/reports/data/bs_is_data.rb, line 27 def bal_sheet_data { end_date: end_date, entity: context.entity, sections: { asset: section_data(:asset), liability: section_data(:liability), equity: section_data(:equity), }, grand_total: journals_acct_totals.values.sum.round(2) } end
inc_stat_data()
click to toggle source
# File lib/rock_books/reports/data/bs_is_data.rb, line 41 def inc_stat_data income_section_data = section_data(:income) expense_section_data = section_data(:expense) net_income = (income_section_data[:acct_totals].values.sum.round(2) - expense_section_data[:acct_totals].values.sum.round(2) ).round(2) { start_date: start_date, end_date: end_date, entity: context.entity, sections: { income: income_section_data, expense: expense_section_data, }, net_income: net_income } end
section_data(type)
click to toggle source
# File lib/rock_books/reports/data/bs_is_data.rb, line 22 def section_data(type) BsIsSectionData.new(type, context, journals_acct_totals).fetch end