qbwc / quickbooks_api

A Ruby wrapper for the Quickbooks XML API
20 stars 10 forks source link

Any tips for implementation? #3

Closed rposborne closed 12 years ago

rposborne commented 12 years ago

I am trying to build out a sync using Quickbooks Web Connect and was wondering if you have any tips in regards to this gem. This is by far the most promising gem out there that does not cost $$. Lets get a wiki started?

skryl commented 12 years ago

If you're trying to implement a sync then I have more good news for you. I built the xml api for this exact reason and I have more components you'll need to get it working. I'll try to get them up on github this week. First is the rails gem that creates a soap server to talk to the Web Connector. Second is the code that performs they syncing/field mapping/etc. Can tell me more about your specific needs and which Intuit software you have to work with?

rposborne commented 12 years ago

I already have communication occurring using some code modeled after https://github.com/zackchandler/qbwc-mini

Basically I have orders/invoicing application, that needs to send old customers new invoices to a quickbooks enterprise 11 manufacturing.

Right now my plan is to attempt to match up customers via exact name only. Nothing fancy

And create new invoices for those existing customers.

I have the raw shell close to working but I am having some difficulty with what I am supposed to be feeding your gem.

skryl commented 12 years ago

Looking at qbwc-mini, it seems hardcoded to deal with Customer data requests only. I believe the 'doc' variable on line 16 of qbwc.rb will have the xml response in full. Doing something like this should convert it to a ruby hash.

h = api.qbxml_to_hash(doc)

If this doesn't work send me a dump of what 'doc' and 'payload' contain after a response comes back.

rposborne commented 12 years ago

qbwc was an example to implement a QWC without any thing like action_web_service.

the doc being passed into the the respond XML results in this crash

NoMethodError (undefined method empty?' for #<Hpricot::Doc:0x007fa2885ff118>): lib/etc/qbwc_supervisor.rb:32:inreceiveResponseXML' app/controllers/quickbooks_controller.rb:60:in `api'

I assumed i was simply needing to only pass in raw QBXML or a nokogiri element based upon looking at your code.

Below is receiveResponse XML from a sample company file

    <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><receiveResponseXML xmlns="http://developer.intuit.com/"><ticket>abc123</ticket><response><?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<CustomerQueryRs requestID="1" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
<CustomerRet>
<ListID>800000DC-1418660962</ListID>
<TimeCreated>2014-12-15T11:29:22-05:00</TimeCreated>
<TimeModified>2014-12-15T11:29:22-05:00</TimeModified>
<EditSequence>1418660962</EditSequence>
<Name>Joe Customer</Name>
<FullName>Joe Customer</FullName>
<IsActive>true</IsActive>
<Sublevel>0</Sublevel>
<CompanyName>Joes Garage</CompanyName>
<Salutation>Mr</Salutation>
<FirstName>Joe</FirstName>
<LastName>Customer</LastName>
<BillAddress>
<Addr1>123 Main St.</Addr1>
<City>Mountain View</City>
<State>CA</State>
<PostalCode>94566</PostalCode>
</BillAddress>
<Phone>650-944-1111</Phone>
<AltPhone>650-944-2111</AltPhone>
<Email>joe@joegargage.com</Email>
<TermsRef>
<ListID>10000-933272658</ListID>
<FullName>Net 30</FullName>
</TermsRef>
<Balance>0.00</Balance>
<TotalBalance>0.00</TotalBalance>
<SalesTaxCodeRef>
<ListID>10000-999022286</ListID>
<FullName>Tax</FullName>
</SalesTaxCodeRef>
<ItemSalesTaxRef>
<ListID>2E0000-933272656</ListID>
<FullName>San Tomas</FullName>
</ItemSalesTaxRef>
<AccountNumber>89087</AccountNumber>
<CreditLimit>2000.00</CreditLimit>
<JobStatus>None</JobStatus>
</CustomerRet>
<CustomerRet>
<ListID>800000DD-1418660962</ListID>
<TimeCreated>2014-12-15T11:29:22-05:00</TimeCreated>
<TimeModified>2014-12-15T11:29:22-05:00</TimeModified>
<EditSequence>1418660962</EditSequence>
<Name>Equipment Installation</Name>
<FullName>Joe Customer:Equipment Installation</FullName>
<IsActive>true</IsActive>
<ParentRef>
<ListID>800000DC-1418660962</ListID>
<FullName>Joe Customer</FullName>
</ParentRef>
<Sublevel>1</Sublevel>
<Balance>0.00</Balance>
<TotalBalance>0.00</TotalBalance>
<SalesTaxCodeRef>
<ListID>10000-999022286</ListID>
<FullName>Tax</FullName>
</SalesTaxCodeRef>
<ItemSalesTaxRef>
<ListID>2E0000-933272656</ListID>
<FullName>San Tomas</FullName>
</ItemSalesTaxRef>
<JobStatus>Awarded</JobStatus>
<JobStartDate>2001-03-01</JobStartDate>
<JobProjectedEndDate>2001-12-01</JobProjectedEndDate>
<JobEndDate>2001-12-15</JobEndDate>
<JobDesc>Install new smog equipment</JobDesc>
</CustomerRet>
<CustomerRet>
<ListID>150000-933272658</ListID>
<TimeCreated>1999-07-29T14:24:18-05:00</TimeCreated>
<TimeModified>2013-12-15T00:23:13-05:00</TimeModified>
<EditSequence>1387084993</EditSequence>
<Name>Abercrombie, Kristy</Name>
<FullName>Abercrombie, Kristy</FullName>
<IsActive>true</IsActive>
<Sublevel>0</Sublevel>
<Salutation>Mrs.</Salutation>
<FirstName>Kristy</FirstName>
<LastName>Abercrombie</LastName>
<BillAddress>
<Addr1>Kristy Abercrombie</Addr1>
<Addr2>5647 Cypress Hill Rd</Addr2>
<City>Bayshore</City>
<State>CA</State>
<PostalCode>94326</PostalCode>
</BillAddress>
<ShipAddress>
<Addr1>Kristy Abercrombie</Addr1>
<Addr2>5647 Cypress Hill Rd</Addr2>
<City>Bayshore</City>
<State>CA</State>
<PostalCode>94326</PostalCode>
</ShipAddress>
<Phone>415-555-6579</Phone>
<Email>kristy@samplename.com</Email>
<Contact>Kristy Abercrombie</Contact>
<AltContact>Steve Darcangelo</AltContact>
<CustomerTypeRef>
<ListID>20000-933272658</ListID>
<FullName>Residential</FullName>
</CustomerTypeRef>
<TermsRef>
<ListID>10000-933272658</ListID>
<FullName>Net 30</FullName>
</TermsRef>
<Balance>0.00</Balance>
<TotalBalance>0.00</TotalBalance>
<SalesTaxCodeRef>
<ListID>10000-999022286</ListID>
<FullName>Tax</FullName>
</SalesTaxCodeRef>
<ItemSalesTaxRef>
<ListID>2E0000-933272656</ListID>
<FullName>San Tomas</FullName>
</ItemSalesTaxRef>
<AccountNumber>91-431</AccountNumber>
<JobStatus>None</JobStatus>
<JobStartDate>2007-09-23</JobStartDate>
<JobProjectedEndDate>2007-09-23</JobProjectedEndDate>
<JobEndDate>2007-09-23</JobEndDate>
<Notes>9/15/2003:  Send Kristy estimate for den remodel.

9/20/2003:  Called Kristy to discuss job:  Kristy is not interested at this time.  Estimate was competitive, not using another firm.

10/15/2003:  Further discussion of bathroom remodel.  I offered 10% discount on project if she would sign the contract now.</Notes>
</CustomerRet>
<CustomerRet>
<ListID>160000-933272658</ListID>
<TimeCreated>1999-07-29T14:24:18-05:00</TimeCreated>
<TimeModified>2013-12-15T00:23:13-05:00</TimeModified>
<EditSequence>1387084993</EditSequence>
<Name>Family Room</Name>
<FullName>Abercrombie, Kristy:Family Room</FullName>
<IsActive>true</IsActive>
<ParentRef>
<ListID>150000-933272658</ListID>
<FullName>Abercrombie, Kristy</FullName>
</ParentRef>
<Sublevel>1</Sublevel>
<Salutation>Mrs.</Salutation>
<FirstName>Kristy</FirstName>
<LastName>Abercrombie</LastName>
<BillAddress>
<Addr1>Kristy Abercrombie</Addr1>
<Addr2>5647 Cypress Hill Rd</Addr2>
<City>Bayshore</City>
<State>CA</State>
<PostalCode>94326</PostalCode>
</BillAddress>
<ShipAddress>
<Addr1>Kristy Abercrombie</Addr1>
<Addr2>5647 Cypress Hill Rd</Addr2>
<City>Bayshore</City>
<State>CA</State>
<PostalCode>94326</PostalCode>
</ShipAddress>
<Phone>415-555-6579</Phone>
<Email>kristy@samplename.com</Email>
<Contact>Kristy Abercrombie</Contact>
<CustomerTypeRef>
<ListID>20000-933272658</ListID>
<FullName>Residential</FullName>
</CustomerTypeRef>
<TermsRef>
<ListID>10000-933272658</ListID>
<FullName>Net 30</FullName>
</TermsRef>
<Balance>0.00</Balance>
<TotalBalance>0.00</TotalBalance>
<ItemSalesTaxRef>
<ListID>2E0000-933272656</ListID>
<FullName>San Tomas</FullName>
</ItemSalesTaxRef>
<JobStatus>Closed</JobStatus>
<JobDesc>Remodel family room: Drywall, re-carpet, add fireplace.</JobDesc>
<JobTypeRef>
<ListID>20000-933272658</ListID>
<FullName>Remodel</FullName>
</JobTypeRef>
</CustomerRet>
<CustomerRet>
<ListID>170000-933272658</ListID>
<TimeCreated>1999-07-29T14:24:18-05:00</TimeCreated>
<TimeModified>2013-12-15T00:23:13-05:00</TimeModified>
<EditSequence>1387084993</EditSequence>
<Name>Kitchen</Name>
<FullName>Abercrombie, Kristy:Kitchen</FullName>
<IsActive>true</IsActive>
<ParentRef>
<ListID>150000-933272658</ListID>
<FullName>Abercrombie, Kristy</FullName>
</ParentRef>
<Sublevel>1</Sublevel>
<Salutation>Mrs.</Salutation>
<FirstName>Kristy</FirstName>
<LastName>Abercrombie</LastName>
<BillAddress>
<Addr1>Kristy Abercrombie</Addr1>
<Addr2>5647 Cypress Hill Rd</Addr2>
<City>Bayshore</City>
<State>CA</State>
<PostalCode>94326</PostalCode>
</BillAddress>
<ShipAddress>
<Addr1>Kristy Abercrombie</Addr1>
<Addr2>5647 Cypress Hill Rd</Addr2>
<City>Bayshore</City>
<State>CA</State>
<PostalCode>94326</PostalCode>
</ShipAddress>
<Phone>415-555-6579</Phone>
<Email>kristy@samplename.com</Email>
<Contact>Kristy Abercrombie</Contact>
<CustomerTypeRef>
<ListID>20000-933272658</ListID>
<FullName>Residential</FullName>
</CustomerTypeRef>
<TermsRef>
<ListID>10000-933272658</ListID>
<FullName>Net 30</FullName>
</TermsRef>
<Balance>0.00</Balance>
<TotalBalance>0.00</TotalBalance>
<ItemSalesTaxRef>
<ListID>2E0000-933272656</ListID>
<FullName>San Tomas</FullName>
</ItemSalesTaxRef>
<JobStatus>Pending</JobStatus>
<JobDesc>Fire restoration of kitchen: Replace counter, dishwasher, oven and paint.</JobDesc>
<JobTypeRef>
<ListID>30000-933272658</ListID>
<FullName>Repairs</FullName>
</JobTypeRef>
</CustomerRet>
<CustomerRet>
<ListID>180000-933272658</ListID>
<TimeCreated>1999-07-29T14:24:18-05:00</TimeCreated>
<TimeModified>2013-12-15T00:23:13-05:00</TimeModified>
<EditSequence>1387084993</EditSequence>
<Name>Remodel Bathroom</Name>
<FullName>Abercrombie, Kristy:Remodel Bathroom</FullName>
<IsActive>true</IsActive>
<ParentRef>
<ListID>150000-933272658</ListID>
<FullName>Abercrombie, Kristy</FullName>
</ParentRef>
<Sublevel>1</Sublevel>
<CompanyName>Kristy Abercrombie</CompanyName>
<Salutation>Mrs.</Salutation>
<FirstName>Kristy</FirstName>
<LastName>Abercrombie</LastName>
<BillAddress>
<Addr1>Kristy Abercrombie</Addr1>
<Addr2>5647 Cypress Hill Rd</Addr2>
<City>Bayshore</City>
<State>CA</State>
<PostalCode>94326</PostalCode>
</BillAddress>
<Phone>415-555-6579</Phone>
<Email>kristy@samplename.com</Email>
<Contact>Kristy Abercrombie</Contact>
<CustomerTypeRef>
<ListID>20000-933272658</ListID>
<FullName>Residential</FullName>
</CustomerTypeRef>
<TermsRef>
<ListID>10000-933272658</ListID>
<FullName>Net 30</FullName>
</TermsRef>
<Balance>0.00</Balance>
<TotalBalance>0.00</TotalBalance>
<ItemSalesTaxRef>
<ListID>2E0000-933272656</ListID>
<FullName>San Tomas</FullName>
</ItemSalesTaxRef>
<JobStatus>InProgress</JobStatus>
<JobStartDate>2014-10-23</JobStartDate>
<JobProjectedEndDate>2014-12-11</JobProjectedEndDate>
<JobEndDate>2014-12-23</JobEndDate>
<JobDesc>Remodel master bathroom: Build new counter, Replace fixtures, Add whirlpool.</JobDesc>
<JobTypeRef>
<ListID>20000-933272658</ListID>
<FullName>Remodel</FullName>
</JobTypeRef>
</CustomerRet>
<CustomerRet>
<ListID>800000D0-1182061376</ListID>
<TimeCreated>2007-06-17T02:22:56-05:00</TimeCreated>
<TimeModified>2013-12-15T00:23:13-05:00</TimeModified>
<EditSequence>1387084993</EditSequence>
<Name>Allard, Robert</Name>
<FullName>Allard, Robert</FullName>
<IsActive>true</IsActive>
<Sublevel>0</Sublevel>
<Salutation>Mrs.</Salutation>
<FirstName>Amanda</FirstName>
<LastName>Roberts</LastName>
<BillAddress>
<Addr1>Robert Allard</Addr1>
<Addr2>92834 Chandler St.</Addr2>
<City>Millbrae</City>
<State>CA</State>
<PostalCode>94030</PostalCode>
</BillAddress>
<ShipAddress>
<Addr1>Robert Allard</Addr1>
<Addr2>92834 Chandler St.</Addr2>
<City>Millbrae</City>
<State>CA</State>
<PostalCode>94030</PostalCode>
</ShipAddress>
<Phone>650-555-3422</Phone>
<AltPhone>650-555-8349</AltPhone>
<Fax>650-555-9804</Fax>
<Email>rallard@myemail.com</Email>
<Contact>Robert Allard</Contact>
<AltContact>Rachel Fisher</AltContact>
<CustomerTypeRef>
<ListID>20000-933272658</ListID>
<FullName>Residential</FullName>
</CustomerTypeRef>
<TermsRef>
<ListID>20000-933272658</ListID>
<FullName>Net 15</FullName>
</TermsRef>
<Balance>0.00</Balance>
<TotalBalance>14510.00</TotalBalance>
<SalesTaxCodeRef>
<ListID>10000-999022286</ListID>
<FullName>Tax</FullName>
</SalesTaxCodeRef>
<ItemSalesTaxRef>
<ListID>2E0000-933272656</ListID>
<FullName>San Tomas</FullName>
</ItemSalesTaxRef>
<JobStatus>None</JobStatus>
</CustomerRet>
<CustomerRet>
<ListID>800000D1-1182061396</ListID>
<TimeCreated>2007-06-17T02:23:16-05:00</TimeCreated>
<TimeModified>2013-12-15T00:23:13-05:00</TimeModified>
<EditSequence>1387084993</EditSequence>
<Name>Remodel</Name>
<FullName>Allard, Robert:Remodel</FullName>
<IsActive>true</IsActive>
<ParentRef>
<ListID>800000D0-1182061376</ListID>
<FullName>Allard, Robert</FullName>
</ParentRef>
<Sublevel>1</Sublevel>
<Salutation>Mrs.</Salutation>
<FirstName>Amanda</FirstName>
<LastName>Roberts</LastName>
<BillAddress>
<Addr1>Robert Allard</Addr1>
<Addr2>92834 Chandler St.</Addr2>
<City>Millbrae</City>
<State>CA</State>
<PostalCode>94030</PostalCode>
</BillAddress>
<Phone>650-555-3422</Phone>
<AltPhone>650-555-8349</AltPhone>
<Fax>650-555-9804</Fax>
<Email>rallard@myemail.com</Email>
<Contact>Robert Allard</Contact>
<CustomerTypeRef>
<ListID>20000-933272658</ListID>
<FullName>Residential</FullName>
</CustomerTypeRef>
<TermsRef>
<ListID>20000-933272658</ListID>
<FullName>Net 15</FullName>
</TermsRef>
<Balance>14510.00</Balance>
<TotalBalance>14510.00</TotalBalance>
<SalesTaxCodeRef>
<ListID>10000-999022286</ListID>
<FullName>Tax</FullName>
</SalesTaxCodeRef>
<ItemSalesTaxRef>
<ListID>2E0000-933272656</ListID>
<FullName>San Tomas</FullName>
</ItemSalesTaxRef>
<JobStatus>None</JobStatus>
</CustomerRet>
<CustomerRet>
<ListID>800000C6-1182059711</ListID>
<TimeCreated>2007-06-17T01:55:11-05:00</TimeCreated>
<TimeModified>2013-12-15T00:23:13-05:00</TimeModified>
<EditSequence>1387084993</EditSequence>
<Name>Babcock&apos;s Music Shop</Name>
<FullName>Babcock&apos;s Music Shop</FullName>
<IsActive>true</IsActive>
<Sublevel>0</Sublevel>
<CompanyName>Babcock&apos;s Music Shop</CompanyName>
<Salutation>Ms.</Salutation>
<FirstName>Kristie</FirstName>
<LastName>Babcock</LastName>
<BillAddress>
<Addr1>Babcock&apos;s Music Shop</Addr1>
<Addr2>Kristie Babcock</Addr2>
<Addr3>10923 Samson Dr.</Addr3>
<City>Millbrae</City>
<State>CA</State>
<PostalCode>94030</PostalCode>
</BillAddress>
<ShipAddress>
<Addr1>Babcock&apos;s Music Shop</Addr1>
<Addr2>Kristie Babcock</Addr2>
<Addr3>10923 Samson Dr.</Addr3>
<City>Millbrae</City>
<State>CA</State>
<PostalCode>94030</PostalCode>
</ShipAddress>
<Phone>650-555-2342</Phone>
<AltPhone>650-555-0983</AltPhone>
<Fax>650-555-9823</Fax>
<Email>kbabcock@myemail.com</Email>
<Contact>Kristie Babcock</Contact>
<CustomerTypeRef>
<ListID>10000-933272658</ListID>
<FullName>Commercial</FullName>
</CustomerTypeRef>
<TermsRef>
<ListID>20000-933272658</ListID>
<FullName>Net 15</FullName>
</TermsRef>
<Balance>0.00</Balance>
<TotalBalance>0.00</TotalBalance>
<SalesTaxCodeRef>
<ListID>10000-999022286</ListID>
<FullName>Tax</FullName>
</SalesTaxCodeRef>
<ItemSalesTaxRef>
<ListID>2E0000-933272656</ListID>
<FullName>San Tomas</FullName>
</ItemSalesTaxRef>
<JobStatus>None</JobStatus>
</CustomerRet>
<CustomerRet>
<ListID>800000C7-1182059716</ListID>
<TimeCreated>2007-06-17T01:55:16-05:00</TimeCreated>
<TimeModified>2013-12-15T00:23:13-05:00</TimeModified>
<EditSequence>1387084993</EditSequence>
<Name>Remodel</Name>
<FullName>Babcock&apos;s Music Shop:Remodel</FullName>
<IsActive>true</IsActive>
<ParentRef>
<ListID>800000C6-1182059711</ListID>
<FullName>Babcock&apos;s Music Shop</FullName>
</ParentRef>
<Sublevel>1</Sublevel>
<CompanyName>Babcock&apos;s Music Shop</CompanyName>
<Salutation>Ms.</Salutation>
<FirstName>Bettie</FirstName>
<LastName>Wilson</LastName>
<BillAddress>
<Addr1>Babcock&apos;s Music Shop</Addr1>
<Addr2>Kristie Babcock</Addr2>
<Addr3>10923 Samson Dr.</Addr3>
<City>Millbrae</City>
<State>CA</State>
<PostalCode>94030</PostalCode>
</BillAddress>
<Phone>650-555-2342</Phone>
<AltPhone>650-555-0983</AltPhone>
<Fax>650-555-9823</Fax>
<Email>kbabcock@myemail.com</Email>
<Contact>Kristie Babcock</Contact>
<CustomerTypeRef>
<ListID>10000-933272658</ListID>
<FullName>Commercial</FullName>
</CustomerTypeRef>
<TermsRef>
<ListID>20000-933272658</ListID>
<FullName>Net 15</FullName>
</TermsRef>
<Balance>0.00</Balance>
<TotalBalance>0.00</TotalBalance>
<SalesTaxCodeRef>
<ListID>10000-999022286</ListID>
<FullName>Tax</FullName>
</SalesTaxCodeRef>
<ItemSalesTaxRef>
<ListID>2E0000-933272656</ListID>
<FullName>San Tomas</FullName>
</ItemSalesTaxRef>
<JobStatus>None</JobStatus>
</CustomerRet>
</CustomerQueryRs>
</QBXMLMsgsRs>
</QBXML>
</response><hresult /><message /></receiveResponseXML></soap:Body></soap:Envelope>
rposborne commented 12 years ago

Same thing for Nokogiri

NoMethodError (undefined method empty?' for #<Nokogiri::XML::Document:0x007fd302dd1cb0>): lib/etc/qbwc_supervisor.rb:32:inreceiveResponseXML' app/controllers/quickbooks_controller.rb:58:in `api'

skryl commented 12 years ago

You are correct. You should only be passing in the raw QBXML string. The top level element has to be . Also make sure you strip the xml version header.

skryl commented 12 years ago

works for me btw

ruby-1.9.2-p290 :006 > h = a.qbxml_to_hash(@xml) => {"xml_attributes"=>{"requestID"=>"1", "statusCode"=>"0", "statusSeverity"=>"Info", "statusMessage"=>"Status OK"}, "customer_ret"=>[{"xml_attributes"=>{}, "list_id"=>"800000DC-1418660962", "time_created"=>"2014-12-15T10:29:22-06:00", "time_modified"=>"2014-12-15T10:29:22-06:00", "edit_sequence"=>"1418660962", "name"=>"Joe Customer", "full_name"=>"Joe Customer", "is_active"=>false, "sublevel"=>0, "company_name"=>"Joes Garage", "salutation"=>"Mr", "first_name"=>"Joe", "last_name"=>"Customer", "bill_address"=>{"xml_attributes"=>{}, "addr1"=>"123 Main St.", "city"=>"Mountain View", "state"=>"CA", "postal_code"=>"94566"}, "phone"=>"650-944-1111", "alt_phone"=>"650-944-2111", "email"=>"joe@joegargage.com", "terms_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-933272658", "full_name"=>"Net 30"}, "balance"=>0.0, "total_balance"=>0.0, "sales_tax_code_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-999022286", "full_name"=>"Tax"}, "item_sales_tax_ref"=>{"xml_attributes"=>{}, "list_id"=>"2E0000-933272656", "full_name"=>"San Tomas"}, "account_number"=>"89087", "credit_limit"=>2000.0, "job_status"=>"None"}, {"xml_attributes"=>{}, "list_id"=>"800000DD-1418660962", "time_created"=>"2014-12-15T10:29:22-06:00", "time_modified"=>"2014-12-15T10:29:22-06:00", "edit_sequence"=>"1418660962", "name"=>"Equipment Installation", "full_name"=>"Joe Customer:Equipment Installation", "is_active"=>false, "parent_ref"=>{"xml_attributes"=>{}, "list_id"=>"800000DC-1418660962", "full_name"=>"Joe Customer"}, "sublevel"=>1, "balance"=>0.0, "total_balance"=>0.0, "sales_tax_code_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-999022286", "full_name"=>"Tax"}, "item_sales_tax_ref"=>{"xml_attributes"=>{}, "list_id"=>"2E0000-933272656", "full_name"=>"San Tomas"}, "job_status"=>"Awarded", "job_start_date"=>"2001-03-01T00:00:00-06:00", "job_projected_end_date"=>"2001-12-01T00:00:00-06:00", "job_end_date"=>"2001-12-15T00:00:00-06:00", "job_desc"=>"Install new smog equipment"}, {"xml_attributes"=>{}, "list_id"=>"150000-933272658", "time_created"=>"1999-07-29T14:24:18-05:00", "time_modified"=>"2013-12-14T23:23:13-06:00", "edit_sequence"=>"1387084993", "name"=>"Abercrombie, Kristy", "full_name"=>"Abercrombie, Kristy", "is_active"=>false, "sublevel"=>0, "salutation"=>"Mrs.", "first_name"=>"Kristy", "last_name"=>"Abercrombie", "bill_address"=>{"xml_attributes"=>{}, "addr1"=>"Kristy Abercrombie", "addr2"=>"5647 Cypress Hill Rd", "city"=>"Bayshore", "state"=>"CA", "postal_code"=>"94326"}, "ship_address"=>{"xml_attributes"=>{}, "addr1"=>"Kristy Abercrombie", "addr2"=>"5647 Cypress Hill Rd", "city"=>"Bayshore", "state"=>"CA", "postal_code"=>"94326"}, "phone"=>"415-555-6579", "email"=>"kristy@samplename.com", "contact"=>"Kristy Abercrombie", "alt_contact"=>"Steve Darcangelo", "customer_type_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Residential"}, "terms_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-933272658", "full_name"=>"Net 30"}, "balance"=>0.0, "total_balance"=>0.0, "sales_tax_code_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-999022286", "full_name"=>"Tax"}, "item_sales_tax_ref"=>{"xml_attributes"=>{}, "list_id"=>"2E0000-933272656", "full_name"=>"San Tomas"}, "account_number"=>"91-431", "job_status"=>"None", "job_start_date"=>"2007-09-23T00:00:00-05:00", "job_projected_end_date"=>"2007-09-23T00:00:00-05:00", "job_end_date"=>"2007-09-23T00:00:00-05:00", "notes"=>"9/15/2003: Send Kristy estimate for den remodel.\n\n9/20/2003: Called Kristy to discuss job: Kristy is not interested at this\ntime. Estimate was competitive, not using another firm.\n\n10/15/2003: Further discussion of bathroom remodel. I offered 10% discount on\nproject if she would sign the contract now."}, {"xml_attributes"=>{}, "list_id"=>"160000-933272658", "time_created"=>"1999-07-29T14:24:18-05:00", "time_modified"=>"2013-12-14T23:23:13-06:00", "edit_sequence"=>"1387084993", "name"=>"Family Room", "full_name"=>"Abercrombie, Kristy:Family Room", "is_active"=>false, "parent_ref"=>{"xml_attributes"=>{}, "list_id"=>"150000-933272658", "full_name"=>"Abercrombie, Kristy"}, "sublevel"=>1, "salutation"=>"Mrs.", "first_name"=>"Kristy", "last_name"=>"Abercrombie", "bill_address"=>{"xml_attributes"=>{}, "addr1"=>"Kristy Abercrombie", "addr2"=>"5647 Cypress Hill Rd", "city"=>"Bayshore", "state"=>"CA", "postal_code"=>"94326"}, "ship_address"=>{"xml_attributes"=>{}, "addr1"=>"Kristy Abercrombie", "addr2"=>"5647 Cypress Hill Rd", "city"=>"Bayshore", "state"=>"CA", "postal_code"=>"94326"}, "phone"=>"415-555-6579", "email"=>"kristy@samplename.com", "contact"=>"Kristy Abercrombie", "customer_type_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Residential"}, "terms_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-933272658", "full_name"=>"Net 30"}, "balance"=>0.0, "total_balance"=>0.0, "item_sales_tax_ref"=>{"xml_attributes"=>{}, "list_id"=>"2E0000-933272656", "full_name"=>"San Tomas"}, "job_status"=>"Closed", "job_desc"=>"Remodel family room: Drywall, re-carpet, add fireplace.", "job_type_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Remodel"}}, {"xml_attributes"=>{}, "list_id"=>"170000-933272658", "time_created"=>"1999-07-29T14:24:18-05:00", "time_modified"=>"2013-12-14T23:23:13-06:00", "edit_sequence"=>"1387084993", "name"=>"Kitchen", "full_name"=>"Abercrombie, Kristy:Kitchen", "is_active"=>false, "parent_ref"=>{"xml_attributes"=>{}, "list_id"=>"150000-933272658", "full_name"=>"Abercrombie, Kristy"}, "sublevel"=>1, "salutation"=>"Mrs.", "first_name"=>"Kristy", "last_name"=>"Abercrombie", "bill_address"=>{"xml_attributes"=>{}, "addr1"=>"Kristy Abercrombie", "addr2"=>"5647 Cypress Hill Rd", "city"=>"Bayshore", "state"=>"CA", "postal_code"=>"94326"}, "ship_address"=>{"xml_attributes"=>{}, "addr1"=>"Kristy Abercrombie", "addr2"=>"5647 Cypress Hill Rd", "city"=>"Bayshore", "state"=>"CA", "postal_code"=>"94326"}, "phone"=>"415-555-6579", "email"=>"kristy@samplename.com", "contact"=>"Kristy Abercrombie", "customer_type_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Residential"}, "terms_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-933272658", "full_name"=>"Net 30"}, "balance"=>0.0, "total_balance"=>0.0, "item_sales_tax_ref"=>{"xml_attributes"=>{}, "list_id"=>"2E0000-933272656", "full_name"=>"San Tomas"}, "job_status"=>"Pending", "job_desc"=>"Fire restoration of kitchen: Replace counter, dishwasher, oven and\npaint.", "job_type_ref"=>{"xml_attributes"=>{}, "list_id"=>"30000-933272658", "full_name"=>"Repairs"}}, {"xml_attributes"=>{}, "list_id"=>"180000-933272658", "time_created"=>"1999-07-29T14:24:18-05:00", "time_modified"=>"2013-12-14T23:23:13-06:00", "edit_sequence"=>"1387084993", "name"=>"Remodel Bathroom", "full_name"=>"Abercrombie, Kristy:Remodel Bathroom", "is_active"=>false, "parent_ref"=>{"xml_attributes"=>{}, "list_id"=>"150000-933272658", "full_name"=>"Abercrombie, Kristy"}, "sublevel"=>1, "company_name"=>"Kristy Abercrombie", "salutation"=>"Mrs.", "first_name"=>"Kristy", "last_name"=>"Abercrombie", "bill_address"=>{"xml_attributes"=>{}, "addr1"=>"Kristy Abercrombie", "addr2"=>"5647 Cypress Hill Rd", "city"=>"Bayshore", "state"=>"CA", "postal_code"=>"94326"}, "phone"=>"415-555-6579", "email"=>"kristy@samplename.com", "contact"=>"Kristy Abercrombie", "customer_type_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Residential"}, "terms_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-933272658", "full_name"=>"Net 30"}, "balance"=>0.0, "total_balance"=>0.0, "item_sales_tax_ref"=>{"xml_attributes"=>{}, "list_id"=>"2E0000-933272656", "full_name"=>"San Tomas"}, "job_status"=>"InProgress", "job_start_date"=>"2014-10-23T00:00:00-05:00", "job_projected_end_date"=>"2014-12-11T00:00:00-06:00", "job_end_date"=>"2014-12-23T00:00:00-06:00", "job_desc"=>"Remodel master bathroom: Build new counter, Replace fixtures, Add\nwhirlpool.", "job_type_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Remodel"}}, {"xml_attributes"=>{}, "list_id"=>"800000D0-1182061376", "time_created"=>"2007-06-17T02:22:56-05:00", "time_modified"=>"2013-12-14T23:23:13-06:00", "edit_sequence"=>"1387084993", "name"=>"Allard, Robert", "full_name"=>"Allard, Robert", "is_active"=>false, "sublevel"=>0, "salutation"=>"Mrs.", "first_name"=>"Amanda", "last_name"=>"Roberts", "bill_address"=>{"xml_attributes"=>{}, "addr1"=>"Robert Allard", "addr2"=>"92834 Chandler St.", "city"=>"Millbrae", "state"=>"CA", "postal_code"=>"94030"}, "ship_address"=>{"xml_attributes"=>{}, "addr1"=>"Robert Allard", "addr2"=>"92834 Chandler St.", "city"=>"Millbrae", "state"=>"CA", "postal_code"=>"94030"}, "phone"=>"650-555-3422", "alt_phone"=>"650-555-8349", "fax"=>"650-555-9804", "email"=>"rallard@myemail.com", "contact"=>"Robert Allard", "alt_contact"=>"Rachel Fisher", "customer_type_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Residential"}, "terms_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Net 15"}, "balance"=>0.0, "total_balance"=>14510.0, "sales_tax_code_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-999022286", "full_name"=>"Tax"}, "item_sales_tax_ref"=>{"xml_attributes"=>{}, "list_id"=>"2E0000-933272656", "full_name"=>"San Tomas"}, "job_status"=>"None"}, {"xml_attributes"=>{}, "list_id"=>"800000D1-1182061396", "time_created"=>"2007-06-17T02:23:16-05:00", "time_modified"=>"2013-12-14T23:23:13-06:00", "edit_sequence"=>"1387084993", "name"=>"Remodel", "full_name"=>"Allard, Robert:Remodel", "is_active"=>false, "parent_ref"=>{"xml_attributes"=>{}, "list_id"=>"800000D0-1182061376", "full_name"=>"Allard, Robert"}, "sublevel"=>1, "salutation"=>"Mrs.", "first_name"=>"Amanda", "last_name"=>"Roberts", "bill_address"=>{"xml_attributes"=>{}, "addr1"=>"Robert Allard", "addr2"=>"92834 Chandler St.", "city"=>"Millbrae", "state"=>"CA", "postal_code"=>"94030"}, "phone"=>"650-555-3422", "alt_phone"=>"650-555-8349", "fax"=>"650-555-9804", "email"=>"rallard@myemail.com", "contact"=>"Robert Allard", "customer_type_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Residential"}, "terms_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Net 15"}, "balance"=>14510.0, "total_balance"=>14510.0, "sales_tax_code_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-999022286", "full_name"=>"Tax"}, "item_sales_tax_ref"=>{"xml_attributes"=>{}, "list_id"=>"2E0000-933272656", "full_name"=>"San Tomas"}, "job_status"=>"None"}, {"xml_attributes"=>{}, "list_id"=>"800000C6-1182059711", "time_created"=>"2007-06-17T01:55:11-05:00", "time_modified"=>"2013-12-14T23:23:13-06:00", "edit_sequence"=>"1387084993", "name"=>"Babcock's Music Shop", "full_name"=>"Babcock's Music Shop", "is_active"=>false, "sublevel"=>0, "company_name"=>"Babcock's Music Shop", "salutation"=>"Ms.", "first_name"=>"Kristie", "last_name"=>"Babcock", "bill_address"=>{"xml_attributes"=>{}, "addr1"=>"Babcock's Music Shop", "addr2"=>"Kristie Babcock", "addr3"=>"10923 Samson Dr.", "city"=>"Millbrae", "state"=>"CA", "postal_code"=>"94030"}, "ship_address"=>{"xml_attributes"=>{}, "addr1"=>"Babcock's Music Shop", "addr2"=>"Kristie Babcock", "addr3"=>"10923 Samson Dr.", "city"=>"Millbrae", "state"=>"CA", "postal_code"=>"94030"}, "phone"=>"650-555-2342", "alt_phone"=>"650-555-0983", "fax"=>"650-555-9823", "email"=>"kbabcock@myemail.com", "contact"=>"Kristie Babcock", "customer_type_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-933272658", "full_name"=>"Commercial"}, "terms_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Net 15"}, "balance"=>0.0, "total_balance"=>0.0, "sales_tax_code_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-999022286", "full_name"=>"Tax"}, "item_sales_tax_ref"=>{"xml_attributes"=>{}, "list_id"=>"2E0000-933272656", "full_name"=>"San Tomas"}, "job_status"=>"None"}, {"xml_attributes"=>{}, "list_id"=>"800000C7-1182059716", "time_created"=>"2007-06-17T01:55:16-05:00", "time_modified"=>"2013-12-14T23:23:13-06:00", "edit_sequence"=>"1387084993", "name"=>"Remodel", "full_name"=>"Babcock's Music Shop:Remodel", "is_active"=>false, "parent_ref"=>{"xml_attributes"=>{}, "list_id"=>"800000C6-1182059711", "full_name"=>"Babcock's Music Shop"}, "sublevel"=>1, "company_name"=>"Babcock's Music Shop", "salutation"=>"Ms.", "first_name"=>"Bettie", "last_name"=>"Wilson", "bill_address"=>{"xml_attributes"=>{}, "addr1"=>"Babcock's Music Shop", "addr2"=>"Kristie Babcock", "addr3"=>"10923 Samson Dr.", "city"=>"Millbrae", "state"=>"CA", "postal_code"=>"94030"}, "phone"=>"650-555-2342", "alt_phone"=>"650-555-0983", "fax"=>"650-555-9823", "email"=>"kbabcock@myemail.com", "contact"=>"Kristie Babcock", "customer_type_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-933272658", "full_name"=>"Commercial"}, "terms_ref"=>{"xml_attributes"=>{}, "list_id"=>"20000-933272658", "full_name"=>"Net 15"}, "balance"=>0.0, "total_balance"=>0.0, "sales_tax_code_ref"=>{"xml_attributes"=>{}, "list_id"=>"10000-999022286", "full_name"=>"Tax"}, "item_sales_tax_ref"=>{"xml_attributes"=>{}, "list_id"=>"2E0000-933272656", "full_name"=>"San Tomas"}, "job_status"=>"None"}]} ruby-1.9.2-p290 :007 > h["customer_ret"].size => 10

skryl commented 12 years ago

qbwc-mini will work ok for simple one time requests BUT... if the response is large enough you will run into HTTP timeouts and other issues. In order to support larger requests you will need some sort of queueing solution which can handle the iteratorRemainingCount attribute sent back by the web connector. Just a heads up.

rposborne commented 12 years ago

Your absolutely right. Especially since i only have a 30 second window from heroku vs. 2 min for QBWC

My Plan was to have a state (pending sync) for each invoice and have it process one at a time. I am only using QBWC as a communication model.

rposborne commented 12 years ago

PS got it working... really hacky but this works for me

     qbxml = "<QBXML>" + doc.split(/\<\/QBXML\>|\<QBXML\>/).second + "</QBXML>"
skryl commented 12 years ago

I threw my implementation up on github. You can try adapting it to your needs or just rip off the QBWC::Session class which handles the iterated requests. Either way here's how to get it to work:

  1. Add a working version of soap4r to your Gemfile
    • gem 'rubyjedi-soap4r', '1.5.8.20100619003610'
  2. Place the qbwc directory in your application's lib/ and make sure qbwc.rb gets loaded during initialization
  3. create a controller and route for qbwc to hit on every request

     class QbwcController < ApplicationController
       def show
         render :text => "This is a SOAP Server"
       end
    
       def create
         req = request
         res = QBWC::Interface.route_request(req)
         render :xml => res, :content_type => 'text/xml'
       end
     end
  4. Edit soap_wrapper/default_servant.rb
    • change credentials in the #authenticate method
    • take a look at sendRequestXML and receiveResponseXML to see how the Session class is used
  5. edit templates.rb
    • the #quickbooks_sync method should return [parser, request_array], request array should contain all requests you want Quickbooks to process. Every request is an array which contains [raw qbxml, response proc]. QBWC::Session has everything you need to understand how it works.

Gluck!

rposborne commented 12 years ago

Looks like another gem of yours plays a substantial role. Active Integration. Which does not seem complete in it's github repo

skryl commented 12 years ago

You can actually ignore it. Just replace the code in the template method with your own. It should just create an array of requests and procs for processing the responses to those requests.

rposborne commented 12 years ago

You say include qbwc.rb but there is no such file in the repo. I have the whole thing just being brought in using rails 3 autoload. But no such luck

NameError (uninitialized constant QBWC::Interface::DefaultMappingRegistry): lib/qbwc/interface.rb:9:in initialize_singleton' lib/qbwc/interface.rb:34:inclass:Interface' lib/qbwc/interface.rb:3:in <top (required)>' app/controllers/quickbooks_controller.rb:33:inapi'

skryl commented 12 years ago

My mistake I was one level too low... pushed up the rest of the repo. Autoload won't work since the classes aren't named right but adding the lines below to your application.rb should do it.

    config.autoload_paths += %W(#{config.root}/lib)
    require "#{config.root}/lib/qbwc/qbwc"
rposborne commented 12 years ago

Working like a charm.