Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Automate Tedious QuickBooks Tasks with COM-based API

Learn how to programmatically control QuickBooks using the COM-based QuickBooks SDK 5.0. You'll be able to free yourself from those time-consuming, repetitive QuickBooks tasks.


advertisement
f you are a part of a small business, either you or someone at your organization likely deals with QuickBooks. QuickBooks is the most broadly used accounting software in the small business arena. It is easy to use and has the basic functionality to satisfy the accounting needs of most small businesses.

The user operates QuickBooks on either the Windows or Macintosh platform via a graphical user interface (GUI) and can achieve most of what he needs for his business through this GUI. As the business grows, however, the owner or accountant of the business will bump into the problem of getting bogged down with certain QuickBooks tasks that are tedious and repetitive in nature.

An example of this problem is the process of moving a large number of bill line items from one account to another, such as merging two accounts for a particular expense or class of expenses into one account. The bill line items in question might have been classified under account #1 at one time and under account #2 at another time, whether by two different people or even the same person. If you try it, you will see that although QuickBooks allows you to rename an account and also to find all transactions (income or expense) in a given account, it does not allow you to find all or some bill line items in one account and move them into another account in one batch. Eventually Intuit may add this functionality, but some other function probably will always be missing and its omission will result in unnecessarily tedious procedures to accomplish basic tasks.



The way to overcome this inefficiency problem is to programmatically control QuickBooks. For several years now, COM has enabled you to control QuickBooks under Windows with the Win32 API. The automation interface has been getting richer each year and is reasonably feature-rich and capable in its latest incarnation, the QuickBooks SDK 5.0. The SDK includes library files exposing the API to control QuickBooks and tools for developing with and using the API.

Under the Hood of the QuickBooks API

The QuickBooks API has two means of access: via the Microsoft Foundation Classes (MFC) and via qbXML. Both of them are built upon the COM foundation. You can use either MFC or qbXML to communicate with and control QuickBooks. This article discusses qbXML because it is cross-platform and thus can work on Windows, Mac, and Linux. Once you know qbXML, it is very easy to use the QuickBooks MFC interface because the MFC interface is essentially the same as the qbXML interface, except it uses COM as the communications method instead of XML message-passing.

If you use Visual Basic or C#, you should look at using the MFC interface after going through the examples in this article because although the MFC interface lacks cross-platform portability and limits you to the Windows platform, if you already use Windows and plan to use nothing else, MFC makes development easier through programmer productivity-enhancing features such as IntelliSense and tight integration with Visual Studio or whichever IDE you use.

Solving the QuickBooks Inefficiency Problem

To see how you can solve the tedious task problem introduced previously, begin by downloading and installing the following in order:
  1. If you do not already have QuickBooks, you can purchase it from http://quickbooks.intuit.com. This article assumes you are running at least QuickBooks Pro 2004. Anything newer is also fine. This article also assumes that you are running the U.S. edition of QuickBooks. There are differences between the U.S. edition and internationalized editions, and the examples in this article may not work on editions other than the U.S. edition.
  2. Install the QuickBooks SDK 5.0 on the machine where QuickBooks runs. Make sure you choose to install Remote Data Sharing (RDS) as part of the QuickBooks SDK installation. The RDS option appears at the end of the installation as a checkbox labeled "Configure Remote Data Sharing on this machine." By default it is on, so all you have to do is leave the checkbox checked. RDS allows you to control QuickBooks from another machine. The SDK needs to be running on the server where QuickBooks runs. The SDK also needs to be running on the client if you want to use the MFC interface. If you are going to use the SOAP web service interface via Remote Data Sharing (RDS), you do not have to install the SDK on the client. You do not need QuickBooks running on the client whether you use the MFC interface or qbXML interface.
  3. The example in this article describes controlling QuickBooks from an application on the same machine as QuickBooks because that is simpler to set up. An upcoming related but separate article will describe remote control of QuickBooks from an application on a networked computer, which is more complex, but is likely to be the scenario under which you would operate for security reasons. It is also the scenario under which you would operate in order to interoperate with Linux (e.g. a web application running on Linux invokes QuickBooks running on Windows to retrieve invoice data).
  4. Download ActiveState Perl. It is a free download. This article assumes ActivePerl 5.8.7 build 815, but later versions are fine and even some earlier versions are fine. This article uses Perl because it is cross-platform and has a nice library of pre-built code called CPAN (Comprehensive Perl Archive Network). The library includes code for processing XML and communicating via SOAP to a web service, both tasks you will need to perform in the following example.
  5. Install the XML::LibXML and XML::LibXSLT modules by running the Perl Package Manager from the ActivePerl start menu group. You should see a command line interface. Follow these steps:
    • Type "repository add theoryx5 http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58"
    • Type "install XML::LibXML"
      If the Perl Package Manager returns a list of results and asks you which match to install, type install XML::LibXML 1, which will tell PPM to install the first match, which should be XML-LibXML.
    • During the installation of XML::LibXML, if PPM asks if it should fetch dependencies, answer yes (usually you can do this by pressing enter to accept the default answer). You can also accept the defaults for the file locations if you need to install dependencies.
    • Type "install XML::LibXSLT"
      Again, accept the defaults when PPM asks whether to fetch dependencies and where to place the fetched dependencies.
    Once you have installed the XML modules for Perl, type quit at the prompt to exit the Perl Package Manager. You will use the XML and XSLT libraries to manipulate XML data for both generating requests to QuickBooks and processing responses from QuickBooks.
  6. Download the accompanying example code for this article. It includes XML files, Perl code, and a QuickBooks company file to serve as sample data.

Make sure you have taken all these steps before proceeding.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap