dolibarr 24.0.0-beta
Thirdparties Class Reference
Inheritance diagram for Thirdparties:
Collaboration diagram for Thirdparties:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id)
 Get a third party.
 
 getByEmail ($email)
 Get properties of a third party by email.
 
 getByBarcode ($barcode)
 Get a third party by barcode.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $mode=0, $category=0, $sqlfilters='', $properties='', $pagination_data=false)
 List third parties.
 
 post ($request_data=null)
 Create a third party.
 
 put ($id, $request_data=null)
 Update third party.
 
 merge ($id, $idtodelete)
 Merge a third party into another third party.
 
 delete ($id)
 Delete a third party.
 
 setThirdpartyPriceLevel ($id, $priceLevel)
 Set a new price level for the given third party.
 
 addRepresentative ($id, $representative_id)
 Add a customer representative to a third party.
 
 deleteRepresentative ($id, $representative_id)
 Remove the link between a customer representative and a third party.
 
 getCategories ($id, $sortfield="s.rowid", $sortorder='ASC', $limit=0, $page=0)
 Get customer categories for a third party.
 
 addCategory ($id, $category_id)
 Add a customer category to a third party.
 
 deleteCategory ($id, $category_id)
 Remove the link between a customer category and the third party.
 
 getSupplierCategories ($id, $sortfield="s.rowid", $sortorder='ASC', $limit=0, $page=0)
 Get supplier categories for a third party.
 
 addSupplierCategory ($id, $category_id)
 Add a supplier category to a third party.
 
 deleteSupplierCategory ($id, $category_id)
 Remove the link between a category and the third party.
 
 getOutStandingProposals ($id, $mode='customer')
 Get outstanding proposals for a third party.
 
 getOutStandingOrder ($id, $mode='customer')
 Get outstanding orders for a third party.
 
 getOutStandingInvoices ($id, $mode='customer')
 Get outstanding invoices for a third party.
 
 getSalesRepresentatives ($id, $mode=0)
 Get representatives of a third party.
 
 getFixedAmountDiscounts ($id, $mode='customer', $filter="none", $sortfield="f.type", $sortorder='ASC')
 Get fixed amount discount of a third party.
 
 createFixedAmountDiscount ($id, $request_data=null)
 Create a fixed amount discount for a thirdparty.
 
 splitdiscount ($id, $discountid, $amount_ttc_1, $amount_ttc_2)
 Split a discount in 2 smaller discount.
 
 getInvoicesQualifiedForReplacement ($id)
 Return invoices qualified to be replaced by another invoice.
 
 getInvoicesQualifiedForCreditNote ($id)
 Return invoices qualified to be corrected by a credit note.
 
 getCompanyNotification ($id)
 Get company notifications for a third party.
 
 createCompanyNotification ($id, $request_data=null)
 Create a company notification for a third party.
 
 createCompanyNotificationByCode ($id, $code, $request_data=null)
 Create a company notification for a third party using action trigger code.
 
 deleteCompanyNotification ($id, $notification_id)
 Delete a company notification attached to a third party.
 
 updateCompanyNotification ($id, $notification_id, $request_data=null)
 Update a company notification for a third party.
 
 getCompanyBankAccount ($id)
 Get company bank accounts of a third party.
 
 createCompanyBankAccount ($id, $request_data=null)
 Create a company bank account for a third party.
 
 updateCompanyBankAccount ($id, $bankaccount_id, $request_data=null)
 Update a company bank account of a third party.
 
 deleteCompanyBankAccount ($id, $bankaccount_id)
 Delete a bank account attached to a third party.
 
 generateBankAccountDocument ($id, $companybankid=null, $model='sepamandate')
 Generate a document from a bank account record.
 
 getSocieteAccounts ($id, $site=null)
 Get a specific account attached to a third party.
 
 getSocieteByAccounts ($site, $key_account)
 Get a specific third party by account.
 
 createSocieteAccount ($id, $request_data=null)
 Create and attach a new account to an existing third party.
 
 postSocieteAccount ($id, $site, $request_data=null)
 Create and attach a new (or replace an existing) specific site account for a third party.
 
 putSocieteAccount ($id, $site, $request_data=null)
 Update specified values of a specific account attached to a third party.
 
 deleteSocieteAccount ($id, $site)
 Delete a specific site account attached to a third party.
 
 deleteSocieteAccounts ($id)
 Delete all accounts attached to a third party.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _cleanObjectDatas ($object)
 Clean sensible object datas @phpstan-template T.
 
- Protected Member Functions inherited from DolibarrApi
 _checkValForAPI ($field, $value, $object)
 Check and convert a string depending on its type/name.
 
 _checkValExtrafieldsForAPI ($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.
 
 _fetch ($rowid, $ref='', $ref_ext='', $barcode='', $idprof1='', $idprof2='', $idprof3='', $idprof4='', $idprof5='', $idprof6='', $email='', $ref_alias='')
 Fetch properties of a thirdparty 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 37 of file api_thirdparties.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Thirdparties::_cleanObjectDatas ( $object)
protected

Clean sensible object datas @phpstan-template T.

Parameters
Object$objectObject to clean
Returns
Object Object with cleaned properties @phpstan-param T $object @phpstan-return T

Reimplemented from DolibarrApi.

Definition at line 2634 of file api_thirdparties.class.php.

References $object.

Referenced by _fetch(), addCategory(), addSupplierCategory(), createCompanyBankAccount(), createCompanyNotification(), createCompanyNotificationByCode(), createSocieteAccount(), deleteCategory(), deleteSupplierCategory(), index(), postSocieteAccount(), putSocieteAccount(), setThirdpartyPriceLevel(), updateCompanyBankAccount(), and updateCompanyNotification().

◆ _fetch()

Thirdparties::_fetch ( $rowid,
$ref = '',
$ref_ext = '',
$barcode = '',
$idprof1 = '',
$idprof2 = '',
$idprof3 = '',
$idprof4 = '',
$idprof5 = '',
$idprof6 = '',
$email = '',
$ref_alias = '' )
private

Fetch properties of a thirdparty object.

Return an array with thirdparty information

Parameters
?int$rowidId of third party to load (Use 0 to get a specimen record, use null to use other search criteria)
string$refReference of third party, name (Warning, this can return several records)
string$ref_extExternal reference of third party (Warning, this information is a free field not provided by Dolibarr)
string$barcodeBarcode of third party to load
string$idprof1Prof id 1 of third party (Warning, this can return several records)
string$idprof2Prof id 2 of third party (Warning, this can return several records)
string$idprof3Prof id 3 of third party (Warning, this can return several records)
string$idprof4Prof id 4 of third party (Warning, this can return several records)
string$idprof5Prof id 5 of third party (Warning, this can return several records)
string$idprof6Prof id 6 of third party (Warning, this can return several records)
string$emailEmail of third party (Warning, this can return several records)
string$ref_aliasName_alias of third party (Warning, this can return several records)
Returns
object cleaned Societe object @phan-return Societe @phpstan-return Societe
Exceptions
RestException

Definition at line 2714 of file api_thirdparties.class.php.

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

Referenced by get(), getByBarcode(), getByEmail(), and getSocieteByAccounts().

◆ _validate()

Thirdparties::_validate ( $data)
private

Validate fields before create or update object.

Parameters
?array<string,string>$data Data to validate
Returns
array<string,string>
Exceptions
RestException

Definition at line 2676 of file api_thirdparties.class.php.

Referenced by post().

◆ addCategory()

Thirdparties::addCategory ( $id,
$category_id )

Add a customer category to a third party.

Since
5.0.0 Initial implementation
Parameters
int$idID of the third party
int$category_idID of category
Returns
Object

@phan-return Societe @phpstan-return Societe

@url PUT {id}/categories/{category_id}

Exceptions
RestException

Definition at line 710 of file api_thirdparties.class.php.

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

◆ addRepresentative()

Thirdparties::addRepresentative ( $id,
$representative_id )

Add a customer representative to a third party.

Since
20.0.0 Initial implementation
Parameters
int$idID of the third party
int$representative_idID of representative
Returns
int Return integer <=0 if KO, >0 if OK

@url POST {id}/representative/{representative_id}

Exceptions
RestException401 Access not allowed for your login
RestException404 User or Third party not found

Definition at line 592 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ addSupplierCategory()

Thirdparties::addSupplierCategory ( $id,
$category_id )

Add a supplier category to a third party.

Since
7.0.0 Initial implementation
Parameters
int$idID of the third party
int$category_idID of category
Returns
mixed

@phan-return Societe @phpstan-return Societe

@url PUT {id}/supplier_categories/{category_id}

Exceptions
RestException

Definition at line 843 of file api_thirdparties.class.php.

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

◆ createCompanyBankAccount()

Thirdparties::createCompanyBankAccount ( $id,
$request_data = null )

Create a company bank account for a third party.

Since
9.0.0 Initial implementation
Parameters
int$idID of the third party
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
array|mixed BankAccount of the third party

@url POST {id}/bankaccounts

Exceptions
RestException

Definition at line 1944 of file api_thirdparties.class.php.

References $id, DolibarrApi\_checkValForAPI(), _cleanObjectDatas(), dol_now(), and sanitizeVal().

◆ createCompanyNotification()

Thirdparties::createCompanyNotification ( $id,
$request_data = null )

Create a company notification for a third party.

Since
20.0.0 Initial implementation
Parameters
int$idID of the third party
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
array|mixed Notification of the third party

@url POST {id}/notifications

Exceptions
RestException

Definition at line 1642 of file api_thirdparties.class.php.

References $id, DolibarrApi\_checkValForAPI(), and _cleanObjectDatas().

◆ createCompanyNotificationByCode()

Thirdparties::createCompanyNotificationByCode ( $id,
$code,
$request_data = null )

Create a company notification for a third party using action trigger code.

Since
21.0.0 Initial implementation
Parameters
int$idID of the third party
string$codeAction Trigger code
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
array|mixed Notification for the third party @phan-return Notify

@url POST {id}/notificationsbycode/{code}

Exceptions
RestException

Definition at line 1705 of file api_thirdparties.class.php.

References $id, DolibarrApi\_checkValForAPI(), and _cleanObjectDatas().

◆ createFixedAmountDiscount()

Thirdparties::createFixedAmountDiscount ( $id,
$request_data = null )

Create a fixed amount discount for a thirdparty.

Since
24.0.0 Initial implementation
Parameters
int$idID of thirdparty
array$request_dataRequest data
  • amount float Amount including tax (required if price_base_type is TTC)
  • description string Description of the discount (required)
  • tva_tx float VAT rate in percentage
  • discount_type int Type of discount: 0 = customer discount, 1 = supplier discount (default: 0)
  • price_base_type string Price base type: 'HT' or 'TTC' (default: 'HT') @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

@url POST {id}/fixedamountdiscounts

Returns
int ID of the created discount
Exceptions
RestException400 Bad request
RestException401 Access not allowed for login
RestException404 Thirdparty not found
RestException500 Error creating discount

Definition at line 1203 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ createSocieteAccount()

Thirdparties::createSocieteAccount ( $id,
$request_data = null )

Create and attach a new account to an existing third party.

Possible fields for request_data (request body) are specified in llx_societe_account table.
See Table llx_societe_account wiki page for more information<br>
Example body payload :

{"key_account": "cus_DAVkLSs1LYyYI", "site": "stripe"}
Since
9.0.0 Initial implementation
Parameters
int$idID of the third party
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
array|mixed
Exceptions
RestException401 Unauthorized: User does not have permission to read thirdparties
RestException409 Conflict: An Account already exists for this company and site.
RestException422 Unprocessable Entity: You must pass the site attribute in your request data !
RestException500 Internal Server Error: Error creating SocieteAccount account

@url POST {id}/accounts

Definition at line 2320 of file api_thirdparties.class.php.

References $id, DolibarrApi\_checkValForAPI(), _cleanObjectDatas(), and sanitizeVal().

◆ delete()

Thirdparties::delete ( $id)

Delete a third party.

Since
3.8.0 Initial implementation
Parameters
int$idID of the third party
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}
Exceptions
RestException

Definition at line 487 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ deleteCategory()

Thirdparties::deleteCategory ( $id,
$category_id )

Remove the link between a customer category and the third party.

Since
7.0.0 Initial implementation
Parameters
int$idID of the third party
int$category_idID of category
Returns
Object @phan-return Societe @phpstan-return Societe

@url DELETE {id}/categories/{category_id}

Exceptions
RestException

Definition at line 754 of file api_thirdparties.class.php.

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

◆ deleteCompanyBankAccount()

Thirdparties::deleteCompanyBankAccount ( $id,
$bankaccount_id )

Delete a bank account attached to a third party.

Since
9.0.0 Initial implementation
Parameters
int$idID of the third party
int$bankaccount_idID of CompanyBankAccount
Returns
int -1 if error, 1 if correct deletion

@url DELETE {id}/bankaccounts/{bankaccount_id}

Exceptions
RestException

Definition at line 2057 of file api_thirdparties.class.php.

References $id.

◆ deleteCompanyNotification()

Thirdparties::deleteCompanyNotification ( $id,
$notification_id )

Delete a company notification attached to a third party.

Since
20.0.0 Initial implementation
Parameters
int$idID of the third party
int$notification_idID of CompanyNotification
Returns
int -1 if error, 1 if correct deletion

@url DELETE {id}/notifications/{notification_id}

Exceptions
RestException

Definition at line 1775 of file api_thirdparties.class.php.

References $id.

◆ deleteRepresentative()

Thirdparties::deleteRepresentative ( $id,
$representative_id )

Remove the link between a customer representative and a third party.

Since
20.0.0 Initial implementation
Parameters
int$idID of the third party
int$representative_idID of representative
Returns
int Return integer <=0 if KO, >0 if OK

@url DELETE {id}/representative/{representative_id}

Exceptions
RestException401 Access not allowed for your login
RestException404 User or Third party not found

Definition at line 628 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ deleteSocieteAccount()

Thirdparties::deleteSocieteAccount ( $id,
$site )

Delete a specific site account attached to a third party.

by account id

Since
9.0.0 Initial implementation
Parameters
int$idID of the third party
string$siteSite key
Returns
void
Exceptions
RestException401 Unauthorized: User does not have permission to delete thirdparties accounts
RestException404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty
RestException500 Internal Server Error: Error deleting SocieteAccount entity

@url DELETE {id}/accounts/{site}

Definition at line 2550 of file api_thirdparties.class.php.

◆ deleteSocieteAccounts()

Thirdparties::deleteSocieteAccounts ( $id)

Delete all accounts attached to a third party.

Since
9.0.0 Initial implementation
Parameters
int$idID of the third party
Returns
void
Exceptions
RestException401 Unauthorized: User does not have permission to delete thirdparties accounts
RestException404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty
RestException500 Internal Server Error: Error deleting SocieteAccount entity

@url DELETE {id}/accounts

We select all the records that match the socid

Definition at line 2587 of file api_thirdparties.class.php.

References $id.

◆ deleteSupplierCategory()

Thirdparties::deleteSupplierCategory ( $id,
$category_id )

Remove the link between a category and the third party.

Since
7.0.0 Initial implementation
Parameters
int$idID of the third party
int$category_idID of category
Returns
mixed @phan-return Societe @phpstan-return Societe

@url DELETE {id}/supplier_categories/{category_id}

Exceptions
RestException

Definition at line 887 of file api_thirdparties.class.php.

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

◆ generateBankAccountDocument()

Thirdparties::generateBankAccountDocument ( $id,
$companybankid = null,
$model = 'sepamandate' )

Generate a document from a bank account record.

Like SEPA mandate

Since
9.0.0 Initial implementation
Parameters
int$idID of the third party
int$companybankidID of company bank
string$modelModel of document to generate
Returns
array @phan-return array{success:int<0,1>} @phpstan-return array{success:int<0,1>}

@url GET {id}/generateBankAccountDocument/{companybankid}/{model}

Exceptions
RestException

Definition at line 2094 of file api_thirdparties.class.php.

References $conf, $id, dol_sanitizeFileName(), and getDolGlobalInt().

◆ get()

Thirdparties::get ( $id)

Get a third party.

Return the third party object

Since
3.8.0 Initial implementation
Parameters
int$idID of the third party to load
Returns
Object Object with cleaned properties
Exceptions
RestException

Definition at line 84 of file api_thirdparties.class.php.

References $id, and _fetch().

◆ getByBarcode()

Thirdparties::getByBarcode ( $barcode)

Get a third party by barcode.

Return an array with third party information

Since
13.0.0 Initial implementation
Parameters
string$barcodeBarcode of the third party
Returns
array|mixed Cleaned Societe object

@url GET barcode/{barcode}

Exceptions
RestException

Definition at line 124 of file api_thirdparties.class.php.

References _fetch().

◆ getByEmail()

Thirdparties::getByEmail ( $email)

Get properties of a third party by email.

Return an array with third party information

Since
11.0.0 Initial implementation
Parameters
string$emailEmail of the third party to load
Returns
array|mixed Cleaned Societe object @phan-return Societe @phpstan-return Societe

@url GET email/{email}

Exceptions
RestException

Definition at line 105 of file api_thirdparties.class.php.

References _fetch().

◆ getCategories()

Thirdparties::getCategories ( $id,
$sortfield = "s.rowid",
$sortorder = 'ASC',
$limit = 0,
$page = 0 )

Get customer categories for a third party.

Since
5.0.0 Initial implementation
Parameters
int$idID of the third party
string$sortfieldSort field
string$sortorderSort order
int$limitList limit
int$pagePage number
Returns
array @phan-return array<int,array{id:int,fk_parent:int,label:string,description:string,color:string,position:int,socid:int,type:string,entity:int,array_options:array<string,mixed>,visible:int,ref_ext:string,multilangs?:array<string,array{label:string,description:string,note?:string}>}> @phpstan-return array<int,array{id:int,fk_parent:int,label:string,description:string,color:string,position:int,socid:int,type:string,entity:int,array_options:array<string,mixed>,visible:int,ref_ext:string,multilangs?:array<string,array{label:string,description:string,note?:string}>}>

@url GET {id}/categories

Exceptions
RestException

Definition at line 668 of file api_thirdparties.class.php.

References $id.

◆ getCompanyBankAccount()

Thirdparties::getCompanyBankAccount ( $id)

Get company bank accounts of a third party.

Since
9.0.0 Initial implementation
Parameters
int$idID of the third party
Returns
array @phan-return array<array{socid?:int,default_rib?:string,frstrecur?:string,1000110000001?:string,datec:string,datem:string,label:string,bank:string,bic:string,iban:string,id:int,rum:string}> @phpstan-return array<array{socid?:int,default_rib?:string,frstrecur?:string,1000110000001?:string,datec:string,datem:string,label:string,bank:string,bic:string,iban:string,id:int,rum:string}>

@url GET {id}/bankaccounts

Exceptions
RestException

We select all the records that match the socid

Definition at line 1854 of file api_thirdparties.class.php.

References $id, $object, DolibarrApi\_checkAccessToResource(), and dolDecrypt().

◆ getCompanyNotification()

Thirdparties::getCompanyNotification ( $id)

Get company notifications for a third party.

Since
20.0.0 Initial implementation
Parameters
int$idID of the third party
Returns
array @phan-return array<array{id:int,socid:int,event:string,contact_id:int,datec:int,tms:string,type:string}> @phpstan-return array<array{id:int,socid:int,event:string,contact_id:int,datec:int,tms:string,type:string}>

@url GET {id}/notifications

Exceptions
RestException

We select all the records that match the socid

Definition at line 1563 of file api_thirdparties.class.php.

References $id, $object, and DolibarrApi\_checkAccessToResource().

◆ getFixedAmountDiscounts()

Thirdparties::getFixedAmountDiscounts ( $id,
$mode = 'customer',
$filter = "none",
$sortfield = "f.type",
$sortorder = 'ASC' )

Get fixed amount discount of a third party.

all sources: deposit, credit note, commercial offers, etc.

Since
7.0.0 Initial implementation
Parameters
int$idID of the third party
string$mode'customer' or 'supplier'
string$filterFilter exceptional discount. "none" will return every discount, "available" returns unapplied discounts, "used" returns applied discounts {@choice none,available,used}
string$sortfieldSort field
string$sortorderSort order

@url GET {id}/fixedamountdiscounts

Returns
array List of fixed discount of the third party @phan-return stdClass[] @phpstan-return stdClass[]
Exceptions
RestException400
RestException401
RestException404
RestException503

Definition at line 1118 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ getInvoicesQualifiedForCreditNote()

Thirdparties::getInvoicesQualifiedForCreditNote ( $id)

Return invoices qualified to be corrected by a credit note.

Invoices matching the following rules are returned (validated + payment on process) or classified (paid completely or paid partially) + not already replaced + not already a credit note

Since
7.0.0 Initial implementation
Parameters
int$idID of a third party

@url GET {id}/getinvoicesqualifiedforcreditnote

Returns
array @phan-return array<int,array{ref:string,status:int,type:int,paye:int,paymentornot:int}>|int @phpstan-return array<int,array{ref:string,status:int,type:int,paye:int,paymentornot:int}>|int
Exceptions
RestException400
RestException401
RestException404
RestException405

Definition at line 1520 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ getInvoicesQualifiedForReplacement()

Thirdparties::getInvoicesQualifiedForReplacement ( $id)

Return invoices qualified to be replaced by another invoice.

Since
7.0.0 Initial implementation
Parameters
int$idID of a third party

@url GET {id}/getinvoicesqualifiedforreplacement

Returns
array @phan-return array<int,array{id:int,ref:string,status:int,paid:int,alreadypaid:int}>|int @phpstan-return array<int,array{id:int,ref:string,status:int,paid:int,alreadypaid:int}>|int
Exceptions
RestException400
RestException401
RestException404
RestException405

Definition at line 1471 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ getOutStandingInvoices()

Thirdparties::getOutStandingInvoices ( $id,
$mode = 'customer' )

Get outstanding invoices for a third party.

Since
7.0.0 Initial implementation
Parameters
int$idID of the third party
string$mode'customer' or 'supplier'

@url GET {id}/outstandinginvoices

Returns
array List of outstanding invoices of the third party @phan-return array{opened?:float} @phpstan-return array{opened?:float}
Exceptions
RestException400
RestException401
RestException404

Definition at line 1025 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ getOutStandingOrder()

Thirdparties::getOutStandingOrder ( $id,
$mode = 'customer' )

Get outstanding orders for a third party.

Since
7.0.0 Initial implementation
Parameters
int$idID of the third party
string$mode'customer' or 'supplier'

@url GET {id}/outstandingorders

Returns
array List of outstandings orders of the third party @phan-return array{opened?:float} @phpstan-return array{opened?:float}
Exceptions
RestException400
RestException401
RestException404

Definition at line 980 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ getOutStandingProposals()

Thirdparties::getOutStandingProposals ( $id,
$mode = 'customer' )

Get outstanding proposals for a third party.

Since
7.0.0 Initial implementation
Parameters
int$idID of the third party
string$mode'customer' or 'supplier'

@url GET {id}/outstandingproposals

Returns
array List of outstandings proposals of thirdparty @phan-return array{opened?:float} @phpstan-return array{opened?:float}
Exceptions
RestException400
RestException401
RestException404

Definition at line 934 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ getSalesRepresentatives()

Thirdparties::getSalesRepresentatives ( $id,
$mode = 0 )

Get representatives of a third party.

Since
11.0.0 Initial implementation
Parameters
int$idID of the third party
int$mode0=Array with properties, 1=Array of id.

@url GET {id}/representatives

Returns
array List of representatives of the third party @phan-return int[]|array<array{id:int,lastname:string,firstname:string,email:string,phone:string,office_phone:string,office_fax:string,user_mobile:string,personal_mobile:string,job:string,statut:int,status:int,entity:int,login:string,photo:string,gender:string}> @phpstan-return int[]|array<array{id:int,lastname:string,firstname:string,email:string,phone:string,office_phone:string,office_fax:string,user_mobile:string,personal_mobile:string,job:string,statut:int,status:int,entity:int,login:string,photo:string,gender:string}>
Exceptions
RestException400
RestException401
RestException404

Definition at line 1070 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ getSocieteAccounts()

Thirdparties::getSocieteAccounts ( $id,
$site = null )

Get a specific account attached to a third party.

Specify the site key

Since
9.0.0 Initial implementation
Parameters
int$idID of the third party
string$siteSite key
Returns
array|mixed
Exceptions
RestException401 Unauthorized: User does not have permission to read thirdparties
RestException404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty

@url GET {id}/accounts/

We select all the records that match the socid

Definition at line 2194 of file api_thirdparties.class.php.

References $id, $object, and DolibarrApi\_checkAccessToResource().

◆ getSocieteByAccounts()

Thirdparties::getSocieteByAccounts ( $site,
$key_account )

Get a specific third party by account.

Since
21.0.0 Initial implementation
Parameters
string$siteSite key
string$key_accountKey of the account
Returns
array|mixed
Exceptions
RestException401 Unauthorized: User does not have permission to read thirdparties
RestException404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty

@url GET /accounts/{site}/{key_account}

Exceptions
RestException

Definition at line 2271 of file api_thirdparties.class.php.

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

◆ getSupplierCategories()

Thirdparties::getSupplierCategories ( $id,
$sortfield = "s.rowid",
$sortorder = 'ASC',
$limit = 0,
$page = 0 )

Get supplier categories for a third party.

Since
7.0.0 Initial implementation
Parameters
int$idID of the third party
string$sortfieldSort field
string$sortorderSort order
int$limitList limit
int$pagePage number
Returns
array @phan-return array<int,array{id:int,fk_parent:int,label:string,description:string,color:string,position:int,socid:int,type:string,entity:int,array_options:array<string,mixed>,visible:int,ref_ext:string,multilangs?:array<string,array{label:string,description:string,note?:string}>}> @phpstan-return array<int,array{id:int,fk_parent:int,label:string,description:string,color:string,position:int,socid:int,type:string,entity:int,array_options:array<string,mixed>,visible:int,ref_ext:string,multilangs?:array<string,array{label:string,description:string,note?:string}>}>

@url GET {id}/supplier_categories

Exceptions
RestException

Definition at line 801 of file api_thirdparties.class.php.

References $id.

◆ index()

Thirdparties::index ( $sortfield = "t.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$mode = 0,
$category = 0,
$sqlfilters = '',
$properties = '',
$pagination_data = false )

List third parties.

Get a list of third parties

Since
3.8.0 Initial implementation
21.0.0 Data pagination
Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitList limit
int$pagePage number
int$modeSet to 0 to show all third parties, Set to 1 to show only customers, 2 for prospects, 3 for neither customer nor prospect, 4 for suppliers
int$categoryUse this param to filter the list by category
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "((t.nom:like:'TheCompany%') or (t.name_alias:like:'TheCompany%')) and (t.datec:<:'20160101')"
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
bool$pagination_dataIf this parameter is set to true, the response will include pagination data. The default value is false. Page starts from 0*
Returns
array Array of third party objects @phan-return Societe[]|array{data:Societe[],pagination:array{total:int,page:int,page_count:int,limit:int}} @phpstan-return Societe[]|array{data:Societe[],pagination:array{total:int,page:int,page_count:int,limit:int}}
Exceptions
RestException400
RestException403
RestException404
RestException503

Definition at line 155 of file api_thirdparties.class.php.

References _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), isModEnabled(), and string.

◆ merge()

Thirdparties::merge ( $id,
$idtodelete )

Merge a third party into another third party.

Merge content (properties, notes) and objects (like invoices, events, orders, proposals, ...) of a third party into a target third party, then delete the merged third party. If a property has a defined value both in the third party to delete and the third party to keep, the value of the third party to delete will be ignored, the value of the target third party will remain, except for notes (content is concatenated).

Since
7.0.0 Initial implementation
Parameters
int$idID of thirdparty to keep (the target third party)
int$idtodeleteID of thirdparty to remove (the third party to delete), once data has been merged into the target third party.
Returns
Object Return the resulted third party.

@phan-return Societe @phpstan-return Societe

@url PUT {id}/merge/{idtodelete}

Exceptions
RestException

Definition at line 437 of file api_thirdparties.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ post()

Thirdparties::post ( $request_data = null)

Create a third party.

Since
3.8.0 Initial implementation
Parameters
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
int ID of third party
Exceptions
RestException

Definition at line 308 of file api_thirdparties.class.php.

References $id, DolibarrApi\_checkValExtrafieldsForAPI(), DolibarrApi\_checkValForAPI(), _validate(), dol_getIdFromCode(), isModEnabled(), and sanitizeVal().

◆ postSocieteAccount()

Thirdparties::postSocieteAccount ( $id,
$site,
$request_data = null )

Create and attach a new (or replace an existing) specific site account for a third party.

You MUST pass all values to keep (otherwise, they will be deleted) !
If you just need to update specific fields prefer PUT /thirdparties/{id}/accounts/{site} endpoint.

When a SocieteAccount entity does not exist for the id and site supplied, a new one will be created. In that case fk_soc and site members form request body payload will be ignored and id and site query strings parameters will be used instead.

Since
9.0.0 Initial implementation
Parameters
int$idID of the third party
string$siteSite key
array$request_dataRequest data
Returns
array|mixed

@phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

Exceptions
RestException401 Unauthorized: User does not have permission to read thirdparties
RestException422 Unprocessable Entity: You must pass the site attribute in your request data !
RestException500 Internal Server Error: Error updating SocieteAccount entity

@url POST {id}/accounts/{site}

Definition at line 2388 of file api_thirdparties.class.php.

References $id, DolibarrApi\_checkValForAPI(), _cleanObjectDatas(), and sanitizeVal().

◆ put()

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

Update third party.

Since
3.8.0 Initial implementation
Parameters
int$idID of thirdparty to update
array$request_dataData @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
Object Updated object @phan-return Societe @phpstan-return Societe
Exceptions
RestException401
RestException404
RestException500

Definition at line 372 of file api_thirdparties.class.php.

References $id, DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValExtrafieldsForAPI(), DolibarrApi\_checkValForAPI(), isModEnabled(), and sanitizeVal().

◆ putSocieteAccount()

Thirdparties::putSocieteAccount ( $id,
$site,
$request_data = null )

Update specified values of a specific account attached to a third party.

Since
9.0.0 Initial implementation
Parameters
int$idID of the third party
string$siteSite key
array$request_dataRequest data
Returns
array|mixed

@phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

Exceptions
RestException401 Unauthorized: User does not have permission to read thirdparties
RestException404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty
RestException409 Conflict: Another SocieteAccount entity already exists for this thirdparty with this site key.
RestException500 Internal Server Error: Error updating SocieteAccount entity

@url PUT {id}/accounts/{site}

Definition at line 2486 of file api_thirdparties.class.php.

References $id, DolibarrApi\_checkValForAPI(), _cleanObjectDatas(), and sanitizeVal().

◆ setThirdpartyPriceLevel()

Thirdparties::setThirdpartyPriceLevel ( $id,
$priceLevel )

Set a new price level for the given third party.

Since
13.0.0 Initial implementation
Parameters
int$idID of thirdparty
int$priceLevelPrice level to apply to thirdparty
Returns
Object Thirdparty data without useless information

@url PUT {id}/setpricelevel/{priceLevel}

Exceptions
RestException400 Price level out of bounds
RestException401 Access not allowed for your login
RestException404 Third party not found
RestException500 Error fetching/setting price level
RestException501 Request needs modules "Thirdparties" and "Products" and setting Multiprices activated

Definition at line 533 of file api_thirdparties.class.php.

References $conf, $id, DolibarrApi\_checkAccessToResource(), _cleanObjectDatas(), getDolGlobalString(), and isModEnabled().

◆ splitdiscount()

Thirdparties::splitdiscount ( $id,
$discountid,
$amount_ttc_1,
$amount_ttc_2 )

Split a discount in 2 smaller discount.

Parameters
int$idID of the thirdparty
int$discountidID of a discount coming from a credit note
float$amount_ttc_1Amount 1 (inc. tax)
float$amount_ttc_2Amount 2 (inc. tax)

@url POST {id}/splitdiscount/{discountid}

Returns
array List of fixed discount of the third party @phan-return stdClass[] @phpstan-return stdClass[]
Exceptions
RestException400
RestException401
RestException403
RestException404
RestException405
RestException409
RestException500

Definition at line 1310 of file api_thirdparties.class.php.

References $id, DolibarrApi\_checkAccessToResource(), and price2num().

◆ updateCompanyBankAccount()

Thirdparties::updateCompanyBankAccount ( $id,
$bankaccount_id,
$request_data = null )

Update a company bank account of a third party.

Since
9.0.0 Initial implementation
Parameters
int$idID of the third party
int$bankaccount_idID of CompanyBankAccount
array$request_dataRequest data
Returns
array|mixed BankAccount of the third party

@phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

@url PUT {id}/bankaccounts/{bankaccount_id}

Exceptions
RestException

Definition at line 2001 of file api_thirdparties.class.php.

References $id, DolibarrApi\_checkValForAPI(), _cleanObjectDatas(), dol_now(), and sanitizeVal().

◆ updateCompanyNotification()

Thirdparties::updateCompanyNotification ( $id,
$notification_id,
$request_data = null )

Update a company notification for a third party.

Since
20.0.0 Initial implementation
Parameters
int$idID of the third party
int$notification_idID of CompanyNotification
array$request_dataRequest data
Returns
array|mixed Notification for the third party

@phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

@url PUT {id}/notifications/{notification_id}

Exceptions
RestException

Definition at line 1811 of file api_thirdparties.class.php.

References $id, DolibarrApi\_checkValForAPI(), and _cleanObjectDatas().


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