dolibarr 21.0.0-beta
|
Public Member Functions | |
__construct () | |
Constructor. | |
get ($id, $contact_list=1) | |
Get properties of a invoice object. | |
getByRef ($ref, $contact_list=1) | |
Get properties of an invoice object by ref. | |
getByRefExt ($ref_ext, $contact_list=1) | |
Get properties of an invoice object by ref_ext. | |
index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $thirdparty_ids='', $status='', $sqlfilters='', $properties='', $pagination_data=false) | |
List invoices. | |
post ($request_data=null) | |
Create invoice object. | |
createInvoiceFromOrder ($orderid) | |
Create an invoice using an existing order. | |
createInvoiceFromContract ($contractid) | |
Create an invoice using a contract. | |
getLines ($id) | |
Get lines of an invoice. | |
putLine ($id, $lineid, $request_data=null) | |
Update a line to a given invoice. | |
postContact ($id, $contactid, $type) | |
Add a contact type of given invoice. | |
deleteContact ($id, $contactid, $type) | |
Delete a contact type of given invoice. | |
deleteLine ($id, $lineid) | |
Deletes a line of a given invoice. | |
put ($id, $request_data=null) | |
Update invoice. | |
delete ($id) | |
Delete invoice. | |
postLine ($id, $request_data=null) | |
Add a line to a given invoice. | |
addContact ($id, $fk_socpeople, $type_contact, $source, $notrigger=0) | |
Adds a contact to an invoice. | |
settodraft ($id, $idwarehouse=-1) | |
Sets an invoice as draft. | |
validate ($id, $force_number='', $idwarehouse=0, $notrigger=0) | |
Validate an invoice. | |
settopaid ($id, $close_code='', $close_note='') | |
Sets an invoice as paid. | |
settounpaid ($id) | |
Sets an invoice as unpaid. | |
getDiscount ($id) | |
Get discount from invoice. | |
markAsCreditAvailable ($id) | |
Create a discount (credit available) for a credit note or a deposit. | |
useDiscount ($id, $discountid) | |
Add a discount line into an invoice (as an invoice line) using an existing absolute discount. | |
useCreditNote ($id, $discountid) | |
Add an available credit note discount to payments of an existing invoice. | |
getPayments ($id) | |
Get list of payments of a given invoice. | |
addPayment ($id, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment='', $comment='', $chqemetteur='', $chqbank='') | |
Add payment line to a specific invoice with the remain to pay as amount. | |
addPaymentDistributed ($arrayofamounts, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment='', $comment='', $chqemetteur='', $chqbank='', $ref_ext='', $accepthigherpayment=false) | |
Add a payment to pay partially or completely one or several invoices. | |
putPayment ($id, $num_payment='') | |
Update a payment. | |
getTemplateInvoice ($id, $contact_list=1) | |
Get properties of a template invoice object. | |
Public Member Functions inherited from DolibarrApi | |
__construct ($db, $cachedir='', $refreshCache=false) | |
Constructor. | |
Protected Member Functions | |
_cleanObjectDatas ($object) | |
Clean sensible object datas. | |
_cleanTemplateObjectDatas ($object) | |
Clean sensible object datas. | |
Protected Member Functions inherited from DolibarrApi | |
_checkValForAPI ($field, $value, $object) | |
Check and convert a string depending on its type/name. | |
_filterObjectProperties ($object, $properties) | |
Filter properties that will be returned on object. | |
_checkFilters ($sqlfilters, &$error='') | |
Return if a $sqlfilters parameter is valid Function no more used. | |
Private Member Functions | |
_fetch ($id, $ref='', $ref_ext='', $contact_list=1) | |
Get properties of an invoice object. | |
_validate ($data) | |
Validate fields before create or update object. | |
_fetchTemplateInvoice ($id, $ref='', $ref_ext='', $contact_list=1) | |
Get properties of an invoice object. | |
Additional Inherited Members | |
Static Protected Member Functions inherited from DolibarrApi | |
static | _checkAccessToResource ($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid') |
Check access by user to a given resource. | |
static | _forge_criteria_callback ($matches) |
Function to forge a SQL criteria from a Generic filter string. | |
Definition at line 34 of file api_invoices.class.php.
|
protected |
Clean sensible object datas.
Object | $object | Object to clean |
Reimplemented from DolibarrApi.
Definition at line 1785 of file api_invoices.class.php.
References $object.
Referenced by _fetch(), addContact(), createInvoiceFromContract(), createInvoiceFromOrder(), deleteContact(), getLines(), index(), markAsCreditAvailable(), putLine(), settodraft(), settopaid(), settounpaid(), and validate().
|
protected |
Clean sensible object datas.
Object | $object | Object to clean |
Definition at line 1888 of file api_invoices.class.php.
References $object.
Referenced by _fetchTemplateInvoice().
|
private |
Get properties of an invoice object.
Return an array with invoice information
int | $id | ID of order |
string | $ref | Ref of object |
string | $ref_ext | External reference of object |
int | $contact_list | 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses |
RestException |
Definition at line 131 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), _cleanObjectDatas(), and price2num().
Referenced by get(), getByRef(), and getByRefExt().
|
private |
Get properties of an invoice object.
Return an array with invoice information
int | $id | ID of order |
string | $ref | Ref of object |
string | $ref_ext | External reference of object |
int | $contact_list | 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses |
RestException |
Definition at line 1853 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and _cleanTemplateObjectDatas().
Referenced by getTemplateInvoice().
|
private |
Validate fields before create or update object.
array | null | $data | Datas to validate |
RestException |
Definition at line 1809 of file api_invoices.class.php.
Referenced by post().
Invoices::addContact | ( | $id, | |
$fk_socpeople, | |||
$type_contact, | |||
$source, | |||
$notrigger = 0 ) |
Adds a contact to an invoice.
int | $id | Order ID |
int | $fk_socpeople | Id of thirdparty contact (if source = 'external') or id of user (if source = 'internal') to link |
string | $type_contact | Type of contact (code). Must a code found into table llx_c_type_contact. For example: BILLING |
string | $source | external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) |
int | $notrigger | Disable all triggers |
@url POST {id}/contacts
RestException | 304 |
RestException | 401 |
RestException | 404 |
RestException | 500 System error |
Definition at line 870 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().
Invoices::addPayment | ( | $id, | |
$datepaye, | |||
$paymentid, | |||
$closepaidinvoices, | |||
$accountid, | |||
$num_payment = '', | |||
$comment = '', | |||
$chqemetteur = '', | |||
$chqbank = '' ) |
Add payment line to a specific invoice with the remain to pay as amount.
int | $id | Id of invoice |
string | $datepaye | {@from body} Payment date {@type timestamp} |
int | $paymentid | {@from body} Payment mode Id {@min 1} |
string | $closepaidinvoices | {@from body} Close paid invoices {@choice yes,no} |
int | $accountid | {@from body} Account Id {@min 1} |
string | $num_payment | {@from body} Payment number (optional) |
string | $comment | {@from body} Note private (optional) |
string | $chqemetteur | {@from body} Payment issuer (mandatory if paymentcode = 'CHQ') |
string | $chqbank | {@from body} Issuer bank name (optional) |
@url POST {id}/payments
RestException | 400 |
RestException | 401 |
RestException | 404 |
Definition at line 1483 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), dol_getIdFromCode(), dol_stringtotime(), price2num(), and Facture\TYPE_CREDIT_NOTE.
Invoices::addPaymentDistributed | ( | $arrayofamounts, | |
$datepaye, | |||
$paymentid, | |||
$closepaidinvoices, | |||
$accountid, | |||
$num_payment = '', | |||
$comment = '', | |||
$chqemetteur = '', | |||
$chqbank = '', | |||
$ref_ext = '', | |||
$accepthigherpayment = false ) |
Add a payment to pay partially or completely one or several invoices.
Warning: Take care that all invoices are owned by the same customer. Example of value for parameter arrayofamounts: {"1": {"amount": "99.99", "multicurrency_amount": ""}, "2": {"amount": "", "multicurrency_amount": "10"}}
array | $arrayofamounts | {@from body} Array with id of invoices with amount to pay for each invoice |
string | $datepaye | {@from body} Payment date {@type timestamp} |
int | $paymentid | {@from body} Payment mode Id {@min 1} |
string | $closepaidinvoices | {@from body} Close paid invoices {@choice yes,no} |
int | $accountid | {@from body} Account Id {@min 1} |
string | $num_payment | {@from body} Payment number (optional) |
string | $comment | {@from body} Note private (optional) |
string | $chqemetteur | {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') |
string | $chqbank | {@from body} Issuer bank name (optional) |
string | $ref_ext | {@from body} External reference (optional) |
bool | $accepthigherpayment | {@from body} Accept higher payments that it remains to be paid (optional) |
@url POST /paymentsdistributed
RestException | 400 |
RestException | 401 |
RestException | 403 |
RestException | 404 |
Definition at line 1607 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), dol_getIdFromCode(), dol_stringtotime(), price2num(), and Facture\TYPE_CREDIT_NOTE.
Invoices::createInvoiceFromContract | ( | $contractid | ) |
Create an invoice using a contract.
int | $contractid | Id of the contract |
@url POST /createfromcontract/{contractid}
RestException | 400 |
RestException | 401 |
RestException | 404 |
RestException | 405 |
Definition at line 402 of file api_invoices.class.php.
References _cleanObjectDatas().
Invoices::createInvoiceFromOrder | ( | $orderid | ) |
Create an invoice using an existing order.
int | $orderid | Id of the order |
@url POST /createfromorder/{orderid}
RestException | 400 |
RestException | 401 |
RestException | 404 |
RestException | 405 |
Definition at line 361 of file api_invoices.class.php.
References _cleanObjectDatas().
Invoices::delete | ( | $id | ) |
Delete invoice.
int | $id | Invoice ID |
Definition at line 730 of file api_invoices.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
Invoices::deleteContact | ( | $id, | |
$contactid, | |||
$type ) |
Delete a contact type of given invoice.
int | $id | Id of invoice to update |
int | $contactid | Row key of the contact in the array contact_ids. |
string | $type | Type of the contact (BILLING, SHIPPING, CUSTOMER). |
@url DELETE {id}/contact/{contactid}/{type}
RestException | 401 |
RestException | 404 |
RestException | 500 System error |
Definition at line 593 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().
Invoices::deleteLine | ( | $id, | |
$lineid ) |
Deletes a line of a given invoice.
int | $id | Id of invoice |
int | $lineid | Id of the line to delete |
@url DELETE {id}/lines/{lineid}
RestException | 400 |
RestException | 401 |
RestException | 404 |
RestException | 405 |
Definition at line 638 of file api_invoices.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
Invoices::get | ( | $id, | |
$contact_list = 1 ) |
Get properties of a invoice object.
Return an array with invoice information
int | $id | ID of invoice |
int | $contact_list | 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses |
RestException |
Definition at line 77 of file api_invoices.class.php.
Invoices::getByRef | ( | $ref, | |
$contact_list = 1 ) |
Get properties of an invoice object by ref.
Return an array with invoice information
string | $ref | Ref of object |
int | $contact_list | 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses |
@url GET ref/{ref}
RestException |
Definition at line 95 of file api_invoices.class.php.
References _fetch().
Invoices::getByRefExt | ( | $ref_ext, | |
$contact_list = 1 ) |
Get properties of an invoice object by ref_ext.
Return an array with invoice information
string | $ref_ext | External reference of object |
int | $contact_list | 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses |
@url GET ref_ext/{ref_ext}
RestException |
Definition at line 113 of file api_invoices.class.php.
References _fetch().
Invoices::getDiscount | ( | $id | ) |
Get discount from invoice.
int | $id | Id of invoice |
@url GET {id}/discount
Definition at line 1115 of file api_invoices.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
Invoices::getLines | ( | $id | ) |
Get lines of an invoice.
int | $id | Id of invoice |
@url GET {id}/lines
Definition at line 438 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().
Invoices::getPayments | ( | $id | ) |
Get list of payments of a given invoice.
int | $id | Id of invoice |
@url GET {id}/payments
RestException | 400 |
RestException | 401 |
RestException | 404 |
RestException | 405 |
Definition at line 1435 of file api_invoices.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
Invoices::getTemplateInvoice | ( | $id, | |
$contact_list = 1 ) |
Get properties of a template invoice object.
Return an array with invoice information
int | $id | ID of template invoice |
int | $contact_list | 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses |
@url GET templates/{id}
RestException |
Definition at line 1835 of file api_invoices.class.php.
References $id, and _fetchTemplateInvoice().
Invoices::index | ( | $sortfield = "t.rowid", | |
$sortorder = 'ASC', | |||
$limit = 100, | |||
$page = 0, | |||
$thirdparty_ids = '', | |||
$status = '', | |||
$sqlfilters = '', | |||
$properties = '', | |||
$pagination_data = false ) |
List invoices.
Get a list of invoices
string | $sortfield | Sort field |
string | $sortorder | Sort order |
int | $limit | Limit for list |
int | $page | Page number |
string | $thirdparty_ids | Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} |
string | $status | Filter by invoice status : draft | unpaid | paid | cancelled |
string | $sqlfilters | Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" |
string | $properties | Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names |
bool | $pagination_data | If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0 |
RestException | 404 Not found |
RestException | 503 Error |
Definition at line 188 of file api_invoices.class.php.
References _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), forgeSQLFromUniversalSearchCriteria(), and price2num().
Invoices::markAsCreditAvailable | ( | $id | ) |
Create a discount (credit available) for a credit note or a deposit.
int | $id | Invoice ID |
@url POST {id}/markAsCreditAvailable
RestException | 304 |
RestException | 401 |
RestException | 404 |
RestException | 500 System error |
Definition at line 1158 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), _cleanObjectDatas(), dol_print_error(), Facture\TYPE_CREDIT_NOTE, Facture\TYPE_DEPOSIT, Facture\TYPE_REPLACEMENT, Facture\TYPE_SITUATION, and Facture\TYPE_STANDARD.
Invoices::post | ( | $request_data = null | ) |
Create invoice object.
array | $request_data | Request datas |
Definition at line 313 of file api_invoices.class.php.
References DolibarrApi\_checkValForAPI(), _validate(), dol_now(), and sanitizeVal().
Invoices::postContact | ( | $id, | |
$contactid, | |||
$type ) |
Add a contact type of given invoice.
int | $id | Id of invoice to update |
int | $contactid | Id of contact to add |
string | $type | Type of the contact (BILLING, SHIPPING, CUSTOMER) |
@url POST {id}/contact/{contactid}/{type}
RestException | 401 |
RestException | 404 |
Definition at line 545 of file api_invoices.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
Invoices::postLine | ( | $id, | |
$request_data = null ) |
Add a line to a given invoice.
Example 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 }
int | $id | Id of invoice |
array | $request_data | InvoiceLine data |
@url POST {id}/lines
RestException | 304 |
RestException | 401 |
RestException | 404 |
RestException | 400 |
Definition at line 782 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), getMarginInfos(), and sanitizeVal().
Invoices::put | ( | $id, | |
$request_data = null ) |
Update invoice.
int | $id | Id of invoice to update |
array | $request_data | Datas |
Definition at line 671 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValForAPI(), and sanitizeVal().
Invoices::putLine | ( | $id, | |
$lineid, | |||
$request_data = null ) |
Update a line to a given invoice.
int | $id | Id of invoice to update |
int | $lineid | Id of line to update |
array | $request_data | InvoiceLine data |
@url PUT {id}/lines/{lineid}
RestException | 304 |
RestException | 401 |
RestException | 404 Invoice not found |
Definition at line 474 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), _cleanObjectDatas(), and sanitizeVal().
Invoices::putPayment | ( | $id, | |
$num_payment = '' ) |
Update a payment.
int | $id | Id of payment |
string | $num_payment | Payment number |
@url PUT payments/{id}
RestException | 400 Bad parameters |
RestException | 401 Not allowed |
RestException | 404 Not found |
Definition at line 1745 of file api_invoices.class.php.
References $id.
Invoices::settodraft | ( | $id, | |
$idwarehouse = -1 ) |
Sets an invoice as draft.
int | $id | Order ID |
int | $idwarehouse | Warehouse ID |
@url POST {id}/settodraft
RestException | 304 |
RestException | 401 |
RestException | 404 |
RestException | 500 System error |
Definition at line 918 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().
Invoices::settopaid | ( | $id, | |
$close_code = '', | |||
$close_note = '' ) |
Sets an invoice as paid.
int | $id | Order ID |
string | $close_code | Code filled if we classify to 'Paid completely' when payment is not complete (for escompte for example) |
string | $close_note | Comment defined if we classify to 'Paid' when payment is not complete (for escompte for example) |
@url POST {id}/settopaid
RestException | 304 |
RestException | 401 |
RestException | 404 |
RestException | 500 System error |
Definition at line 1023 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().
Invoices::settounpaid | ( | $id | ) |
Sets an invoice as unpaid.
int | $id | Order ID |
@url POST {id}/settounpaid
RestException | 304 |
RestException | 401 |
RestException | 404 |
RestException | 500 System error |
Definition at line 1072 of file api_invoices.class.php.
References $id, 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.
int | $id | Id of invoice |
int | $discountid | Id of a discount coming from a credit note |
@url POST {id}/usecreditnote/{discountid}
RestException | 400 |
RestException | 401 |
RestException | 404 |
RestException | 405 |
Definition at line 1391 of file api_invoices.class.php.
References $id, and 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.
int | $id | Id of invoice |
int | $discountid | Id of discount |
@url POST {id}/usediscount/{discountid}
RestException | 400 |
RestException | 401 |
RestException | 404 |
RestException | 405 |
Definition at line 1346 of file api_invoices.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
Invoices::validate | ( | $id, | |
$force_number = '', | |||
$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 }
int | $id | Invoice ID |
string | $force_number | force ref invoice |
int | $idwarehouse | Warehouse ID |
int | $notrigger | 1=Does not execute triggers, 0= execute triggers |
@url POST {id}/validate
Definition at line 970 of file api_invoices.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().