This topic provides information about the QuickBooks Online API sales tax model for non-US integrations. For US sales tax integrations, click here.
Sales transactions (such as Invoices and SalesReceipts) and expense transactions (such as Bills and PurchaseOrders) represent sales taxes both collected and paid. They use TaxCode objects to specify sales tax at the line level so that QuickBooks Online knows the tax rate to use when calculating taxes.
TaxRate and TaxAgency objects, while not used directly in transactions, are used in TaxCode definitions.
To follow along, you’ll need a sandbox or another QuickBooks company populated with a chart of accounts, customers, vendors, and invoices. The examples in this tutorial use the sandbox company.
The table below summarizes the resources comprising the non-US sales tax model.
Tax Item | Resource | Description |
Tax code | TaxCode | Defines a tax code comprised of one or more tax rates. For example, the tax code Sales Transaction entities:
Purchase Transaction entities:
|
Tax rate | TaxRate | Defines the tax rate of an individual tax agency. Use the TaxService endpoint to create a TaxRate object. |
Tax agency | TaxAgency | Defines display names for individual tax agencies supported by your QuickBooks company file. Use the TaxAgency endpoint, itself, to create and maintain tax agencies. |
For each sales item line subject to sales tax, set its SalesItemLineDetail.TaxCodeRef
attribute to reference the applicable TaxCode object. When creating or updating sales transactions, QuickBooks Online automatically calculates tax and returns the amount in the
TxnTaxDetail.TotalTax
attribute of the transaction based on the TaxCode assigned to each line.
Note
Note
The QuickBooks company must be enabled to use sales tax.
Preferences.TaxPrefs.UsingSalesTax
attribute is set to true
.The Invoice create request below includes three lines, a sales tax code is specified for each individual line as follows.
Exempt From VAT
(TaxCode ID=2), Constituent tax rate is ES
(TaxRate ID=2)20.0% S
(TaxCode ID=3), Constituent tax rate is SS-20.0
(TaxRate ID=4)20.0% S
(TaxCode ID=3), Constituent tax rate is SS-20.0
(TaxRate ID=4)
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 67 68 69 70 71 72 73 74 75 76 | { "Line": [ { "Id": "1", "LineNum": 1, "Description": "Holiday party - gold level", "Amount": 2000.0, "DetailType": "SalesItemLineDetail", "SalesItemLineDetail": { "ItemRef": { "value": "7", "name": "Holiday party:Gold party" }, "UnitPrice": 2000, "Qty": 1, "TaxCodeRef": { "value": "2" } } }, { "Id": "2", "LineNum": 2, "Description": "Entertainment for the event", "Amount": 1000.0, "DetailType": "SalesItemLineDetail", "SalesItemLineDetail": { "ItemRef": { "value": "6", "name": "General services:Entertainment" }, "UnitPrice": 1000, "Qty": 1, "TaxCodeRef": { "value": "3" } } }, { "Id": "3", "LineNum": 3, "Description": "Entertainment for the event", "Amount": 1400.0, "DetailType": "SalesItemLineDetail", "SalesItemLineDetail": { "ItemRef": { "value": "6", "name": "General services:Entertainment" }, "UnitPrice": 1400, "Qty": 1, "TaxCodeRef": { "value": "3" } } }, { "Amount": 3000.0, "DetailType": "SubTotalLineDetail", "SubTotalLineDetail": {} }], "CustomerRef": { "value": "1" } } |
Here is the corresponding response from the above request. A overall transaction sales tax of 480.00 GBP is calculated by QuickBooks Online and returned in TxnTaxDetail.TotalTax
. In addition, the response contains a TxnTaxDetail.TaxLine
element detailing how the sales tax breaks down into
its constituent parts. There is one TaxLine
entry for each tax rate represented in the request; multiple occurrences of a tax rate are aggregated into one entry. So, this response contains two TxnTaxDetail.TaxLine
elements: one for tax in line 1 and one that combines tax in line 2 and 3
(since these two lines specify the same tax code). Some content has been omitted in order to showcase sales tax attributes.
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | { { "Invoice": { ... "CurrencyRef": { "value": "GBP", "name": "British Pound Sterling" }, "ExchangeRate": 1, "LinkedTxn": [], "Line": [ { "Id": "1", "LineNum": 1, "Description": "Holiday party - gold level", "Amount": 2000.0, "DetailType": "SalesItemLineDetail", "SalesItemLineDetail": { "ItemRef": { "value": "7", "name": "Holiday party:Gold party" }, "UnitPrice": 2000, "Qty": 1, "TaxCodeRef": { "value": "2" } } }, { "Id": "2", "LineNum": 2, "Description": "Entertainment for the event", "Amount": 1000.0, "DetailType": "SalesItemLineDetail", "SalesItemLineDetail": { "ItemRef": { "value": "6", "name": "General services:Entertainment" }, "UnitPrice": 1000, "Qty": 1, "TaxCodeRef": { "value": "3" } } }, { "Id": "3", "LineNum": 3, "Description": "Entertainment for the event", "Amount": 1400.0, "DetailType": "SalesItemLineDetail", "SalesItemLineDetail": { "ItemRef": { "value": "6", "name": "General services:Entertainment" }, "UnitPrice": 1400, "Qty": 1, "TaxCodeRef": { "value": "3" } } }, { "Amount": 4400.0, "DetailType": "SubTotalLineDetail", "SubTotalLineDetail": {} }], "TxnTaxDetail": { "TotalTax": 480.0, "TaxLine": [ { "Amount": 0, "DetailType": "TaxLineDetail", "TaxLineDetail": { "TaxRateRef": { "value": "2" }, "PercentBased": true, "TaxPercent": 0, "NetAmountTaxable": 2000.0 } }, { "Amount": 480.0, "DetailType": "TaxLineDetail", "TaxLineDetail": { "TaxRateRef": { "value": "4" }, "PercentBased": true, "TaxPercent": 20, "NetAmountTaxable": 2400.0 } }] }, "CustomerRef": { "value": "1", "name": "Adwin Ko" }, ... }, "time": "2017-09-18T10:43:20.143-07:00" } } |
To override automatic sales tax calculation for a given tax rate, supply a TxnTaxDetail
element in the create request with the following fields set:
TxnTaxDetail.TotalTax
—the new total tax amount.TxnTaxDetail.TaxLine.TaxLineDetail.TaxRateRef
—the tax rate that is overridden. You must send all TaxRateRefs of a TaxCode even if you are modifying just one of them.TxnTaxDetail.TaxLine.Amount
—The amount of tax contributed by the tax rate.TxnTaxDetail.TaxLine.TaxLineDetail.TaxPercent
—The new tax percent to use.A QuickBooks company file comes pre-populated with tax rates. Some tax rates are non-editable and an attempt to override them generates a business validation error. Non-editable tax rates are those whose TaxRate.DisplayType
attribute is set to ReadOnly
.
1 2 3 4 5 6 7 8 9 10 11 12 | { "Fault": { "Error": [{ "Message": "A business validation error has occurred while processing your request", "Detail": "Business Validation Error: Unexpected Internal Error. (-37100)", "code": "6000", "element": "" }], "type": "ValidationFault" }, "time": "2015-09-30T09:07:35.030-07:00" } |
The sample Invoice create request below overrides the 20% rate defined by the 20.0% S tax code with 10%. A sales tax of £8.90 is applied to the £89.00 sales amount thus suppressing QuickBooks Online automatic sales tax calculation. .
TxnTaxDetail.TotalTax
attribute explicitly defines £8.90 total tax.TxnTaxDetail.TaxLine.TaxLineDetail.TaxRateRef
attribute specifies the tax rate to be overridden.TxnTaxDetail.TaxLine.Amount
attribute explicitly defines £8.90 total tax.TxnTaxDetail.TaxLine.TaxLineDetail.TaxPercent
attribute explicitly defines the 10.0% tax rate.
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 | { "Line": [{ "Amount": 89.00, "DetailType": "SalesItemLineDetail", "SalesItemLineDetail": { "ItemRef": { "value": "18", "name": "Name Badges" }, "Qty": 5, "TaxCodeRef": { "value": "3", "name": "20.0% S" } } }], "TxnTaxDetail": { "TaxLine": [{ "Amount": 8.90, "DetailType": "TaxLineDetail", "TaxLineDetail": { "TaxRateRef": { "value": "4", "name": "SS-20.0" }, "PercentBased": true, "TaxPercent": 10.0, "NetAmountTaxable": 89.0 } }], "TotalTax": 8.9 }, "CustomerRef": { "value": "1" } } |
Here is the corresponding response from the above request. Some content has been omitted in order to showcase sales tax attributes.
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 | { "Invoice": { ... "Line": [{ "Id": "1", "LineNum": 1, "Amount": 89.0, "DetailType": "SalesItemLineDetail", "SalesItemLineDetail": { "ItemRef": { "value": "18", "name": "Name Badges" }, "Qty": 5, "TaxCodeRef": { "value": "3" } } }, { "Amount": 89.0, "DetailType": "SubTotalLineDetail", "SubTotalLineDetail": {} }], "TxnTaxDetail": { "TotalTax": 8.9, "TaxLine": [{ "Amount": 8.9, "DetailType": "TaxLineDetail", "TaxLineDetail": { "TaxRateRef": { "value": "4" }, "PercentBased": true, "TaxPercent": 20, "NetAmountTaxable": 89.0 } }] }, "CustomerRef": { "value": "1", "name": "Adwin Ko" }, ... "GlobalTaxCalculation": "TaxExcluded", "TotalAmt": 97.9, "HomeTotalAmt": 97.9, "PrintStatus": "NeedToPrint", "EmailStatus": "NotSet", "Balance": 97.9 }, "time": "2015-09-29T14:49:17.397-07:00" } |
For each purchase item line subject to purchase tax, set its PurchaseItemLineDetail.TaxCodeRef
attribute to reference the applicable TaxCode object. When creating or updating purchase transactions, QuickBooks Online automatically calculates tax and returns the amount in the
TxnTaxDetail.TotalTax
attribute of the transaction based on the TaxCode assigned to each line.
In the Bill create request below, purchase tax is calculated using the rate defined by the GST on non-cAPItal
TaxCode definition.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | { "Line": [{ "Id": "1", "Amount": 200.0, "DetailType": "AccountBasedExpenseLineDetail", "AccountBasedExpenseLineDetail": { "AccountRef": { "value": "93", "name": "Janitorial Expense" }, "BillableStatus": "NotBillable", "TaxCodeRef": { "value": "2", "name": "GST on non-cAPItal" } } }], "VendorRef": { "value": "37", "name": "Jennifer Hargreaves" }, "GlobalTaxCalculation": "TaxExcluded" } |
Here is the corresponding response from the above request. A transaction tax of $20.00 is calculated by QuickBooks Online and returned in TxnTaxDetail.TotalTax
. In addition, the response contains a TxnTaxDetail.TaxLine
attribute detailing how the purchase tax breaks down into its constituent
parts, based on the the GST on non-cAPItal
TaxCode definition. Some content has been omitted in order to showcase purchase tax attributes.
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 | { "Bill": { ... "Line": [{ "Id": "1", "Amount": 200.0, "DetailType": "AccountBasedExpenseLineDetail", "AccountBasedExpenseLineDetail": { "AccountRef": { "value": "93", "name": "Janitorial Expense" }, "BillableStatus": "NotBillable", "TaxCodeRef": { "value": "2" } } }], "TxnTaxDetail": { "TotalTax": 20.0, "TaxLine": [{ "Amount": 20.0, "DetailType": "TaxLineDetail", "TaxLineDetail": { "TaxRateRef": { "value": "1" }, "PercentBased": true, "TaxPercent": 10, "NetAmountTaxable": 200.0 } }] }, "VendorRef": { "value": "37", "name": "Jennifer Hargreaves" }, ... "GlobalTaxCalculation": "TaxExcluded" }, "time": "2015-09-09T13:08:46.331-07:00" } |
To override automatic purchase tax calculation, supply a TxnTaxDetail
element in the create request with the following fields set:
TxnTaxDetail.TotalTax
—the new total tax amount.TxnTaxDetail.TaxLine.TaxLineDetail.TaxRateRef
—the tax rate that is overriden. You must send all TaxRateRefs of a TaxCode even if you are modifying just one of them.TxnTaxDetail.TaxLine.Amount
—The amount of tax contributed by the tax rate.TxnTaxDetail.TaxLine.TaxLineDetail.TaxPercent
—The new tax percent to use.A QuickBooks company file comes pre-populated with tax codes. Some of these auto-generated tax codes are non-editable and tax amount for such tax codes cannot be overridden. An attempt to do so will generate a business validation error.
1 2 3 4 5 6 7 8 9 10 11 12 | { "Fault": { "Error": [{ "Message": "A business validation error has occurred while processing your request", "Detail": "Business Validation Error: Unexpected Internal Error. (-37100)", "code": "6000", "element": "" }], "type": "ValidationFault" }, "time": "2015-09-30T09:07:35.030-07:00" } |
The sample Bill create request below overrides the 20% rate defined by the 20.0% S tax code with 10%. A purchase tax of £61.88 is applied to the £618.75 bill amount thus suppressing QuickBooks Online automatic sales tax calculation.
TxnTaxDetail.TotalTax
attribute explicitly defines £61.88 total tax.TxnTaxDetail.TaxLine.TaxLineDetail.TaxRateRef
attribute specifies the tax rate to be overridden.TxnTaxDetail.TaxLine.Amount
attribute explicitly defines £61.88 total tax.TxnTaxDetail.TaxLine.TaxLineDetail.TaxPercent
attribute explicitly defines the 10.0% tax rate.
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 | { "Line": [ { "Description": "promotional items -- misc engraved items", "Amount": 618.75, "DetailType": "ItemBasedExpenseLineDetail", "ItemBasedExpenseLineDetail": { "ItemRef": { "value": "12", "name": "Promotional items -- misc" }, "UnitPrice": 8.25, "Qty": 75, "TaxCodeRef": { "value": "3", "name":"20.0% S" } } } ], "TxnTaxDetail": { "TotalTax": 61.88, "TaxLine": [ { "Amount": 61.88, "DetailType": "TaxLineDetail", "TaxLineDetail": { "TaxRateRef": { "value": "3" }, "PercentBased": true, "TaxPercent": 10, "NetAmountTaxable": 618.75 } } ] }, "VendorRef": { "value": "57", "name": "Hall's Promo Items" } } |
Here is the corresponding response from the above Bill create request. Some content has been omitted in order to showcase purchase tax attributes.
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 | "Bill": { ... "Line": [ { "Id": "1", "Description": "promotional items -- misc engraved items", "Amount": 618.75, "DetailType": "ItemBasedExpenseLineDetail", "ItemBasedExpenseLineDetail": { "BillableStatus": "NotBillable", "ItemRef": { "value": "12", "name": "Promotional items -- misc" }, "UnitPrice": 8.25, "Qty": 75, "TaxCodeRef": { "value": "3" } } } ], "TxnTaxDetail": { "TotalTax": 61.88, "TaxLine": [ { "Amount": 61.88, "DetailType": "TaxLineDetail", "TaxLineDetail": { "TaxRateRef": { "value": "3" }, "PercentBased": true, "TaxPercent": 20, "NetAmountTaxable": 618.75 } } ] }, "VendorRef": { "value": "57", "name": "Hall's Promo Items" }, ... } |
QuickBooks Online calculates tax based on the total of taxable Line.Amount
attributes in the transaction. A Line.Amount
is calculated automatically from the UnitPrice
value passed in with the line, if present. If a UnitPrice
is not present, QuickBooks Online uses the value of
Line.Amount
directly. If both UnitPrice
and Line.Amount
are passed in, the value in Line.Amount
is discarded and the calculated value is used instead.
UnitPrice
fields have a precision of seven decimal places.Line.Amount
fields have a precision of two decimal places.The rounding precision for tax calculations is designed for two decimal place precision in QuickBooks Online. When inputing numbers into the UI or the API, you need to take this rounding into account. Tax is applied to the Line.Amount
fields after whatever rounding was necessary to get them to
two decimal places. As such, if you are entering numbers based on UnitPrice
, then you need to be aware that your number can potentially be rounded twice before tax is applied.
The table below contrasts the effects of rounding on the final stored value of Line.Amount
and corresponding sales tax on that amount.
Input UnitPrice| (input with 8 places)
|
Saved UnitPrice | (rounded to 7 places)
|
Line.Amount
|
Saved Line.Amount
(rounded to 2 places)
|
Calculated Tax
(where tax rate = 12%)
|
37.37499999 | 37.3750000 | 37.3750000 (calculated) | 37.38 | 4.49 |
37.37499999 (input directly) | 37.37 | 4.48 |
For transactions that are inclusive of tax, that is GlobalTaxCalculation=TaxInclusive
, the pre-tax transaction amount is the sum of pre-tax amounts rounded off per line rather than rounded off the total amount. For example, consider the following:
Apps need to take this into account with tax inclusive transactions.
The sample Invoice request below shows how to specify line amount and sales tax for tax inclusive transactions.
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 | { "Line": [{ "Amount": 16.67, "DetailType": "SalesItemLineDetail", "SalesItemLineDetail": { "UnitPrice": 16.67, "Qty": 1, "TaxCodeRef": { "value": "3", "name": "20.0% S" } } }], "GlobalTaxCalculation": "TaxInclusive", "TxnTaxDetail": { "TaxLine": [{ "Amount": 3.33, "DetailType": "TaxLineDetail", "TaxLineDetail": { "TaxRateRef": { "value": "4", "name": "SS-20.0" }, "PercentBased": true, "NetAmountTaxable": 16.67 } }], "TotalTax": 0 }, "CustomerRef": { "value": "1" } } |
Here is the corresponding response from the above Invoice create request. Some content has been omitted in order to showcase the resulting tax calculation.
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 | { "Invoice": { ... "Line": [{ "Id": "1", "LineNum": 1, "Amount": 16.67, "DetailType": "SalesItemLineDetail", "SalesItemLineDetail": { "ItemRef": { "value": "1", "name": "Services" }, "UnitPrice": 16.67, "Qty": 1, "TaxCodeRef": { "value": "3" } } }, { "Amount": 16.67, "DetailType": "SubTotalLineDetail", "SubTotalLineDetail": {} }], "TxnTaxDetail": { "TotalTax": 3.33, "TaxLine": [{ "Amount": 3.33, "DetailType": "TaxLineDetail", "TaxLineDetail": { "TaxRateRef": { "value": "4" }, "PercentBased": true, "TaxPercent": 20, "NetAmountTaxable": 16.67 } }] }, "CustomerRef": { "value": "1", "name": "Adwin Ko" }, ... } } |
Working with tax codes
Use a TaxCode object anywhere throughout the data model where it is required to specify the tax of a transaction. A TaxCode object represents a tax group (TaxCode.TaxGroup=true
) that combines one or more TaxRate components, asapplicable to the tax. It can specify a sales tax, a purchase tax, or both. For example, the sales tax for GST
is a tax group composed of the single tax rate, GST (sales)
: A sandbox company is pre-populated with several TaxCode objects.
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 | { "Name": "GST", "Description": "GST", "Active": true, "Taxable": true, "TaxGroup": true, "SalesTaxRateList": { "TaxRateDetail": [ { "TaxRateRef": { "value": "20", "name": "GST (sales)" }, "TaxTypeApplicable": "TaxOnAmount", "TaxOrder": 0 } ] }, "PurchaseTaxRateList": { "TaxRateDetail": [] }, "domain": "QBO", "sparse": false, "Id": "10", "SyncToken": "0", "MetaData": { "CreateTime": "2015-08-07T21:52:57-07:00", "LastUpdatedTime": "2015-08-07T21:52:57-07:00" }, "time": "2015-08-18T15:59:55.113-07:00" } |
Each line in the transaction references an actual TaxCode that is applied to the line. An actual TaxCode always references one or more TaxRate entities in either the SalesTaxRateList
, the PurchaseTaxRateList
, or both.The image below shows how the TaxCode object, GST
, is referenced in an
Invoice.
The TxnTaxDetail
element summarizes the tax for the entire transaction. It contains a TaxRate object reference for each component of the sales tax. In this case there are two underlying components to the tax rate, Vat @ 0 and VAT @ 20%. Note the Amounts are Tax exclusive setting, represented
in the object by the GlobalTaxCalculation
attribute. This means the amount on each line is the base amount without tax applied; information in the TxnTaxDetail section provides the tax amount.
A TaxRate object specifies the amount of tax imposed by a given tax agency. It is not used directly in transaction, but is a building block used in creating higher level tax code definitions. Create TaxRate objects with the TaxService entity. Non-US editions of QuickBooks Online support tax rates for both sales and purchase transactions.The image below shows how this object relates to the QuickBooks user interface showing VAT rate settings.
A tax agency is associated with a tax rate and is the authority that collects those taxes. It is defined in the data model with the TaxAgency entity. It is not used directly in transaction or list objects, but is a building block used to create higher level tax rate and tax code definitions. The image below shows how this entity relates to the Tax Centre in the QuickBooks Online UI.