QuickBooks Desktop is a software for managing accounting-related stuff, which is more powerful and easy to handle for accounting persons or non-accounting persons. 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
The generator will create some files and migration will create some tables into your rails application. Among these config/initializers/qbwc.rb files needs to be configured according to your requirement., that’s why to 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 that 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 a specific worker file for specific tasks. Like, if we want to export/import a chart of account, then we need to create two specific worker files, one for importing and one for exporting. Also, we need to create a separate worker files 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 the 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. The job can be stopped based on some conditions here.
- handle_response: returns the processed data from QuickBooks desktop