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??

Why?

Here’s the code to reproduce it :

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

$line1 = new stdClass;
 $line1->product_key="Abonnement";
 $line1->notes="Blogue V.I.P";
 $line1->cost=9.95;
 $line1->qty=1;

$line2 = new stdClass;
 $line2->product_key="Abonnement";
 $line2->notes="Plotte V.I.P";
 $line2->cost=9.95;
 $line2->qty=6;

 $invoice->invoice_items = [
            $line1, $line2
        ]; 
 $invoice->tax_rate=14.975;
 $invoice->tax_name="Taxes";

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

$payment = new stdClass;
$payment->invoice_id=$invoice_id;
$payment->amount='80.08';
$payment->payment_type_id=13;
$payment->transaction_reference='XXXXXXXXXXXXXXXXXXX';
$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.