Class: QBFC::Report
Overview
This class is EXPERIMENTAL! This is a first stab at working with Reports.
Direct Known Subclasses
QBFC::Reports::Aging, QBFC::Reports::BudgetSummary, QBFC::Reports::CustomDetail, QBFC::Reports::CustomSummary, QBFC::Reports::GeneralDetail, QBFC::Reports::GeneralSummary, QBFC::Reports::Job, QBFC::Reports::PayrollDetail, QBFC::Reports::PayrollSummary, QBFC::Reports::Time
Constant Summary collapse
- CLASSES =
Set up CLASSES constant now that the referenced classes are loaded.
[QBFC::Reports::Aging, QBFC::Reports::BudgetSummary, QBFC::Reports::CustomDetail, QBFC::Reports::CustomSummary, QBFC::Reports::GeneralDetail, QBFC::Reports::GeneralSummary, QBFC::Reports::Job, QBFC::Reports::PayrollDetail, QBFC::Reports::PayrollSummary, QBFC::Reports::Time]
Class Method Summary collapse
-
.get(sess, name, *args) ⇒ Object
Get a new Report.
-
.get_class(report_name) ⇒ Object
Return the class that a report belongs to.
-
.qb_name ⇒ Object
The QuickBooks name for this Report.
-
.query(sess, name, *args) ⇒ Object
Run a query to retrieve a report.
Instance Method Summary collapse
- #cell(row_name, col_name) ⇒ Object
- #col_for(name) ⇒ Object
- #data ⇒ Object
- #rows ⇒ Object
- #subtotals ⇒ Object
- #text_rows ⇒ Object
- #totals ⇒ Object
Methods inherited from Base
create_query, #initialize, is_base_class?, #method_missing, #ole_methods, parse_find_args, #qb_name, #respond_to_ole?
Constructor Details
This class inherits a constructor from QBFC::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class QBFC::Base
Class Method Details
.get(sess, name, *args) ⇒ Object
Get a new Report. This is roughly equivalent with QBFC::Element::find.
-
sess: An open QBFC::Session object that will recieve all requests. -
name: The name of the report. -
args: TODO.
37 38 39 40 |
# File 'lib/qbfc/report.rb', line 37 def get(sess, name, *args) klass = get_class(name) klass.new(sess, klass.query(sess, name, *args)) end |
.get_class(report_name) ⇒ Object
Return the class that a report belongs to. Takes a string (or symbol) of the report name. I could see refactoring this to use constants, later.
8 9 10 11 |
# File 'lib/qbfc/report.rb', line 8 def get_class(report_name) report_name = report_name.to_s CLASSES.find {|klass| klass::REPORTS.include?(report_name)} end |
.qb_name ⇒ Object
The QuickBooks name for this Report. It typically matches the last part of class name, plus ‘Report’ Used in determining names of Requests and other OLE methods.
28 29 30 |
# File 'lib/qbfc/report.rb', line 28 def qb_name self.name.split('::').last + 'Report' end |
.query(sess, name, *args) ⇒ Object
Run a query to retrieve a report. Typically called by new. See new for arguments.
15 16 17 18 19 20 21 22 23 |
# File 'lib/qbfc/report.rb', line 15 def query(sess, name, *args) # Setup q, options and base_options arguments (base_options is not used) q, , = parse_find_args(*args) q ||= create_query(sess) q.() q.send(qb_name + 'Type'). SetValue(QBFC_CONST::const_get(self::REPORT_TYPE_PREFIX + name)) q.response end |
Instance Method Details
#cell(row_name, col_name) ⇒ Object
63 64 65 |
# File 'lib/qbfc/report.rb', line 63 def cell(row_name, col_name) rows[:data][row_name][col_for(col_name)] end |
#col_for(name) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/qbfc/report.rb', line 67 def col_for(name) @ole.col_descs.each do |col| col.col_titles.each do |title| if title.value if (title.value.GetValue() == name) return col.colID.GetValue().to_i - 1 end end end end end |
#data ⇒ Object
47 48 49 |
# File 'lib/qbfc/report.rb', line 47 def data rows[:data] end |
#rows ⇒ Object
43 44 45 |
# File 'lib/qbfc/report.rb', line 43 def rows @rows ||= QBFC::Reports::Rows::parse(@ole.report_data) end |
#subtotals ⇒ Object
51 52 53 |
# File 'lib/qbfc/report.rb', line 51 def subtotals rows[:subtotals] end |
#text_rows ⇒ Object
59 60 61 |
# File 'lib/qbfc/report.rb', line 59 def text_rows rows[:text] end |
#totals ⇒ Object
55 56 57 |
# File 'lib/qbfc/report.rb', line 55 def totals rows[:totals] end |