Merge pull request #13241 from ptibogxiv/patch-309
NEW: api invoice get by ref
This commit is contained in:
commit
c9d7ea8998
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
/* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -63,11 +64,66 @@ class Invoices extends DolibarrApi
|
||||
*/
|
||||
public function get($id, $contact_list = 1)
|
||||
{
|
||||
return $this->_fetch($id, '', '', '', $contact_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of an invoice object by ref
|
||||
*
|
||||
* Return an array with invoice informations
|
||||
*
|
||||
* @param string $ref Ref of object
|
||||
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @url GET ref/{ref}
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function getByRef($ref, $contact_list = 1)
|
||||
{
|
||||
return $this->_fetch('', $ref, '', '', $contact_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of an invoice object by ref_ext
|
||||
*
|
||||
* Return an array with invoice informations
|
||||
*
|
||||
* @param string $ref_ext External reference of object
|
||||
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @url GET ref_ext/{ref_ext}
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function getByRefExt($ref_ext, $contact_list = 1)
|
||||
{
|
||||
return $this->_fetch('', '', $ref_ext, '', $contact_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of an order object
|
||||
*
|
||||
* Return an array with order informations
|
||||
*
|
||||
* @param int $id ID of order
|
||||
* @param string $ref Ref of object
|
||||
* @param string $ref_ext External reference of object
|
||||
* @param string $ref_int Internal reference of other objec
|
||||
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
private function _fetch($id, $ref = '', $ref_ext = '', $ref_int = '', $contact_list = 1)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->facture->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->invoice->fetch($id);
|
||||
$result = $this->invoice->fetch($id, $ref, $ref_ext, $ref_int);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
@ -87,7 +143,7 @@ class Invoices extends DolibarrApi
|
||||
|
||||
$this->invoice->fetchObjectLinked();
|
||||
return $this->_cleanObjectDatas($this->invoice);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List invoices
|
||||
@ -424,7 +480,7 @@ class Invoices extends DolibarrApi
|
||||
* @url DELETE {id}/contact/{rowid}
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
@ -592,6 +648,7 @@ class Invoices extends DolibarrApi
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws RestException 304
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 400
|
||||
@ -1098,6 +1155,7 @@ class Invoices extends DolibarrApi
|
||||
* @url POST {id}/usediscount/{discountid}
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws RestException 400
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
@ -1144,6 +1202,7 @@ class Invoices extends DolibarrApi
|
||||
* @url POST {id}/usecreditnote/{discountid}
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws RestException 400
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
@ -1189,7 +1248,7 @@ class Invoices extends DolibarrApi
|
||||
* @url GET {id}/payments
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*
|
||||
* @throws RestException 400
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
@ -1239,6 +1298,7 @@ class Invoices extends DolibarrApi
|
||||
* @url POST {id}/payments
|
||||
*
|
||||
* @return int Payment ID
|
||||
*
|
||||
* @throws RestException 400
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
@ -1358,6 +1418,7 @@ class Invoices extends DolibarrApi
|
||||
* @url POST /paymentsdistributed
|
||||
*
|
||||
* @return int Payment ID
|
||||
*
|
||||
* @throws RestException 400
|
||||
* @throws RestException 401
|
||||
* @throws RestException 403
|
||||
|
||||
Loading…
Reference in New Issue
Block a user