|
@@ -65,9 +65,9 @@ class Invoices extends DolibarrApi
|
|
|
*
|
|
|
* Return an array with invoice informations
|
|
|
*
|
|
|
- * @param int $id ID of invoice
|
|
|
- * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses
|
|
|
- * @return array|mixed data without useless information
|
|
|
+ * @param int $id ID of invoice
|
|
|
+ * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @throws RestException
|
|
|
*/
|
|
@@ -81,9 +81,9 @@ class Invoices extends DolibarrApi
|
|
|
*
|
|
|
* 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, -1: Do not return contacts/adddesses
|
|
|
- * @return array|mixed data without useless information
|
|
|
+ * @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, -1: Do not return contacts/adddesses
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @url GET ref/{ref}
|
|
|
*
|
|
@@ -99,9 +99,9 @@ class Invoices extends DolibarrApi
|
|
|
*
|
|
|
* 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, -1: Do not return contacts/adddesses
|
|
|
- * @return array|mixed data without useless information
|
|
|
+ * @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, -1: Do not return contacts/adddesses
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @url GET ref_ext/{ref_ext}
|
|
|
*
|
|
@@ -117,11 +117,11 @@ class Invoices extends DolibarrApi
|
|
|
*
|
|
|
* Return an array with invoice informations
|
|
|
*
|
|
|
- * @param int $id ID of order
|
|
|
- * @param string $ref Ref of object
|
|
|
- * @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, -1: Do not return contacts/adddesses
|
|
|
- * @return array|mixed data without useless information
|
|
|
+ * @param int $id ID of order
|
|
|
+ * @param string $ref Ref of object
|
|
|
+ * @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, -1: Do not return contacts/adddesses
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @throws RestException
|
|
|
*/
|
|
@@ -325,12 +325,11 @@ class Invoices extends DolibarrApi
|
|
|
/**
|
|
|
* Create an invoice using an existing order.
|
|
|
*
|
|
|
- *
|
|
|
* @param int $orderid Id of the order
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @url POST /createfromorder/{orderid}
|
|
|
*
|
|
|
- * @return int
|
|
|
* @throws RestException 400
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 404
|
|
@@ -338,7 +337,6 @@ class Invoices extends DolibarrApi
|
|
|
*/
|
|
|
public function createInvoiceFromOrder($orderid)
|
|
|
{
|
|
|
-
|
|
|
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
|
|
|
|
|
if (!DolibarrApiAccess::$user->rights->commande->lire) {
|
|
@@ -368,11 +366,10 @@ class Invoices extends DolibarrApi
|
|
|
/**
|
|
|
* Get lines of an invoice
|
|
|
*
|
|
|
- * @param int $id Id of invoice
|
|
|
+ * @param int $id Id of invoice
|
|
|
+ * @return array Array of lines
|
|
|
*
|
|
|
* @url GET {id}/lines
|
|
|
- *
|
|
|
- * @return int
|
|
|
*/
|
|
|
public function getLines($id)
|
|
|
{
|
|
@@ -399,14 +396,13 @@ class Invoices extends DolibarrApi
|
|
|
/**
|
|
|
* Update a line to a given invoice
|
|
|
*
|
|
|
- * @param int $id Id of invoice to update
|
|
|
- * @param int $lineid Id of line to update
|
|
|
- * @param array $request_data InvoiceLine data
|
|
|
+ * @param int $id Id of invoice to update
|
|
|
+ * @param int $lineid Id of line to update
|
|
|
+ * @param array $request_data InvoiceLine data
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @url PUT {id}/lines/{lineid}
|
|
|
*
|
|
|
- * @return array
|
|
|
- *
|
|
|
* @throws RestException 304
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 404 Invoice not found
|
|
@@ -472,14 +468,13 @@ class Invoices extends DolibarrApi
|
|
|
/**
|
|
|
* Add a contact type of given invoice
|
|
|
*
|
|
|
- * @param int $id Id of invoice to update
|
|
|
- * @param int $contactid Id of contact to add
|
|
|
- * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER)
|
|
|
+ * @param int $id Id of invoice to update
|
|
|
+ * @param int $contactid Id of contact to add
|
|
|
+ * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER)
|
|
|
+ * @return array
|
|
|
*
|
|
|
* @url POST {id}/contact/{contactid}/{type}
|
|
|
*
|
|
|
- * @return int
|
|
|
- *
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 404
|
|
|
*/
|
|
@@ -509,20 +504,24 @@ class Invoices extends DolibarrApi
|
|
|
throw new RestException(500, 'Error when added the contact');
|
|
|
}
|
|
|
|
|
|
- return $this->_cleanObjectDatas($this->invoice);
|
|
|
+ return array(
|
|
|
+ 'success' => array(
|
|
|
+ 'code' => 200,
|
|
|
+ 'message' => 'Contact linked to the invoice'
|
|
|
+ )
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Delete a contact type of given invoice
|
|
|
*
|
|
|
- * @param int $id Id of invoice to update
|
|
|
- * @param int $contactid Row key of the contact in the array contact_ids.
|
|
|
- * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER).
|
|
|
+ * @param int $id Id of invoice to update
|
|
|
+ * @param int $contactid Row key of the contact in the array contact_ids.
|
|
|
+ * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER).
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @url DELETE {id}/contact/{contactid}/{type}
|
|
|
*
|
|
|
- * @return array
|
|
|
- *
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 404
|
|
|
* @throws RestException 500 System error
|
|
@@ -561,13 +560,12 @@ class Invoices extends DolibarrApi
|
|
|
/**
|
|
|
* Deletes a line of a given invoice
|
|
|
*
|
|
|
- * @param int $id Id of invoice
|
|
|
- * @param int $lineid Id of the line to delete
|
|
|
+ * @param int $id Id of invoice
|
|
|
+ * @param int $lineid Id of the line to delete
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @url DELETE {id}/lines/{lineid}
|
|
|
*
|
|
|
- * @return array
|
|
|
- *
|
|
|
* @throws RestException 400
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 404
|
|
@@ -575,7 +573,6 @@ class Invoices extends DolibarrApi
|
|
|
*/
|
|
|
public function deleteLine($id, $lineid)
|
|
|
{
|
|
|
-
|
|
|
if (!DolibarrApiAccess::$user->rights->facture->creer) {
|
|
|
throw new RestException(401);
|
|
|
}
|
|
@@ -592,9 +589,7 @@ class Invoices extends DolibarrApi
|
|
|
throw new RestException(404, 'Invoice not found');
|
|
|
}
|
|
|
|
|
|
- // TODO Check the lineid $lineid is a line of ojbect
|
|
|
-
|
|
|
- $updateRes = $this->invoice->deleteline($lineid);
|
|
|
+ $updateRes = $this->invoice->deleteline($lineid, $id);
|
|
|
if ($updateRes > 0) {
|
|
|
return $this->get($id);
|
|
|
} else {
|
|
@@ -605,9 +600,9 @@ class Invoices extends DolibarrApi
|
|
|
/**
|
|
|
* Update invoice
|
|
|
*
|
|
|
- * @param int $id Id of invoice to update
|
|
|
- * @param array $request_data Datas
|
|
|
- * @return int
|
|
|
+ * @param int $id Id of invoice to update
|
|
|
+ * @param array $request_data Datas
|
|
|
+ * @return Object|false Object with cleaned properties
|
|
|
*/
|
|
|
public function put($id, $request_data = null)
|
|
|
{
|
|
@@ -648,8 +643,8 @@ class Invoices extends DolibarrApi
|
|
|
/**
|
|
|
* Delete invoice
|
|
|
*
|
|
|
- * @param int $id Invoice ID
|
|
|
- * @return array
|
|
|
+ * @param int $id Invoice ID
|
|
|
+ * @return array
|
|
|
*/
|
|
|
public function delete($id)
|
|
|
{
|
|
@@ -829,11 +824,10 @@ class Invoices extends DolibarrApi
|
|
|
*
|
|
|
* @param int $id Order ID
|
|
|
* @param int $idwarehouse Warehouse ID
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @url POST {id}/settodraft
|
|
|
*
|
|
|
- * @return array
|
|
|
- *
|
|
|
* @throws RestException 304
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 404
|
|
@@ -887,10 +881,9 @@ class Invoices extends DolibarrApi
|
|
|
* @param int $id Invoice ID
|
|
|
* @param int $idwarehouse Warehouse ID
|
|
|
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
|
|
+ * @return Object|false Object with cleaned properties
|
|
|
*
|
|
|
* @url POST {id}/validate
|
|
|
- *
|
|
|
- * @return array
|
|
|
*/
|
|
|
public function validate($id, $idwarehouse = 0, $notrigger = 0)
|
|
|
{
|
|
@@ -932,11 +925,10 @@ class Invoices extends DolibarrApi
|
|
|
* @param int $id Order ID
|
|
|
* @param string $close_code Code filled if we classify to 'Paid completely' when payment is not complete (for escompte for example)
|
|
|
* @param string $close_note Comment defined if we classify to 'Paid' when payment is not complete (for escompte for example)
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @url POST {id}/settopaid
|
|
|
*
|
|
|
- * @return array An invoice object
|
|
|
- *
|
|
|
* @throws RestException 304
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 404
|
|
@@ -981,12 +973,11 @@ class Invoices extends DolibarrApi
|
|
|
/**
|
|
|
* Sets an invoice as unpaid
|
|
|
*
|
|
|
- * @param int $id Order ID
|
|
|
+ * @param int $id Order ID
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @url POST {id}/settounpaid
|
|
|
*
|
|
|
- * @return array An invoice object
|
|
|
- *
|
|
|
* @throws RestException 304
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 404
|
|
@@ -1031,10 +1022,9 @@ class Invoices extends DolibarrApi
|
|
|
* Get discount from invoice
|
|
|
*
|
|
|
* @param int $id Id of invoice
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @url GET {id}/discount
|
|
|
- *
|
|
|
- * @return mixed
|
|
|
*/
|
|
|
public function getDiscount($id)
|
|
|
{
|
|
@@ -1069,10 +1059,10 @@ class Invoices extends DolibarrApi
|
|
|
/**
|
|
|
* Create a discount (credit available) for a credit note or a deposit.
|
|
|
*
|
|
|
- * @param int $id Invoice ID
|
|
|
- * @url POST {id}/markAsCreditAvailable
|
|
|
+ * @param int $id Invoice ID
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
- * @return array An invoice object
|
|
|
+ * @url POST {id}/markAsCreditAvailable
|
|
|
*
|
|
|
* @throws RestException 304
|
|
|
* @throws RestException 401
|
|
@@ -1241,11 +1231,10 @@ class Invoices extends DolibarrApi
|
|
|
*
|
|
|
* @param int $id Id of invoice
|
|
|
* @param int $discountid Id of discount
|
|
|
+ * @return int
|
|
|
*
|
|
|
* @url POST {id}/usediscount/{discountid}
|
|
|
*
|
|
|
- * @return int
|
|
|
- *
|
|
|
* @throws RestException 400
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 404
|
|
@@ -1253,7 +1242,6 @@ class Invoices extends DolibarrApi
|
|
|
*/
|
|
|
public function useDiscount($id, $discountid)
|
|
|
{
|
|
|
-
|
|
|
if (!DolibarrApiAccess::$user->rights->facture->creer) {
|
|
|
throw new RestException(401);
|
|
|
}
|
|
@@ -1288,11 +1276,10 @@ class Invoices extends DolibarrApi
|
|
|
*
|
|
|
* @param int $id Id of invoice
|
|
|
* @param int $discountid Id of a discount coming from a credit note
|
|
|
+ * @return int
|
|
|
*
|
|
|
* @url POST {id}/usecreditnote/{discountid}
|
|
|
*
|
|
|
- * @return int
|
|
|
- *
|
|
|
* @throws RestException 400
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 404
|
|
@@ -1300,7 +1287,6 @@ class Invoices extends DolibarrApi
|
|
|
*/
|
|
|
public function useCreditNote($id, $discountid)
|
|
|
{
|
|
|
-
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
|
|
|
|
|
|
if (!DolibarrApiAccess::$user->rights->facture->creer) {
|
|
@@ -1333,12 +1319,11 @@ class Invoices extends DolibarrApi
|
|
|
/**
|
|
|
* Get list of payments of a given invoice
|
|
|
*
|
|
|
- * @param int $id Id of invoice
|
|
|
+ * @param int $id Id of invoice
|
|
|
+ * @return array
|
|
|
*
|
|
|
* @url GET {id}/payments
|
|
|
*
|
|
|
- * @return array
|
|
|
- *
|
|
|
* @throws RestException 400
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 404
|
|
@@ -1395,8 +1380,6 @@ class Invoices extends DolibarrApi
|
|
|
*/
|
|
|
public function addPayment($id, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '')
|
|
|
{
|
|
|
- global $conf;
|
|
|
-
|
|
|
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
|
|
|
|
|
if (!DolibarrApiAccess::$user->rights->facture->creer) {
|
|
@@ -1509,6 +1492,7 @@ class Invoices extends DolibarrApi
|
|
|
* @url POST /paymentsdistributed
|
|
|
*
|
|
|
* @return int Payment ID
|
|
|
+ *
|
|
|
* @throws RestException 400
|
|
|
* @throws RestException 401
|
|
|
* @throws RestException 403
|
|
@@ -1516,8 +1500,6 @@ class Invoices extends DolibarrApi
|
|
|
*/
|
|
|
public function addPaymentDistributed($arrayofamounts, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '', $ref_ext = '', $accepthigherpayment = false)
|
|
|
{
|
|
|
- global $conf;
|
|
|
-
|
|
|
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
|
|
|
|
|
if (!DolibarrApiAccess::$user->rights->facture->creer) {
|
|
@@ -1645,6 +1627,7 @@ class Invoices extends DolibarrApi
|
|
|
* @url PUT payments/{id}
|
|
|
*
|
|
|
* @return array
|
|
|
+ *
|
|
|
* @throws RestException 400 Bad parameters
|
|
|
* @throws RestException 401 Not allowed
|
|
|
* @throws RestException 404 Not found
|
|
@@ -1708,8 +1691,8 @@ class Invoices extends DolibarrApi
|
|
|
/**
|
|
|
* Validate fields before create or update object
|
|
|
*
|
|
|
- * @param array|null $data Datas to validate
|
|
|
- * @return array
|
|
|
+ * @param array|null $data Datas to validate
|
|
|
+ * @return array
|
|
|
*
|
|
|
* @throws RestException
|
|
|
*/
|
|
@@ -1733,7 +1716,7 @@ class Invoices extends DolibarrApi
|
|
|
*
|
|
|
* @param int $id ID of template invoice
|
|
|
* @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses
|
|
|
- * @return array|mixed data without useless information
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @url GET templates/{id}
|
|
|
*
|
|
@@ -1749,11 +1732,11 @@ class Invoices extends DolibarrApi
|
|
|
*
|
|
|
* Return an array with invoice informations
|
|
|
*
|
|
|
- * @param int $id ID of order
|
|
|
- * @param string $ref Ref of object
|
|
|
- * @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, -1: Do not return contacts/adddesses
|
|
|
- * @return array|mixed data without useless information
|
|
|
+ * @param int $id ID of order
|
|
|
+ * @param string $ref Ref of object
|
|
|
+ * @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, -1: Do not return contacts/adddesses
|
|
|
+ * @return Object Object with cleaned properties
|
|
|
*
|
|
|
* @throws RestException
|
|
|
*/
|