Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2161 Näkymät

Hello,

I am currently having a problem when I create an invoice with the API.

This is created correctly, the invoice lines also as well as the application of VAT.

The problem is that the amount due on the invoice remains at 0 when it should be the same as the total at the time of creation


The code to create the invoice :

$content = array(
    "partner_id" => $customers[0]["id"],
    "date_invoice" => date( "Y-m-d", $invoiceArray["invoice"]->getDate()),
    "date_due" => date( "Y-m-d",     $invoiceArray["invoice"]->getDate()),
    "type" => $type,
    "state" => "draft",
);

The code to create the invoice lines:

$content = array(
    'Invoice'=> $invoiceCreated[0],
    'invoice_id'=> $result["invoice"],
    'product_id'=> 3, 
    'quantity'=> 1,
    'name'=> $v->getComment(),
    'account_id' => $accountId,
    'price_unit'=> $price,
);

I see with the debug that the residual field is in read_only but I don't know how to make it fill correctly.

I noticed that the amount due became correct if I canceled the invoice and manually re-open it from the interface.


Could you help me ?

Thank you

Avatar
Hylkää
Tekijä

The problem is solved. I had to use the action_invoice_open function instead of directly changing the status of the invoice.

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
lokak. 22
2651
2
heinäk. 19
4088
0
toukok. 19
4171
1
kesäk. 17
3587
1
helmik. 25
1570