QuickBooks Desktop is a software of managing accounting related stuff, which is more powerful and easy to handle for accounting person or non-accounting person. The purpose of integrating QuickBooks desktop with rails application is to send accounting related data over QuickBooks desktop from our rails application.
INSTALL QBWC GEM TO RAILS APP :
Run the generator
$ rails g qbwc:install
Then the migrations
Generator will create some files and migration will create some tables into your rails application. Among these config/initializers/qbwc.rb file needs to be configured according to your requirement., that’s why assume that QuickBooks desktop will be used by single user/account and single company file for QuickBooks desktop. If we want multiple users and multiple company files then the above config file needs to be configured properly.Quickbooks requires HTTPS connections when connecting to remote machines. ngrok may be useful to fulfill this requirement.
GENERATE QWC FILE:
Previously we said that we need to add a communicator file which will be added to the QBWC application to communicate to our rails application. To get this file we need to add a link into our application page which is ‘application_domain/qbwc/qwc’. This path is already entered into the routes.rb file when we execute command ‘$ rails g qbwc:install’ . Now after downloading the file we need to add that file to the QBWC application.Now our integration is ready to exchange data between QuickBooks desktop and our rails application
CREATING WORKER FILE:
We need to create specific worker file for specific task. Like, if we want to export/import chart of account, then we need to create two specific worker file, one for importing and one for exporting. Also we need to create separate worker file for updating the QuickBooks list/transaction data. basic operation for importing and exporting of COA (chart of account).To perform this action we need to create two worker files into rails app under application_root/app/workers directory.
$ cd application_root/app
$ mkdir workers
$ touch import_coa_worker.rb
$ touch export_coa_worker.rb
UNDERSTANDING A WORKER FILE:
Every worker file extends QBWC::Worker class and has 3 primary methods.
requests: process the request data, and returns a hash or array of hashes which QuickBooks desktop will process
should_run? : returns a boolean whether the jobs should run. Job can be stopped based on some conditions here.
handle_response: returns the processed data from QuickBooks desktop