dolibarr 19.0.3
SupplierInvoices Class Reference
Inheritance diagram for SupplierInvoices:
Collaboration diagram for SupplierInvoices:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id)
 Get properties of a supplier invoice object.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $thirdparty_ids='', $status='', $sqlfilters='', $properties='')
 List invoices.
 
 post ($request_data=null)
 Create supplier invoice object.
 
 put ($id, $request_data=null)
 Update supplier invoice.
 
 delete ($id)
 Delete supplier invoice.
 
 validate ($id, $idwarehouse=0, $notrigger=0)
 Validate an invoice.
 
 getPayments ($id)
 Get list of payments of a given supplier invoice.
 
 addPayment ($id, $datepaye, $payment_mode_id, $closepaidinvoices, $accountid, $num_payment='', $comment='', $chqemetteur='', $chqbank='', $amount=null)
 Add payment line to a specific supplier invoice with the remain to pay as amount.
 
 getLines ($id)
 Get lines of a supplier invoice.
 
 postLine ($id, $request_data=null)
 Add a line to given supplier invoice.
 
 putLine ($id, $lineid, $request_data=null)
 Update a line to a given supplier invoice.
 
 deleteLine ($id, $lineid)
 Deletes a line of a given supplier invoice.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _cleanObjectDatas ($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

 _validate ($data)
 Validate fields before create or update 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.
 

Detailed Description

Definition at line 31 of file api_supplier_invoices.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

SupplierInvoices::_cleanObjectDatas ( $object)
protected

Clean sensible object datas.

Parameters
Object$objectObject to clean
Returns
Object Object with cleaned properties

Reimplemented from DolibarrApi.

Definition at line 729 of file api_supplier_invoices.class.php.

Referenced by get(), getLines(), index(), and putLine().

◆ _validate()

SupplierInvoices::_validate ( $data)
private

Validate fields before create or update object.

Parameters
array$dataDatas to validate
Returns
array
Exceptions
RestException

Definition at line 751 of file api_supplier_invoices.class.php.

Referenced by post().

◆ addPayment()

SupplierInvoices::addPayment ( $id,
$datepaye,
$payment_mode_id,
$closepaidinvoices,
$accountid,
$num_payment = '',
$comment = '',
$chqemetteur = '',
$chqbank = '',
$amount = null )

Add payment line to a specific supplier invoice with the remain to pay as amount.

Parameters
int$idId of invoice
string$datepaye{@from body} Payment date {@type timestamp}
int$payment_mode_id{@from body} Payment mode ID (look it up via REST GET to /setup/dictionary/payment_types) {@min 1}
string$closepaidinvoices{@from body} Close paid invoices {@choice yes,no}
int$accountid{@from body} Bank account ID (look it up via REST GET to /bankaccounts) {@min 1}
string$num_payment{@from body} Payment number (optional)
string$comment{@from body} Note (optional)
string$chqemetteur{@from body} Payment issuer (mandatory if payment_mode_id corresponds to 'CHQ'-payment type)
string$chqbank{@from body} Issuer bank name (optional)
float$amount{@from body} Amount of payment if we don't want to use the remain to pay

@url POST {id}/payments

Returns
int Payment ID
Exceptions
RestException400
RestException401
RestException404

Definition at line 432 of file api_supplier_invoices.class.php.

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

◆ delete()

SupplierInvoices::delete ( $id)

Delete supplier invoice.

Parameters
int$idSupplier invoice ID
Returns
array
Exceptions
RestException401
RestException404
RestException500 System error

Definition at line 298 of file api_supplier_invoices.class.php.

References DolibarrApi\_checkAccessToResource().

◆ deleteLine()

SupplierInvoices::deleteLine ( $id,
$lineid )

Deletes a line of a given supplier invoice.

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

@url DELETE {id}/lines/{lineid}

Returns
array
Exceptions
RestException400 Bad parameters
RestException401 Not allowed
RestException404 Not found
RestException405 Error

Definition at line 693 of file api_supplier_invoices.class.php.

References DolibarrApi\_checkAccessToResource().

◆ get()

SupplierInvoices::get ( $id)

Get properties of a supplier invoice object.

Return an array with supplier invoice information

Parameters
int$idID of supplier invoice
Returns
Object Object with cleaned properties
Exceptions
RestException

Definition at line 66 of file api_supplier_invoices.class.php.

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

◆ getLines()

SupplierInvoices::getLines ( $id)

Get lines of a supplier invoice.

Parameters
int$idId of supplier invoice

@url GET {id}/lines

Returns
array

Definition at line 523 of file api_supplier_invoices.class.php.

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

◆ getPayments()

SupplierInvoices::getPayments ( $id)

Get list of payments of a given supplier invoice.

Parameters
int$idId of SupplierInvoice

@url GET {id}/payments

Returns
array
Exceptions
RestException400
RestException401
RestException404
RestException405

Definition at line 384 of file api_supplier_invoices.class.php.

References DolibarrApi\_checkAccessToResource().

◆ index()

SupplierInvoices::index ( $sortfield = "t.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$thirdparty_ids = '',
$status = '',
$sqlfilters = '',
$properties = '' )

List invoices.

Get a list of supplier invoices

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$thirdparty_idsThirdparty ids to filter invoices of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
string$statusFilter by invoice status : draft | unpaid | paid | cancelled
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
string$propertiesRestrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names
Returns
array Array of invoice objects
Exceptions
RestException

Definition at line 102 of file api_supplier_invoices.class.php.

References _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), forgeSQLFromUniversalSearchCriteria(), and getEntity().

◆ post()

SupplierInvoices::post ( $request_data = null)

Create supplier invoice object.

Note: soc_id = dolibarr_order_id

Example: {'ref': 'auto', 'ref_supplier': '7985630', 'socid': 1, 'note': 'Inserted with Python', 'order_supplier': 1, 'date': '2021-07-28'}

Parameters
array$request_dataRequest datas
Returns
int ID of supplier invoice
Exceptions
RestException401
RestException500 System error

Definition at line 214 of file api_supplier_invoices.class.php.

References DolibarrApi\_checkValForAPI(), _validate(), and dol_now().

◆ postLine()

SupplierInvoices::postLine ( $id,
$request_data = null )

Add a line to given supplier invoice.

Note: socid = dolibarr_order_id, pu_ht = net price, remise = discount

Example: {'socid': 1, 'qty': 1, 'pu_ht': 21.0, 'tva_tx': 25.0, 'fk_product': '1189', 'product_type': 0, 'remise_percent': 1.0, 'vat_src_code': None}

Parameters
int$idId of supplier invoice to update
array$request_datasupplier invoice line data

@url POST {id}/lines

Returns
int|bool

Definition at line 559 of file api_supplier_invoices.class.php.

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

◆ put()

SupplierInvoices::put ( $id,
$request_data = null )

Update supplier invoice.

Parameters
int$idId of supplier invoice to update
array$request_dataDatas
Returns
int
Exceptions
RestException401
RestException404

Definition at line 252 of file api_supplier_invoices.class.php.

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

◆ putLine()

SupplierInvoices::putLine ( $id,
$lineid,
$request_data = null )

Update a line to a given supplier invoice.

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

@url PUT {id}/lines/{lineid}

Returns
object
Exceptions
RestException401 Not allowed
RestException404 Not found
RestException304 Error

Definition at line 626 of file api_supplier_invoices.class.php.

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

◆ validate()

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

Validate an invoice.

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

@url POST {id}/validate

Returns
array
Exceptions
RestException304
RestException401
RestException404
RestException405
RestException500 System error

Definition at line 341 of file api_supplier_invoices.class.php.

References DolibarrApi\_checkAccessToResource().


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