Question

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.

Was it helpful?

Solution 2

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

OTHER TIPS

I think the bigger problem here is that you're looking at the completely wrong object type.

The error message is about:

does not have a tax code associated with it

But you're trying to set a:

TaxLineDetail

And a:

TaxLineDetail#set TaxRate Ref(ReferenceType)

Bottom line here - tax codes are NOT the same thing as tax rates. They are related, but totally separate entities.

What QuickBooks is complaining about is that you're not setting a tax code on your line items. See the line item documentation, and look for the TaxCodeRef node which you should be setting.

You should query for tax codes, using a query like this:

SELECT * FROM TaxCode

And then set your TaxCodeRef value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top