QuickBooks Online provides a way for your app to track different segments of the business apart from a particular client or project. For example, segments of a landscAPIng business could be: landscAPIng, maintenance, design, and overhead. Then, as you create sales and expense transactions, consistently designate the class corresponding to the segment to which they belong. The transactions become organized into segments across income and expenses, providing you a segment-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 segments you wish to track. The examples in this tutorial use the sandbox company.
Tracking business segments and class 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 class tracking available to transactions, you must first enable it.
Preferences.AccountingInfoPrefs.ClassTrackingPerTxn or Preferences.AccountingInfoPrefs.ClassTrackingPerTxnLine to true.
Note
Note
Once class tracking is enabled, build up the list of classes and sub-classes you wish to track.
Going forward, you can add class designations to transactions, either at the line level or transaction level, based on the company file configuration. In the QuickBooks Online API, transactions supporting class tracking provide a ClassRef attribute. In general, follow these steps to track
classes in your transactions with the QuickBooks Online API:
Class.Id and Class.Name for the class 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/<CompanyId>/query?query=select%20%2A%20from%20class |
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | { "QueryResponse": { "Class": [ { "Name": "Landscape", "SubClass": false, "FullyQualifiedName": "Landscape", "Active": true, "domain": "QBO", "sparse": false, "Id": "5000000000000013171", "SyncToken": "0", "MetaData": { "CreateTime": "2016-03-21T14:13:30-07:00", "LastUpdatedTime": "2016-03-21T14:13:30-07:00" } }, { "Name": "Maintenance", "SubClass": false, "FullyQualifiedName": "Maintenance", "Active": true, "domain": "QBO", "sparse": false, "Id": "5000000000000013172", "SyncToken": "0", "MetaData": { "CreateTime": "2016-03-21T14:13:41-07:00", "LastUpdatedTime": "2016-03-21T14:13:41-07:00" } }, { "Name": "Overhead", "SubClass": false, "FullyQualifiedName": "Overhead", "Active": true, "domain": "QBO", "sparse": false, "Id": "5000000000000013174", "SyncToken": "0", "MetaData": { "CreateTime": "2016-03-21T15:57:06-07:00", "LastUpdatedTime": "2016-03-21T15:57:06-07:00" } }, { "Name": "Sales", "SubClass": false, "FullyQualifiedName": "Sales", "Active": true, "domain": "QBO", "sparse": false, "Id": "5000000000000013173", "SyncToken": "0", "MetaData": { "CreateTime": "2016-03-21T14:13:51-07:00", "LastUpdatedTime": "2016-03-21T14:13:51-07:00" } } ], "startPosition": 1, "maxResults": 4, "totalCount": 4 }, "time": "2016-03-22T09:27:59.236-07:00" } |
ClassRef attribute with values from the Class object you obtained in the last step. Set ClassRef.value to Class.Id and ClassRef.name to Class.NameHere is a visual representation using the QuickBooks Online API to set a line-level class in an Invoice object and how it relates to the UI. Class tracking is configured as follows:
Preferences.AccountingInfoPrefs.ClassTrackingPerTxn set to false.Preferences.AccountingInfoPrefs.ClassTrackingPerTxnLine set to true.
Here is a visual representation using the QuickBooks Online API to set a transaction-level class in an Invoice object and how it relates to the UI. Class tracking is configured as follows:
Preferences.AccountingInfoPrefs.ClassTrackingPerTxn set to true.Preferences.AccountingInfoPrefs.ClassTrackingPerTxnLine set to false.
The QuickBooks Online API provides the Sales by Class report API, presenting a summary of how class tracking breaks down across all the transactions.
View the Class API reference here.