What you're asking isn't really a programming question... it's more of an accounting question.
The QuickBooks API exactly mirrors the QuickBooks GUI. So, whatever you do in the GUI to add sales tax, you should do in the API. How do you do it in the GUI?
Soooo... let's talk about QuickBooks normally does sales tax in the GUI:
- You mark each line item with a Sales Tax Code of either NON (for non-taxable) or TAX (for taxable)
- At the bottom of the invoice, you choose a specific Sales Tax Item (e.g. "California Sales Tax")
- QuickBooks then calculates tax for you by using the tax rate from the Sale Tax Item * (the sum of the TAXable line items)
It shouldn't be terribly surprising then you look at the QuickBooks OSR API documentation, and you see line item definitions like this:
<InvoiceLineAdd>
...
<Amount>29.95</Amount>
<SalesTaxCodeRef>
<FullName>Tax</FullName> <!-- valid values here are one of your Sales Tax Codes, usually "NON" or "TAX" -->
</SalesTaxCodeRef>
</InvoiceLineAdd>
And, at the bottom of the InvoiceAdd specification, an option for specifying a Sales Tax Item like this:
<ItemSalesTaxRef>
<FullName>California Sales Tax</FullName> <!-- valid values are any of your existing Sale Tax Items in QuickBooks -->
</ItemSalesTaxRef>
With all that said, we have to pay special attention to this portion of your question:
I cannot find any way to add sales tax, which is calculated in my app,
to the QB invoice.
The answer above let's QuickBooks calculate the tax amount from the tax rate vs. taking what you already calculated in your app. Sooooo... the rule still stands - the QuickBooks API mirrors the GUI. So, how do you do this in the GUI right now?
The correct answer is: ask your accountant how he wants you to do it.
More than likely, the answer is:
- Create a new Sales Tax Item with a 0% tax rate named "Refer to Invoice"
- Add a new line item to the invoice that uses ItemRef/FullName to refer to the correct Sales Tax Item (e.g. "California State Tax")
- On that line item, specify the actual tax amount calculated in your app
If that's what he wants, then you should do exactly that in the GUI. Treat it just like any other invoice line item.