Search code examples
javaquickbooksquickbooks-onlineintuit-partner-platform

Where/How do I find the tax reference code needed to create an invoice using the QuickBooks API v3?


I'm trying to create invoices using the Java SDK (2.2.1) with the v3 API. My API calls to create invoices are failing because of a Business Validation Error stating that my transaction line does not have a tax code associated with it (error code: 6000).

I'm trying to set the tax for the transaction (sales line) like this:

TaxLineDetail taxLineDetail = new TaxLineDetail();
taxLineDetail.setPercentBased(true);
taxLineDetail.setTaxPercent( getTaxPercent() );
salesLine.setTaxLineDetail(taxLineDetail);

I've also tried using Invoice#setTxnTaxDetail(TxnTaxDetail) but it fails in both cases. It seems the API wants a tax code, presumably one that I set with:

TaxLineDetail#setTaxRateRef(ReferenceType)

But I don't understand where I get this tax rate code from. My QB account does have two taxes configured (23% and 0%) but how do I associate one of these with an invoice? Where is this (integer?) code that I need?

For what it's worth, this is a non-US account.


Solution

  • You can query TaxCode and TaxRate ref to get details and use the corresponding Ids in time of Invoice creation.

    https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference/taxcode

    https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference/taxrate

    ApiExplorer - https://developer.intuit.com/apiexplorer?apiname=V3QBO#TaxCode

    To get a correct XML structure of an Invoice object with TaxCode and TaxRate, you can create an invoice from QBO UI(with tax) and retrieve the same using API.

    Thanks