Invoices
class Invoices extends DolibarrApi (View source)
API class for invoices
Properties
| protected DoliDB | $db | from DolibarrApi | |
| Restler | $r | from DolibarrApi | |
| static string[] | $FIELDS |
Methods
Constructor
Check and convert a string depending on its type/name.
Filter properties that will be returned on object
Clean sensible object datas
Check access by user to a given resource
Return if a $sqlfilters parameter is valid Function no more used. Kept for backward compatibility with old APIs of modules
Function to forge a SQL criteria from a Generic filter string.
Get properties of a invoice object
Get properties of an invoice object by ref
Get properties of an invoice object by ref_ext
List invoices
Create invoice object
Create an invoice using an existing order.
Create an invoice using a contract.
Get lines of an invoice
Update a line to a given invoice
Add a contact type of given invoice
Get contacts of given invoice
Delete a contact type of given invoice
Deletes a line of a given invoice
Update invoice
Delete invoice
Add a line to a given invoice
Adds a contact to an invoice
Sets an invoice as draft
Validate an invoice
Sets an invoice as paid
Sets an invoice as unpaid
Get discount from invoice
Create a discount (credit available) for a credit note or a deposit.
Add a discount line into an invoice (as an invoice line) using an existing absolute discount
Add an available credit note discount to payments of an existing invoice.
Get list of payments of a given invoice
Add payment line to a specific invoice with the remain to pay as amount.
Add a payment to pay partially or completely one or several invoices.
Update a payment
Get properties of a template invoice object
List template invoices
Clean sensible object datas
Details
__construct()
Constructor
protected string|array<string, mixed>
_checkValForAPI(string $field, string|string[] $value, object $object)
Check and convert a string depending on its type/name.
protected object
_filterObjectProperties(object $object, string $properties)
Filter properties that will be returned on object
protected object
_cleanObjectDatas(object $object)
Clean sensible object datas
static protected bool
_checkAccessToResource(string $resource, int $resource_id = 0, string $dbtablename = '', string $feature2 = '', string $dbt_keyfield = 'fk_soc', string $dbt_select = 'rowid')
Check access by user to a given resource
protected bool|string
_checkFilters(string $sqlfilters, string $error = '')
Return if a $sqlfilters parameter is valid Function no more used. Kept for backward compatibility with old APIs of modules
static protected string
_forge_criteria_callback(string[] $matches)
Function to forge a SQL criteria from a Generic filter string.
Function no more used. Kept for backward compatibility with old APIs of modules
object
get(int $id, int $contact_list = 1, string $properties = '', bool $withLines = true)
Get properties of a invoice object
Return an array with invoice information
object
getByRef(string $ref, int $contact_list = 1)
Get properties of an invoice object by ref
Return an array with invoice information
object
getByRefExt(string $ref_ext, int $contact_list = 1)
Get properties of an invoice object by ref_ext
Return an array with invoice information
array
index(string $sortfield = "t.rowid", string $sortorder = 'ASC', int $limit = 100, int $page = 0, string $thirdparty_ids = '', string $status = '', string $sqlfilters = '', string $properties = '', bool $pagination_data = false, int $loadlinkedobjects = 0, bool $withLines = true)
List invoices
Get a list of invoices
int
post(array $request_data = null)
Create invoice object
object
createInvoiceFromOrder(int $orderid)
Create an invoice using an existing order.
object
createInvoiceFromContract(int $contractid)
Create an invoice using a contract.
array
getLines(int $id)
Get lines of an invoice
object
putLine(int $id, int $lineid, array $request_data = null)
Update a line to a given invoice
array
postContact(int $id, int $contactid, string $type, string $source = 'external', int $notrigger = 0)
Add a contact type of given invoice
array<int, mixed>
getContacts(int $id, string $type = '')
Get contacts of given invoice
Return an array with contact information
object
deleteContact(int $id, int $contactid, string $type)
Delete a contact type of given invoice
object
deleteLine(int $id, int $lineid)
Deletes a line of a given invoice
object|false
put(int $id, array $request_data = null)
Update invoice
array
delete(int $id)
Delete invoice
int
postLine(int $id, array $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 }
object
addContact(int $id, int $fk_socpeople, string $type_contact, string $source, int $notrigger = 0)
Adds a contact to an invoice
object
settodraft(int $id, int $idwarehouse = -1)
Sets an invoice as draft
object|false
validate(int $id, string $force_number = '', int $idwarehouse = 0, int $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 }
object
settopaid(int $id, string $close_code = '', string $close_note = '')
Sets an invoice as paid
object
settounpaid(int $id)
Sets an invoice as unpaid
object
getDiscount(int $id)
Get discount from invoice
object
markAsCreditAvailable(int $id)
Create a discount (credit available) for a credit note or a deposit.
int
useDiscount(int $id, int $discountid)
Add a discount line into an invoice (as an invoice line) using an existing absolute discount
Note that this consume the discount.
int
useCreditNote(int $id, int $discountid)
Add an available credit note discount to payments of an existing invoice.
Note that this consume the credit note.
array
getPayments(int $id)
Get list of payments of a given invoice
int
addPayment(int $id, string $datepaye, int $paymentid, string $closepaidinvoices, int $accountid, string $num_payment = '', string $comment = '', string $chqemetteur = '', string $chqbank = '')
Add payment line to a specific invoice with the remain to pay as amount.
int
addPaymentDistributed(array $arrayofamounts, string $datepaye, int $paymentid, string $closepaidinvoices, int $accountid, string $num_payment = '', string $comment = '', string $chqemetteur = '', string $chqbank = '', string $ref_ext = '', bool $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
putPayment(int $id, string $num_payment = '')
Update a payment
object
getTemplateInvoice(int $id, int $contact_list = 1)
Get properties of a template invoice object
Return an array with invoice information
array
indexTemplateInvoices(string $sortfield = "t.rowid", string $sortorder = 'ASC', int $limit = 100, int $page = 0, string $thirdparty_ids = '', string $status = '', string $sqlfilters = '', string $properties = '', bool $pagination_data = false, int $loadlinkedobjects = 0, bool $withLines = true)
List template invoices
Get a list of template invoices
protected object
_cleanTemplateObjectDatas(object $object)
Clean sensible object datas