Version v5.10.43
In addition to normal invoices where a client has to pay us, we also have invoices where the total amounts comes out negative, so we have to transfer money to a client.
Up to now I just created the invoice with the negative amounts in it and then a script created the actual bank payment + the payment in InvoiceNinja using the API to show that we have transferred the amount.
In the API POST request I just used the invoice_id and the negative amount that we have to pay and that seemed to work just fine until recently.
The request looks like this:
curl -X POST 'https://invoiceninja.mysite.com/api/v1/payments' \
-H "X-Api-Token:[ourtoken]" \
-H 'X-Requested-With:XMLHttpRequest' \
-H 'accept:application/json' \
-H 'Content-Type:application/json' \
-d '{"amount":-100,
"invoices":[{"amount":-100, "invoice_id":"4w9aAr9bvM"}],
"type_id":"1",
"is_manual":true,
"transaction_reference":"R0012024",
"client_id":"KGRb41dBLZ"}'
When I try this now I get the following error:
{“message”:“The given data was invalid.”,“errors”:{“invoices”:[“Eine oder mehrere dieser Rechnungen wurden bereits bezahlt”]}}
(Which seems to be “one_or_more_invoices_paid” in texts.php)
I suspect this is because the invoice has a negative amount and therefore a negative balance.
When I manually set the balance to 0 in the database, then it is possible to add the (negative) payment. But after this the invoice has a balance of +100.
Is this behavior a new feature of the application?
Is there no possibility to register an outgoing payment and mark a negative invoices as paid?