Home Forums Support Found a bug with API and amount due…

This topic contains 2 replies, has 2 voices, and was last updated by  quebecblogue 3 years, 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2152

    quebecblogue
    Participant

    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"); 
    
    #2155

    Hillel Coren
    Keymaster

    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);

    #2159

    quebecblogue
    Participant

    It works! Thanks a lot.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Posted in: