dolibarr 24.0.0-beta
AccountancyCategory Class Reference

Class to manage categories of an accounting account. More...

Public Member Functions

 __construct ($db)
 Constructor.
 
 create ($user, $notrigger=0)
 Create object into database.
 
 fetch ($id, $code='', $label='')
 Load object in memory from database.
 
 update ($user=null, $notrigger=0)
 Update object into database.
 
 delete ($user, $notrigger=0)
 Delete object in database.
 
 display ($id)
 Function to select into ->lines_display all accounting accounts for a given custom accounting group.
 
 getAccountsWithNoCategory ($id)
 Function to fill ->lines_cptbk with accounting account (defined in chart of account) and not yet into a custom group.
 
 updateAccAcc ($id_cat, $cpts=array())
 Function to add an accounting account in an accounting category.
 
 deleteCptCat ($cpt_id)
 Function to delete an accounting account from an accounting category.
 
 getSumDebitCredit ($cpt, $date_start, $date_end, $sens, $thirdparty_code='nofilter', $month=0, $year=0)
 Function to set the property ->sdc (and ->sdcperaccount) that is the result of an accounting account from the ledger with a direction and a period.
 
 getCatsCpts ($catid=0)
 Function to get an array of all active custom groups (llx_c_accunting_categories) with their accounts from the chart of account (ll_accounting_acount)
 
 getCats ($categorytype=-1, $active=1, $id_report=1)
 Return list of custom groups.
 
 getCptsCat ($cat_id, $sanitizedpredefinedgroupwhere='')
 Get all accounting account of a given custom group (or a list of custom groups).
 
 addAccountToCategory ($fkAccountingAccount)
 Link an accounting account to this category (multi-report system)
 
 deleteAccountFromCategory ($fkAccountingAccount)
 Unlink an accounting account from this category (multi-report system)
 
 getAccountsForCategory ()
 Get all accounting accounts linked to this category (multi-report system)
 
 getCategoriesForAccount ($fkAccountingAccount)
 Get categories for a specific accounting account (multi-report system)
 
 isAccountInCategory ($fkAccountingAccount)
 Check if an account belongs to this category (multi-report system)
 
 getAvailableAccountsForCategory ()
 Get all accounting accounts NOT linked to this category (for selection)
 
 addMultipleAccountsToCategory (array $accountIds)
 Add multiple accounts to this category at once.
 
 removeAllAccountsFromCategory ()
 Remove all accounts from this category.
 
 countAccountsInCategory ()
 Count number of accounts linked to this category.
 

Detailed Description

Class to manage categories of an accounting account.

Definition at line 33 of file accountancycategory.class.php.

Constructor & Destructor Documentation

◆ __construct()

AccountancyCategory::__construct ( $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 146 of file accountancycategory.class.php.

Member Function Documentation

◆ addAccountToCategory()

AccountancyCategory::addAccountToCategory ( $fkAccountingAccount)

Link an accounting account to this category (multi-report system)

Parameters
int$fkAccountingAccountID of the accounting account to link
Returns
int<-1,1> <0 if KO, 0 if already exists, >0 if OK

Definition at line 922 of file accountancycategory.class.php.

References dol_syslog(), and isAccountInCategory().

◆ addMultipleAccountsToCategory()

AccountancyCategory::addMultipleAccountsToCategory ( array $accountIds)

Add multiple accounts to this category at once.

Parameters
array<int>$accountIds Array of accounting account IDs
Returns
int<-1,max> Number of accounts added, -1 if error

Definition at line 1148 of file accountancycategory.class.php.

References isAccountInCategory().

◆ countAccountsInCategory()

AccountancyCategory::countAccountsInCategory ( )

Count number of accounts linked to this category.

Returns
int Number of accounts, <0 if error

Definition at line 1213 of file accountancycategory.class.php.

References dol_syslog().

◆ create()

AccountancyCategory::create ( $user,
$notrigger = 0 )

Create object into database.

Parameters
User$userUser that create
int$notrigger0=launch triggers after, 1=disable triggers
Returns
int Return integer <0 if KO, Id of created object if OK

Definition at line 159 of file accountancycategory.class.php.

References $conf, active, dol_syslog(), and position.

◆ delete()

AccountancyCategory::delete ( $user,
$notrigger = 0 )

Delete object in database.

Parameters
User$userUser that delete
int$notrigger0=launch triggers after, 1=disable triggers
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 400 of file accountancycategory.class.php.

References dol_syslog().

◆ deleteAccountFromCategory()

AccountancyCategory::deleteAccountFromCategory ( $fkAccountingAccount)

Unlink an accounting account from this category (multi-report system)

Parameters
int$fkAccountingAccountID of the accounting account to unlink
Returns
int<-1,1> <0 if KO, >0 if OK

Definition at line 955 of file accountancycategory.class.php.

References dol_syslog().

◆ deleteCptCat()

AccountancyCategory::deleteCptCat ( $cpt_id)

Function to delete an accounting account from an accounting category.

Parameters
int$cpt_idId of accounting account
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 591 of file accountancycategory.class.php.

References dol_syslog().

◆ display()

AccountancyCategory::display ( $id)

Function to select into ->lines_display all accounting accounts for a given custom accounting group.

Parameters
int$idId
Returns
int Return integer <0 if KO, 0 if not found, >0 if OK

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

References $conf, dol_syslog(), and getDolGlobalInt().

◆ fetch()

AccountancyCategory::fetch ( $id,
$code = '',
$label = '' )

Load object in memory from database.

Parameters
int$idId object
string$codeCode
string$labelLabel
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 259 of file accountancycategory.class.php.

References active, dol_syslog(), and position.

◆ getAccountsForCategory()

AccountancyCategory::getAccountsForCategory ( )

Get all accounting accounts linked to this category (multi-report system)

Returns
array<int,array{id:int,account_number:string,label:string}> Array of accounting accounts indexed by account ID, or empty array if error

Definition at line 982 of file accountancycategory.class.php.

References $conf, and dol_syslog().

◆ getAccountsWithNoCategory()

AccountancyCategory::getAccountsWithNoCategory ( $id)

Function to fill ->lines_cptbk with accounting account (defined in chart of account) and not yet into a custom group.

Parameters
int$idId of category to know which account to exclude
Returns
int Return integer <0 if KO, 0 if not found, >0 if OK

Definition at line 476 of file accountancycategory.class.php.

References $conf, dol_syslog(), and getDolGlobalInt().

◆ getAvailableAccountsForCategory()

AccountancyCategory::getAvailableAccountsForCategory ( )

Get all accounting accounts NOT linked to this category (for selection)

Returns
array<array{id:int,account_number:string,label:string}> Array of available accounts, or empty array if error

Definition at line 1093 of file accountancycategory.class.php.

References $conf, dol_getIdFromCode(), dol_syslog(), and getDolGlobalInt().

◆ getCategoriesForAccount()

AccountancyCategory::getCategoriesForAccount ( $fkAccountingAccount)

Get categories for a specific accounting account (multi-report system)

Parameters
int$fkAccountingAccountID of the accounting account
Returns
array<int,array{id:int,code:string,label:string,fk_report:int}> Array of categories indexed by category ID, or empty array if error

Definition at line 1026 of file accountancycategory.class.php.

References $conf, and dol_syslog().

◆ getCats()

AccountancyCategory::getCats ( $categorytype = -1,
$active = 1,
$id_report = 1 )

Return list of custom groups.

For list + detail of accounting account, see getCatsCpt()

Parameters
int$categorytype-1=All, 0=Only non computed groups, 1=Only computed groups
int$active1= active, 0=not active
int$id_reportid of the report
Returns
never|array<array{rowid:string,code:string,label:string,formula:string,position:string,category_type:string,sens:string,dc:string}>|int Array of groups or -1 if error
See also
getCatsCpts(), getCptsCat()

Definition at line 786 of file accountancycategory.class.php.

References $conf, $mysoc, dol_print_error(), and dol_syslog().

◆ getCatsCpts()

AccountancyCategory::getCatsCpts ( $catid = 0)

Function to get an array of all active custom groups (llx_c_accunting_categories) with their accounts from the chart of account (ll_accounting_acount)

Parameters
int$catidCustom group ID
Returns
array<string,array<int,array{id:int,code:string,label:string,position:string,category_type:string,formula:string,sens:string,dc:string,account_number:string,account_label:string}>>|int<-1,-1> Result in table (array), -1 if KO
See also
getCats(), getCptsCat()

Definition at line 721 of file accountancycategory.class.php.

References $conf, $mysoc, and dol_syslog().

◆ getCptsCat()

AccountancyCategory::getCptsCat ( $cat_id,
$sanitizedpredefinedgroupwhere = '' )

Get all accounting account of a given custom group (or a list of custom groups).

You must choose between first parameter (personalized group) or the second (free criteria filter)

Parameters
int$cat_idId if personalized accounting group/category
string$sanitizedpredefinedgroupwhereSql criteria filter to select accounting accounts. This value must be sanitized and not come from an input of a user. Example: "pcg_type = 'EXPENSE' AND fk_pcg_version = 'xx'" Example: "fk_accounting_category = 99"
Returns
never|array<array{id:int,account_number:string,account_label:string}>|int<-1,-1> Array of accounting accounts or -1 if error
See also
getCats(), getCatsCpts()

Definition at line 851 of file accountancycategory.class.php.

References $conf, $mysoc, dol_getIdFromCode(), dol_print_error(), dol_syslog(), and getDolGlobalInt().

◆ getSumDebitCredit()

AccountancyCategory::getSumDebitCredit ( $cpt,
$date_start,
$date_end,
$sens,
$thirdparty_code = 'nofilter',
$month = 0,
$year = 0 )

Function to set the property ->sdc (and ->sdcperaccount) that is the result of an accounting account from the ledger with a direction and a period.

Parameters
int|array<?string>$cpt Accounting account or array of accounting account
int$date_startDate start
int$date_endDate end
int<0,1>$sens Sens of the account: 0: credit - debit (use this by default), 1: debit - credit
string$thirdparty_codeThird party code
int$monthSpecific month - Can be empty
int$yearSpecific year - Can be empty
Returns
integer Return integer <0 if KO, >= 0 if OK

Definition at line 635 of file accountancycategory.class.php.

References $conf, $date_start, dol_get_first_day(), dol_get_last_day(), dol_syslog(), and string.

◆ isAccountInCategory()

AccountancyCategory::isAccountInCategory ( $fkAccountingAccount)

Check if an account belongs to this category (multi-report system)

Parameters
int$fkAccountingAccountID of the accounting account
Returns
bool True if account is in category, false otherwise

Definition at line 1071 of file accountancycategory.class.php.

References dol_syslog().

Referenced by addAccountToCategory(), and addMultipleAccountsToCategory().

◆ removeAllAccountsFromCategory()

AccountancyCategory::removeAllAccountsFromCategory ( )

Remove all accounts from this category.

Returns
int<-1,max> Number of deleted relations if OK, -1 if error

Definition at line 1186 of file accountancycategory.class.php.

References dol_syslog().

◆ update()

AccountancyCategory::update ( $user = null,
$notrigger = 0 )

Update object into database.

Parameters
User$userUser that modify
int$notrigger0=launch triggers after, 1=disable triggers
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 318 of file accountancycategory.class.php.

References $conf, active, dol_syslog(), and position.

◆ updateAccAcc()

AccountancyCategory::updateAccAcc ( $id_cat,
$cpts = array() )

Function to add an accounting account in an accounting category.

Parameters
int$id_catId category
array<string,?string>$cpts list of accounts array
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 520 of file accountancycategory.class.php.

References $conf, dol_syslog(), getDolGlobalInt(), and length_accountg().


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