Class QBFC::Report
In: lib/qbfc/report.rb
Parent: Base

This class is EXPERIMENTAL! This is a first stab at working with Reports.

Methods

cell   col_for   data   get   get_class   qb_name   query   rows   subtotals   text_rows   totals  

Constants

CLASSES = [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]   Set up CLASSES constant now that the referenced classes are loaded.

Public Class methods

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.

[Source]

    # File lib/qbfc/report.rb, line 37
37:       def get(sess, name, *args)
38:         klass = get_class(name)
39:         klass.new(sess, klass.query(sess, name, *args))
40:       end

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.

[Source]

    # File lib/qbfc/report.rb, line 8
 8:       def get_class(report_name)
 9:         report_name = report_name.to_s
10:         CLASSES.find {|klass| klass::REPORTS.include?(report_name)}
11:       end

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.

[Source]

    # File lib/qbfc/report.rb, line 28
28:       def qb_name
29:         self.name.split('::').last + 'Report'
30:       end

Run a query to retrieve a report. Typically called by new. See new for arguments.

[Source]

    # File lib/qbfc/report.rb, line 15
15:       def query(sess, name, *args)  
16:         # Setup q, options and base_options arguments (base_options is not used)

17:         q, options, base_options = parse_find_args(*args)
18:         q ||= create_query(sess)
19:         q.apply_options(options)
20:         q.send(qb_name + 'Type').
21:             SetValue(QBFC_CONST::const_get(self::REPORT_TYPE_PREFIX + name))
22:         q.response
23:       end

Public Instance methods

[Source]

    # File lib/qbfc/report.rb, line 63
63:     def cell(row_name, col_name)
64:       rows[:data][row_name][col_for(col_name)]
65:     end

[Source]

    # File lib/qbfc/report.rb, line 67
67:     def col_for(name)
68:       @ole.col_descs.each do |col|
69:         col.col_titles.each do |title|
70:           if title.value
71:             if (title.value.GetValue() == name)
72:               return col.colID.GetValue().to_i - 1
73:             end
74:           end
75:         end
76:       end
77:     end

[Source]

    # File lib/qbfc/report.rb, line 47
47:     def data
48:       rows[:data]
49:     end

[Source]

    # File lib/qbfc/report.rb, line 43
43:     def rows
44:       @rows ||= QBFC::Reports::Rows::parse(@ole.report_data)
45:     end

[Source]

    # File lib/qbfc/report.rb, line 51
51:     def subtotals
52:       rows[:subtotals]
53:     end

[Source]

    # File lib/qbfc/report.rb, line 59
59:     def text_rows
60:       rows[:text]
61:     end

[Source]

    # File lib/qbfc/report.rb, line 55
55:     def totals
56:       rows[:totals]
57:     end

[Validate]