Creating invoice over API with different taxes per product and negative amounts

Hi,

I’m trying to create an invoice where I have multiple products, where every product is subject to a different tax amount. (So I’m having a tax rate for every product, but no total tax is applied to the whole invoice.)
Moreover one of the items has a negative amount, and the others are positive.

When I’m doing this in the app (in the browser) everything works out. It shows the net amount and gross amount and all the tax totals are calculated correctly on the bottom.

But when I try to do the same over the API it seems the total taxes are not calculated correctly and they aren’t shown on the bottom of the invoice.

Take e.g. 2 Products

Testproduct1      Tax 20%       Cost -200     quantitiy 1
Testproduct2      Tax 10%       Cost  100     quantitiy 1

In the app I get a total amount of -130 and total taxes of -30, and the taxes are nicely summarized at the bottom.

Now I try this over the API with this command:

curl -X POST $API_URL’invoices’ -H $H_TOKEN -H ‘X-Requested-With: XMLHttpRequest’ -H ‘Content-Type:application/json’ -d ‘{“client_id”: “KGRb41dBLZ”, “line_items”: [{“product_key”: “Testproduct1”, “notes”: null, “cost”: -200, “quantity”: 1, “tax_name1”: “Umsatzsteuer”, “tax_rate1”: 20}, {“product_key”: “Testproduct2”, “notes”: null, “cost”: 100, “quantity”: 1, “tax_name1”: “Umsatzsteuer”, “tax_rate1”: 10}]}’

(where $API_URL is our base URL and $H_TOKEN is ‘X-API-Token:…and so on’)

Then I get an invoice with no total taxes at the bottom (total_taxes = 0.0 and total_amount = -100.0 in the database).

Do I have to pass some additional values to the API or do I have to format something differently?

Hi,

I suggest using the network tab in the browser console to check the API request being sent by the app to compare to what you’re using.

1 Like

Thanks for the tip!
When I copy the exact request it works. So now I just have to find out what’s missing in my request.

Thank you!

It seems the only thing I have to add is

“is_amount_discount”: false

I don’t know what this does but apparently I have to set it to false.

Interesting, thanks for the info! @david any thoughts as to why?