Found a bug with API and amount due...

Yeah it’s me again but I think you’ll be interested to see this. The good news is that I’ve built the customer, the invoice and the payment with the API and that while there’s an error in the invoice builder, it still is being sent correctly to the customer and the customer payment is mark as paid.

Here’s a screenshot :

I’ve created an invoice of 69.65 with 10.43 of taxes for a total of 80.08. I applied a payment of 80.08.

However the invoice builder says there’s an amount due of 1.42??


Here’s the code to reproduce it :

 $invoice = new stdClass;
 $invoice->client_id = 26;

$line1 = new stdClass;
 $line1->notes="Blogue V.I.P";

$line2 = new stdClass;
 $line2->notes="Plotte V.I.P";

 $invoice->invoice_items = [
            $line1, $line2

$response = sendRequest('invoices', $invoice, "POST"); 
$invoice_id = $response->data->id;
	echo "# de facture = $invoice_id";

$payment = new stdClass;
$response = sendRequest('payments', $payment, "POST"); 

Thanks for letting us know!

I’m able to reproduce the problem, it’s a display issue cased by a JavaScript rounding error. We’ll include a fix with the next release. If you’d like to apply the fix search for the following line of code in resources/views/invoices/knockout.blade.php

total = NINJA.parseFloat(total) + roundToTwo(total * (taxRate/100));

And then add the following line after it.

total = roundToTwo(total);

It works! Thanks a lot.