/qbfc

QBFC-Ruby wraps the QBFC COM object of the QuickBooks SDK, providing ease-of-use improvements, such as lower-case method names. It also provides a class for each QuickBooks entity which supports find, save, delete, void, and create operations.

Primary LanguageRubyMIT LicenseMIT

QBFC-Ruby

QBFC-Ruby provides a wrapper around QuickBooks’ QBFC COM object, while allowing more or less direct access to the actual COM object.

Obviously, test before using on your production data…

Find

QBFC-Ruby supports find queries with options, which utitilize QBFC’s Query Requests. See QBFC::Element.find for details and options.

QBFC::session do | qb |
  checks = qb.checks.find(:first, :conditions => {:entity => 'ABC Supplies'})
end

Relationships

QBFC-Ruby supports loading of related records. These are records represented by “*Ref” in the QBFC documentation. For example, a Check has, among others, a PayeeEntityRef and an AccountRef. These can be accessed via, respectively, check.payee and check.account.

check.payee.name returns the name of the payee.

You can also access the *ID and Name fields of referenced records. Example: for the payee of a Check, check.payee_id and check.payee_name.

General Examples

# A very simple example, finding a single Customer by name
QBFC::session do | qb |
  puts qb.customer('Customer Name').full_name
end

# Find all Customer, then return the first in the Array
# Next, find the first Customer only
QBFC::session do | qb |
  customers = qb.customers.find(:all)
  puts customers[0].full_name
  puts qb.customers.find(:first).full_name
end

# Same as previous, but not using a block
sess = QBFC::Session.new
customers = QBFC::Customer.find(sess, :all)
puts customers[0].full_name
puts QBFC::Customer.find(sess, :first).full_name
sess.close

# Use a QBFC::Session object, but access the COM object
# more directly.
QBFC::session do | qb |
  request_set = qb.CreateMsgSetRequest("US", 6, 0)
  customer_query = request_set.AppendCustomerQueryRq	
  response = qb.DoRequests(request_set)
  customer_set = response.ResponseList[0]
  first_customer = customer_set.Detail[0]
  puts first_customer.full_name
end

Alternatives

BehindLogic Quickbooks Rubygem

homepage: behindlogic.com

This gem covers the full API and does validations. I haven’t tried it out, but the code samples look straightforward. ($199 for a internal license)

QuickBooks for Ruby

(docs: quickbooks.rubyforge.org, homepage: rubyforge.org/projects/quickbooks)

This is a project with similar goals to QBFC-Ruby. I believe the approach is creating Ruby classes that mirror the QuickBooks types and generate / parse qbXML. In my opinion, this approach is more stable and flexible than what I’m doing with QBFC-Ruby, but at the cost of slower development. (As in, QBFC-Ruby was intended as a collection of quick and dirty shortcuts; QuickBooks for Ruby seems to be intended as a much more complete project)

QBFC/qbXML COM Objects

Using the SDK directly is an option. Unless you need to use QBWC (QuickBooks Web Connector) or have some other reason for wanting to us qbXML, I suggest using QBFC. The SDK documents (see developer.intuit.com/ ) are pretty easy to use and navigate.

There are some other libraries on rubyforge in early stages which I haven’t really explored.

Copyright © 2008 Jared E. Morgan, released under the MIT license