public
Description: Simplying working with models that rely on parsing QuickBooks SDK qbXML messages
Clone URL: git://github.com/zackchandler/acts_as_quickbooks_model.git
Search Repo:
name age message
folder .gitignore Sat May 17 12:36:03 -0700 2008 tests, auto-build has_many associations [zackchandler]
folder README.markdown Sat May 17 12:36:03 -0700 2008 tests, auto-build has_many associations [zackchandler]
folder Rakefile Fri May 02 00:03:32 -0700 2008 add auto-generated note, qb:all rake task [zackchandler]
folder definitions/ Tue Jun 17 14:43:57 -0700 2008 EsimateLineGroups [zackchandler]
folder init.rb Thu May 01 15:35:26 -0700 2008 first commit [zackchandler]
folder lib/ Thu Jun 19 17:32:14 -0700 2008 added support for polymorphic model support - u... [zackchandler]
folder migrations/ Tue Jun 17 14:43:57 -0700 2008 EsimateLineGroups [zackchandler]
folder model_maps/ Tue Jun 17 14:43:57 -0700 2008 EsimateLineGroups [zackchandler]
folder test/ Thu Jun 19 17:32:14 -0700 2008 added support for polymorphic model support - u... [zackchandler]
README.markdown

Introduction

This plugin simplifies the parsing of qbXML messages into ActiveRecord model attributes.

Usage

class Customer < ActiveRecord::Base
  acts_as_quickbooks_model
end

xml = <
  150000-933272658
  Abercrombie, Kristy

    Kristy Abercrombie
    5647 Cypress Hill Rd
    Bayshore
    CA
    94326


XML

customer = Customer.new(:qbxml => xml)
customer.list_id # => "150000-933272658"
customer.name # => "Abercrombie, Kristy"
customer.bill_address_city # => "Bayshore"
...

Auto-builds has_many associations

class Invoice < ActiveRecord::Base
  acts_as_quickbooks_model
  has_many :invoice_lines
  has_many :invoice_line_groups
end
class InvoiceLine < ActiveRecord::Base
  acts_as_quickbooks_model
  belongs_to :invoice
end
class InvoiceLineGroup < ActiveRecord::Base
  acts_as_quickbooks_model
  belongs_to :invoice
end

xml = <
  123

    456

      789



    012

      567



    321

      987



XML

invoice = Invoice.create(:qbxml => xml)
invoice.txn_id # => "123"
invoice.invoice_lines.count # => 2
invoice.invoice_line_groups.count # => 1
invoice.invoice_lines.first.txn_line_id # => "456"
invoice.invoice_line_groups.first.txn_line_id # => "321"
...

References

QuickBooks SDK Reference