dolibarr 20.0.0
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 show 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)
 Return list of custom groups.
 
 getCptsCat ($cat_id, $predefinedgroupwhere='')
 Get all accounting account of a given custom group (or a list of custom groups).
 

Detailed Description

Class to manage categories of an accounting account.

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

Constructor & Destructor Documentation

◆ __construct()

AccountancyCategory::__construct ( $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

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

Member Function Documentation

◆ 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 158 of file accountancycategory.class.php.

References dol_syslog(), position, and rowid.

◆ 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 399 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 587 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 dol_syslog().

◆ 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 258 of file accountancycategory.class.php.

References dol_syslog(), and position.

◆ 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 472 of file accountancycategory.class.php.

References dol_syslog(), and getDolGlobalInt().

◆ getCats()

AccountancyCategory::getCats ( $categorytype = -1,
$active = 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
Returns
array<array{code:string,label:string,formula:string,position:string,category_type:string,sens:string,bc:string}>|int Array of groups or -1 if error
See also
getCatsCpts(), getCptsCat()

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

References 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|integer Result in table (array), -1 if KO
See also
getCats(), getCptsCat()

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

References dol_syslog().

◆ getCptsCat()

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

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$predefinedgroupwhereSql 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
array|int Array of accounting accounts or -1 if error
See also
getCats(), getCatsCpts()

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

References 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 show result of an accounting account from the ledger with a direction and a period.

Parameters
int | array$cptAccounting account or array of accounting account
string$date_startDate start
string$date_endDate end
int$sensSens of the account: 0: credit - debit (use this by default), 1: debit - credit
string$thirdparty_codeThirdparty 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 631 of file accountancycategory.class.php.

References dol_get_first_day(), dol_get_last_day(), and 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 317 of file accountancycategory.class.php.

References 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$cptslist of accounts array
Returns
int Return integer <0 if KO, >0 if OK

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

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


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