Bonjour,
Je cherche à utiliser la REST API afin de créer une facture depuis une proposition commerciale
Je sais que c’est possible depuis une commande avec la route suivante: /invoices/createfromorder/{orderid}.
Cependant (ou alors je me trompe) je ne vois pas de route qui permet la création d’une facture depuis une proposition commerciale.
Est-ce une fonctionnalité non développé pour le moment ?
Est-ce que la REST API propose une route pour ça que je ne vois pas ?
Merci d’avance pour votre temps et vos réponses
PS: En ajoutant dans le fichier ./compta/facture/class/api_invoices.class.php la route, cela fonctionne:
[code]
/**
* Create an invoice using an existing propal.
*
*
* @param int $propalid Id of the propal
*
* @url POST /createfrompropal/{propalid}
*
* @return int
* @throws 400
* @throws 401
* @throws 404
* @throws 405
*/
function createInvoiceFromPropal($propalid) {
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
if(! DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
}
if(empty($propalid)) {
throw new RestException(400, 'Propal ID is mandatory');
}
$propal = new Propal($this->db);
$result = $propal->fetch($propalid);
if( ! $result ) {
throw new RestException(404, 'Propal not found');
}
$result = $this->invoice->createFromOrder($propal, DolibarrApiAccess::$user);
if( $result < 0) {
throw new RestException(405, $this->invoice->error);
}
$this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice);
}[/code]