QuickBooks Online’s location tracking feature can help your app track transactions across different business units (such as different properties, stores, regions, etc.) apart from a particular client or project.
To use location tracking, simply designate a business unit when you create sales and expense transactions. They automatically get organized into the units you specify across income and expenses, providing you a unit-wide view of your business.
To follow along, you’ll need a sandbox or another QuickBooks company populated with a chart of accounts, customers, and items, as well as a list of business units you wish to track. The examples in this tutorial use the sandbox company.
Tracking business units, and location tracking in general is available with QuickBooks Online Plus, only. To determine the edition type with the QuickBooks Online API, query the value of the CustomerInfo.Name
name/value pair, OfferingSku
. The example below is excerpted from the
CompanyInfo object where the value is set to QuickBooks Online Plus
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | { "CompanyInfo": { "CompanyName": "Sandbox Company_US_3", "LegalName": "Sandbox Company_US_3", ... "NameValue": [ ... { "Name": "OfferingSku", "Value": "QuickBooks Online Plus" }, ... ], ... "Id": "1", "SyncToken": "7", "MetaData": { "CreateTime": "2015-05-22T01:37:33-07:00", "LastUpdatedTime": "2016-03-21T12:21:13-07:00" } }, "time": "2016-03-21T12:36:49.015-07:00" } |
In order to have location tracking available to transactions, you must first enable it—either from the UI or the API.
Preferences.AccountingInfoPrefs.TrackDepartments
to true
, andPreferences.AccountingInfoPrefs.DepartmentTerminology
to one of Business
, Department
, Division
, Location
, Property
, Store
, or Territory
.Once location tracking is enabled, build up the list of locations you wish to track.
Going forward, you can add location designations to transactions. In the QuickBooks Online API, transactions supporting location tracking provide a DepartmentRef
attribute. In general, follow these steps to track locations in your transactions with the QuickBooks Online API:
Department.Id
and Department.Name
for the location you wish to use in the transaction; you need these in the next section
when you create the transaction.
1 | GET https://QuickBooks.API.intuit.com/v3/company/<realmId>/query?query=select%20%2A%20from%20department |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | { "QueryResponse": { "Department": [ { "Name": "Garden Services", "SubDepartment": false, "FullyQualifiedName": "Garden Services", "Active": true, "domain": "QBO", "sparse": false, "Id": "1", "SyncToken": "0", "MetaData": { "CreateTime": "2013-12-31T14:35:44-08:00", "LastUpdatedTime": "2013-12-31T14:35:44-08:00" } }, { "Name": "Marketing Department", "SubDepartment": false, "FullyQualifiedName": "Marketing Department", "Active": true, "domain": "QBO", "sparse": false, "Id": "3", "SyncToken": "0", "MetaData": { "CreateTime": "2015-07-23T12:54:44-07:00", "LastUpdatedTime": "2015-07-23T12:54:44-07:00" } }, { "Name": "Sales Department", "SubDepartment": false, "FullyQualifiedName": "Sales Department", "Active": true, "domain": "QBO", "sparse": false, "Id": "2", "SyncToken": "0", "MetaData": { "CreateTime": "2015-07-23T12:53:47-07:00", "LastUpdatedTime": "2015-07-23T12:53:47-07:00" } } ], "startPosition": 1, "maxResults": 3 }, "time": "2016-09-15T13:53:00.442-07:00" } |
DepartmentRef.value
to Department.Id
and DepartmentRef.name
to Department.Name
Here is a visual representation using the QuickBooks Online API to set a location in an Invoice object and how it relates to the UI. Location tracking is configured as follows:
Preferences.AccountingInfoPrefs.TrackDepartments
set to true.Preferences.AccountingInfoPrefs.DepartmentTerminology
set to Business
.The QuickBooks Online API provides the Sales by Department report API, presenting a summary of how location tracking breaks down across all transactions.
View the Department API reference here.