dolibarr 25.0.0-alpha
BankAccounts Class Reference
Inheritance diagram for BankAccounts:
Collaboration diagram for BankAccounts:

Public Member Functions

 __construct ()
 Constructor.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $category=0, $sqlfilters='', $properties='')
 Get the list of accounts.
 
 get ($id)
 Get account by ID.
 
 post ($request_data=null)
 Create account object.
 
 transfer ($bankaccount_from_id=0, $bankaccount_to_id=0, $date=null, $description="", $amount=0.0, $amount_to=0.0, $cheque_number="")
 Create an internal wire transfer between two bank accounts.
 
 put ($id, $request_data=null)
 Update account.
 
 delete ($id)
 Delete account.
 
 getLines ($id, $sqlfilters='')
 Get the list of lines of the account.
 
 addLine ($id, $date, $type, $label, $amount, $category=0, $cheque_number='', $cheque_writer='', $cheque_bank='', $accountancycode='', $datev=null, $num_releve='')
 Add a line to an account.
 
 addLink ($id, $line_id, $url_id, $url, $label, $type)
 Add a link to an account line.
 
 getLinks ($id, $line_id)
 Get the list of links for a line of the account.
 
 getDetailAccountLine ($line_id)
 Get the detail of a given line of the bank account.
 
 updateLine ($id, $line_id, $label)
 Update an account line.
 
 deleteLine ($id, $line_id)
 Delete an account line.
 
 reconcile ($id, $num_releve, $lines, $conciliated=1, $catid=0)
 Reconcile account lines with a bank statement.
 
 getBalance ($id)
 Get the current account balance.
 
- 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 creating an 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', $parenttableforentity='')
 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 35 of file api_bankaccounts.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

BankAccounts::_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 440 of file api_bankaccounts.class.php.

References $object.

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

◆ _validate()

BankAccounts::_validate ( $data)
private

Validate fields before creating an object.

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

Definition at line 415 of file api_bankaccounts.class.php.

Referenced by post().

◆ addLine()

BankAccounts::addLine ( $id,
$date,
$type,
$label,
$amount,
$category = 0,
$cheque_number = '',
$cheque_writer = '',
$cheque_bank = '',
$accountancycode = '',
$datev = null,
$num_releve = '' )

Add a line to an account.

Parameters
int$idID of account
string$datePayment date (timestamp) {@from body} {@type timestamp}
string$typePayment mode (TYP,VIR,PRE,LIQ,VAD,CB,CHQ...) {@from body}
string$labelLabel {@from body}
float$amountAmount (may be 0) {@from body}
int$categoryCategory
string$cheque_numberCheque numero {@from body}
string$cheque_writerName of cheque writer {@from body}
string$cheque_bankBank of cheque writer {@from body}
string$accountancycodeAccountancy code {@from body}
string$datevPayment date value (timestamp) {@from body} {@type timestamp}
string$num_releveBank statement numero {@from body}
Returns
int ID of line

@url POST {id}/lines

Definition at line 529 of file api_bankaccounts.class.php.

References $id, and sanitizeVal().

◆ addLink()

BankAccounts::addLink ( $id,
$line_id,
$url_id,
$url,
$label,
$type )

Add a link to an account line.

Parameters
int$idID of account
int$line_idID of account line
int$url_idID to set in the URL {@from body}
string$urlURL of the link {@from body}
string$labelLabel {@from body}
string$typeType of link ('payment', 'company', 'member', ...) {@from body}
Returns
int ID of link

@url POST {id}/lines/{line_id}/links

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

References $id, and sanitizeVal().

◆ delete()

BankAccounts::delete ( $id)

Delete account.

Parameters
int$idID of account
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}

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

References $id.

◆ deleteLine()

BankAccounts::deleteLine ( $id,
$line_id )

Delete an account line.

Parameters
int$idID of account
int$line_idID of account line
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}

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

Definition at line 724 of file api_bankaccounts.class.php.

References $id.

◆ get()

BankAccounts::get ( $id)

Get account by ID.

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

Definition at line 138 of file api_bankaccounts.class.php.

References $id, and _cleanObjectDatas().

◆ getBalance()

BankAccounts::getBalance ( $id)

Get the current account balance.

Parameters
int$idID of account
Returns
float $balance balance @url GET {id}/balance
Exceptions
RestException

Definition at line 883 of file api_bankaccounts.class.php.

References $id.

◆ getDetailAccountLine()

BankAccounts::getDetailAccountLine ( $line_id)

Get the detail of a given line of the bank account.

Parameters
int$line_idID of the account line
Returns
array|mixed Data without useless information. Note: If we use here AccountLine as return type, we got error if xdebug is on, due to infinite loop parsing of doc by Restler, we can disable this we commenting line 228 to 323 in CommonObject) @url GET /lines/{line_id}
Exceptions
RestException

Definition at line 657 of file api_bankaccounts.class.php.

References _cleanObjectDatas().

◆ getLines()

BankAccounts::getLines ( $id,
$sqlfilters = '' )

Get the list of lines of the account.

Parameters
int$idID of account
Returns
array Array of AccountLine objects @phan-return AccountLine[] @phpstan-return AccountLine[]
Exceptions
RestException

@url GET {id}/lines

Parameters
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')"

Definition at line 463 of file api_bankaccounts.class.php.

References $id, _cleanObjectDatas(), and forgeSQLFromUniversalSearchCriteria().

◆ getLinks()

BankAccounts::getLinks ( $id,
$line_id )

Get the list of links for a line of the account.

Parameters
int$idID of account
int$line_idID of account line
Returns
array Array of links @phan-return array<int,array{url:string,url_id:int,label:string,type:string,fk_bank:int}> @phpstan-return array<int,array{url:string,url_id:int,label:string,type:string,fk_bank:int}>
Exceptions
RestException

@url GET {id}/lines/{line_id}/links

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

References $id.

◆ index()

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

Get the list of accounts.

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
int$categoryUse this param to filter list by category
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')"
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
Returns
array List of account objects @phan-return Account[] @phpstan-return Account[]
Exceptions
RestException

Definition at line 73 of file api_bankaccounts.class.php.

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

◆ post()

BankAccounts::post ( $request_data = null)

Create account object.

Parameters
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
int ID of account

Definition at line 161 of file api_bankaccounts.class.php.

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

◆ put()

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

Update account.

Parameters
int$idID of account
array$request_datadata @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
Object Object with cleaned properties

Definition at line 338 of file api_bankaccounts.class.php.

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

◆ reconcile()

BankAccounts::reconcile ( $id,
$num_releve,
$lines,
$conciliated = 1,
$catid = 0 )

Reconcile account lines with a bank statement.

All lines are checked before any change and updated in one transaction, so a statement is never left half reconciled. A line already reconciled with the same statement is accepted, so the call can be replayed. A line reconciled with another statement is refused.

Parameters
int$idID of account
string$num_releveBank statement number {@from body} {@required true}
int[]$linesIDs of the account lines to reconcile {@from body} {@required true} {@type int} {@min 1}
int$conciliated1=Set lines as reconciled, 0=Only save the statement number {@from body}
int$catidID of a bank category to add to the lines {@from body}
Returns
array @phan-return array{num_releve:string,conciliated:int,lines:int[]} @phpstan-return array{num_releve:string,conciliated:int,lines:int[]}
Exceptions
RestException400 Bad statement number or category, empty list of lines or line of another account
RestException403 Access denied
RestException404 Account or line not found
RestException409 Line already reconciled with another statement
RestException503 Error when updating a line

@url POST {id}/reconcile

Since
25.0.0 Initial implementation

Definition at line 784 of file api_bankaccounts.class.php.

References $id, DolibarrApi\_checkAccessToResource(), dol_strlen(), getDolGlobalString(), and sanitizeVal().

◆ transfer()

BankAccounts::transfer ( $bankaccount_from_id = 0,
$bankaccount_to_id = 0,
$date = null,
$description = "",
$amount = 0.0,
$amount_to = 0.0,
$cheque_number = "" )

Create an internal wire transfer between two bank accounts.

Parameters
int$bankaccount_from_idBankAccount ID to use as the source of the internal wire transfer {@from body}{@required true}
int$bankaccount_to_idBankAccount ID to use as the destination of the internal wire transfer {@from body}{@required true}
string$dateDate of the internal wire transfer (UNIX timestamp) {@from body}{@required true}{@type timestamp}
string$descriptionDescription of the internal wire transfer {@from body}{@required true}
float$amountAmount to transfer from the source to the destination BankAccount {@from body}{@required true}
float$amount_toAmount to transfer to the destination BankAccount (only when accounts does not share the same currency) {@from body}{@required false}
string$cheque_numberCheque numero {@from body}{@required false}

@url POST /transfer

Returns
array @phan-return array{success:array{code:int,message:string,bank_id_from:int,bank_id_to:int}} @phpstan-return array{success:array{code:int,message:string,bank_id_from:int,bank_id_to:int}}

@status 201

Exceptions
RestException401 Unauthorized: User does not have permission to configure bank accounts
RestException404 Not Found: Either the source or the destination bankaccount for the provided id does not exist
RestException422 Unprocessable Entity: Refer to detailed exception message for the cause
RestException500 Internal Server Error: Error(s) returned by the RDBMS

Creating bank line records

Creating links between bank line record and its source

Definition at line 212 of file api_bankaccounts.class.php.

References price2num(), sanitizeVal(), and Account\TYPE_CASH.

◆ updateLine()

BankAccounts::updateLine ( $id,
$line_id,
$label )

Update an account line.

Parameters
int$idID of account
int$line_idID of account line
string$labelLabel {@from body}
Returns
int ID of link

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

Definition at line 682 of file api_bankaccounts.class.php.

References $id, and sanitizeVal().


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