dolibarr  7.0.0-beta
Public Member Functions | List of all members
Invoices Class Reference
+ Inheritance diagram for Invoices:
+ Collaboration diagram for Invoices:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id)
 Get properties of a invoice object. More...
 
 post ($request_data=NULL)
 Create invoice object. More...
 
 createInvoiceFromOrder ($orderid)
 Create an invoice using an existing order. More...
 
 getLines ($id)
 Get lines of an invoice. More...
 
 putLine ($id, $lineid, $request_data=NULL)
 Update a line to a given invoice. More...
 
 deleteLine ($id, $lineid)
 Deletes a line of a given invoice. More...
 
 put ($id, $request_data=NULL)
 Update invoice. More...
 
 delete ($id)
 Delete invoice. More...
 
 postLine ($id, $request_data=NULL)
 Add a line to a given invoice. More...
 
 settodraft ($id, $idwarehouse=-1)
 Sets an invoice as draft. More...
 
 validate ($id, $idwarehouse=0, $notrigger=0)
 Validate an invoice. More...
 
 settopaid ($id, $close_code='', $close_note='')
 Sets an invoice as paid. More...
 
 settounpaid ($id)
 Sets an invoice as unpaid. More...
 
 useDiscount ($id, $discountid)
 Add a discount line into an invoice (as an invoice line) using an existing absolute discount. More...
 
 useCreditNote ($id, $discountid)
 Add an available credit note discount to payments of an existing invoice. More...
 
 getPayments ($id)
 Get list of payments of a given invoice. More...
 
 addPayment ($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='')
 Add payment line to a specific invoice. More...
 
 _cleanObjectDatas ($object)
 Clean sensible object datas. More...
 
 _validate ($data)
 Validate fields before create or update object. More...
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor. More...
 
 _cleanObjectDatas ($object)
 Executed method when API is called without parameter. More...
 
 _checkFilters ($sqlfilters)
 Return if a $sqlfilters parameter is valid. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DolibarrApi
static _checkAccessToResource ($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
 Check user access to a resource. More...
 
static _forge_criteria_callback ($matches)
 Function to forge a SQL criteria. More...
 

Detailed Description

Definition at line 28 of file api_invoices.class.php.

Member Function Documentation

Invoices::_cleanObjectDatas (   $object)

Clean sensible object datas.

Parameters
object$objectObject to clean
Returns
array Array of cleaned object properties

Definition at line 1022 of file api_invoices.class.php.

Referenced by createInvoiceFromOrder(), get(), getLines(), putLine(), settodraft(), settopaid(), settounpaid(), and validate().

Invoices::_validate (   $data)

Validate fields before create or update object.

Parameters
array | null$dataDatas to validate
Returns
array
Exceptions
RestException

Definition at line 1044 of file api_invoices.class.php.

Referenced by post().

Invoices::addPayment (   $id,
  $datepaye,
  $paiementid,
  $closepaidinvoices,
  $accountid,
  $num_paiement = '',
  $comment = '',
  $chqemetteur = '',
  $chqbank = '' 
)

Add payment line to a specific invoice.

The model schema is defined by the PaymentData class.

Parameters
int$idId of invoice
string$datepaye{ body} Payment date { timestamp}
int$paiementid{ body} Payment mode Id { 1}
string$closepaidinvoices{ body} Close paid invoices { yes,no}
int$accountid{ body} Account Id { 1}
string$num_paiement{ body} Payment number (optional)
string$comment{ body} Note (optional)
string$chqemetteur{ body} Payment issuer (mandatory if paiementcode = 'CHQ')
string$chqbank{ body} Issuer bank name (optional)

POST {id}/payments

Returns
int Payment ID
Exceptions
400
401
404

Definition at line 924 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource(), dol_getIdFromCode(), price2num(), and Facture\TYPE_CREDIT_NOTE.

Invoices::createInvoiceFromOrder (   $orderid)

Create an invoice using an existing order.

Parameters
int$orderidId of the order

POST /createfromorder/{orderid}

Returns
int
Exceptions
400
401
404
405

Definition at line 242 of file api_invoices.class.php.

References _cleanObjectDatas().

Invoices::delete (   $id)

Delete invoice.

Parameters
int$idInvoice ID
Returns
array

Definition at line 458 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource().

Invoices::deleteLine (   $id,
  $lineid 
)

Deletes a line of a given invoice.

Parameters
int$idId of invoice
int$lineidId of the line to delete

DELETE {id}/lines/{lineid}

Returns
array
Exceptions
400
401
404
405

Definition at line 380 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource().

Invoices::get (   $id)

Get properties of a invoice object.

Return an array with invoice informations

Parameters
int$idID of invoice
Returns
array|mixed data without useless information
Exceptions
RestException

Definition at line 63 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource(), _cleanObjectDatas(), and price2num().

Invoices::getLines (   $id)

Get lines of an invoice.

Parameters
int$idId of invoice

GET {id}/lines

Returns
int

Definition at line 279 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

Invoices::getPayments (   $id)

Get list of payments of a given invoice.

Parameters
int$idId of invoice

GET {id}/payments

Returns
array
Exceptions
400
401
404
405

Definition at line 876 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource().

Invoices::post (   $request_data = NULL)

Create invoice object.

Parameters
array$request_dataRequest datas
Returns
int ID of invoice

Definition at line 199 of file api_invoices.class.php.

References _validate(), and dol_now().

Invoices::postLine (   $id,
  $request_data = NULL 
)

Add a line to a given invoice.

Exemple of POST query : { "desc": "Desc", "subprice": "1.00000000", "qty": "1", "tva_tx": "20.000", "localtax1_tx": "0.000", "localtax2_tx": "0.000", "fk_product": "1", "remise_percent": "0", "date_start": "", "date_end": "", "fk_code_ventilation": 0, "info_bits": "0", "fk_remise_except": null, "product_type": "1", "rang": "-1", "special_code": "0", "fk_parent_line": null, "fk_fournprice": null, "pa_ht": "0.00000000", "label": "", "array_options": [], "situation_percent": "100", "fk_prev_id": null, "fk_unit": null }

Parameters
int$idId of invoice
array$request_dataInvoiceLine data

POST {id}/lines

Returns
int
Exceptions
200
401
404
400

Definition at line 502 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource(), and getMarginInfos().

Invoices::put (   $id,
  $request_data = NULL 
)

Update invoice.

Parameters
int$idId of invoice to update
array$request_dataDatas
Returns
int

Definition at line 417 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource().

Invoices::putLine (   $id,
  $lineid,
  $request_data = NULL 
)

Update a line to a given invoice.

Parameters
int$idId of invoice to update
int$lineidId of line to update
array$request_dataInvoiceLine data

PUT {id}/lines/{lineid}

Returns
object
Exceptions
200
304
401
404

Definition at line 316 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

Invoices::settodraft (   $id,
  $idwarehouse = -1 
)

Sets an invoice as draft.

Parameters
int$idOrder ID
int$idwarehouseWarehouse ID

POST {id}/settodraft

Returns
array
Exceptions
200
304
401
404
500

Definition at line 582 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

Invoices::settopaid (   $id,
  $close_code = '',
  $close_note = '' 
)

Sets an invoice as paid.

Parameters
int$idOrder ID
string$close_codeCode renseigne si on classe a payee completement alors que paiement incomplet (cas escompte par exemple)
string$close_noteCommentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple)

POST {id}/settopaid

Returns
array An invoice object
Exceptions
200
304
401
404
500

Definition at line 685 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

Invoices::settounpaid (   $id)

Sets an invoice as unpaid.

Parameters
int$idOrder ID

POST {id}/settounpaid

Returns
array An invoice object
Exceptions
200
304
401
404
500

Definition at line 736 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

Invoices::useCreditNote (   $id,
  $discountid 
)

Add an available credit note discount to payments of an existing invoice.

Note that this consume the credit note.

Parameters
int$idId of invoice
int$discountidId of a discount coming from a credit note

POST {id}/usecreditnote/{discountid}

Returns
int
Exceptions
400
401
404
405

Definition at line 832 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource().

Invoices::useDiscount (   $id,
  $discountid 
)

Add a discount line into an invoice (as an invoice line) using an existing absolute discount.

Note that this consume the discount.

Parameters
int$idId of invoice
int$discountidId of discount

POST {id}/usediscount/{discountid}

Returns
int
Exceptions
400
401
404
405

Definition at line 787 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource().

Invoices::validate (   $id,
  $idwarehouse = 0,
  $notrigger = 0 
)

Validate an invoice.

If you get a bad value for param notrigger check that ou provide this in body { "idwarehouse": 0, "notrigger": 0 }

Parameters
int$idInvoice ID
int$idwarehouseWarehouse ID
int$notrigger1=Does not execute triggers, 0= execute triggers

POST {id}/validate

Returns
array

Definition at line 634 of file api_invoices.class.php.

References DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().


The documentation for this class was generated from the following file: