Reputation: 60
I am a python developer, not a QB user, so please forgive me for using poor terminology.
We have an internal web application that is used by finance staff to identify small sets of payment requests for a particular payee. They then use QB to generate a check to pay that payee. Then they manually enter the check number and date back into the web app. I am modifying the web application so that the finance staff can use the app to bundle the payment requests together and - I hope - send a request to QB for the checks, one per payee. The data to send would be the payee information, the check amount, and whatever else is required. The data to get back from QB (later) would be the check number and check date and some identifier that I can use to match it up with the requests sent earlier.
What is the best way to implement this communication with QB?
Upvotes: 0
Views: 510
Reputation: 215
I use python3, to construct qbXML queries, and Elementree to parse the responses. I use a non-Windows machine for developement, too. I found that I really needed QB and Python together in a Windows VM to make progress. Both QB and COM require it.
Here are a couple snippets in Python 3.1 to show how I do it:
First, use COM to connect to QuickBooks and disconnect from QuickBooks.
import win32com.client
def start(external_application_name):
"""Connect a QuickBooks instance using COM. Start QB if needed"""
SessionManager = win32com.client.Dispatch("QBXMLRP2.RequestProcessor")
# Example only - insecure!
SessionManager.OpenConnection('', external_application_name)
return SessionManager
def stop(SessionManager):
"""Disconnect from the existing Quickbooks instance."""
SessionManager.CloseConnection()
return
Next, I use python to do the logic, construct the qbXML queries, and parse the responses into an ElementTree.
import xml.etree.ElementTree as etree
def xml_query(QB_SessionManager, company_file_path, qbXML_query_string):
"""
Do a QuickBooks QBXML query.
The query must be valid - this function doesn't do error checking.
Return an ElementTree of the XML response.
"""
ticket = QB_SessionManager.BeginSession(company_file_path, 0)
response_string = QB_SessionManager.ProcessRequest(ticket, qbXML_query_string)
#print(response_string) # Debug tool
SessionManager.EndSession(ticket)
QBXML = etree.fromstring(response_string)
response_tree = QBXML.find('QBXMLMsgsRs')
#etree.dump(QBXML) # Debug tool
return response_tree
The actual qbXML query string and response string for a check query are on the qbXML reference at https://member.developer.intuit.com/qbSDK-current/Common/newOSR/index.html There, you will see that you can download the check data filtered by payee, date range, check number range, etc.
You can chain multiple XML queries or transactions into a single large XML file. Assign each a unique request number (Example: <CustomerQueryRq requestID="1">
), so you can locate the proper response.
Use the <IncludeRetElement>
tag to limit the reply size, and speed the search tremendously.
Upvotes: 2
Reputation: 5340
As your app is not a SaaS app, so you can use qbsdk for this use case. sdk download link - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits
IIF files are no longer supported. IIF files can be imported directly into QB, but it would bypass all the business logic.
Upvotes: 1