class AccountancyCategory (View source)

Class to manage categories of an accounting account

Properties

DoliDB $db
string $error
string[] $errors
string $element
string $table_element
int deprecated $rowid
int $id
?string $code
?string $label
?string $range_account
?int $sens
?int $category_type
?string $formula
?int $position
?int $fk_country
?int $active
object[] $lines_cptbk
object[] $lines_display
mixed $sdc
array<string, float> $sdcpermonth
array<string, float> $sdcperaccount

Methods

__construct($db)

Constructor

create($user, int $notrigger = 0)

Create object into database

fetch($id, string $code = '', $label = '')

Load object in memory from database

update($user = null, int $notrigger = 0)

Update object into database

delete(User $user, $notrigger = 0)

Delete object in database

int
display(int $id)

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

int
getAccountsWithNoCategory(int $id)

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

int
updateAccAcc(int $id_cat, array<string, ?string> $cpts = array())

Function to add an accounting account in an accounting category

int
deleteCptCat(int $cpt_id)

Function to delete an accounting account from an accounting category

int
getSumDebitCredit(int|array<?string> $cpt, int $date_start, int $date_end, int<0, 1> $sens, string $thirdparty_code = 'nofilter', int $month = 0, int $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, $predefinedgroupwhere = '')

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

Details

__construct($db)

Constructor

@param DoliDB $db Database handler

Parameters

$db

create($user, int $notrigger = 0)

Create object into database

@param User $user User that create

Parameters

$user
int $notrigger

0=launch triggers after, 1=disable triggers @return int Return integer <0 if KO, Id of created object if OK

fetch($id, string $code = '', $label = '')

Load object in memory from database

@param int $id Id object

Parameters

$id
string $code

Code @param string $label Label @return int Return integer <0 if KO, >0 if OK

$label

update($user = null, int $notrigger = 0)

Update object into database

@param User $user User that modify

Parameters

$user
int $notrigger

0=launch triggers after, 1=disable triggers @return int Return integer <0 if KO, >0 if OK

delete(User $user, $notrigger = 0)

Delete object in database

Parameters

User $user

User that delete @param int $notrigger 0=launch triggers after, 1=disable triggers @return int Return integer <0 if KO, >0 if OK

$notrigger

int display(int $id)

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

Parameters

int $id Id

Return Value

int

Return integer <0 if KO, 0 if not found, >0 if OK

int getAccountsWithNoCategory(int $id)

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

Parameters

int $id

Id of category to know which account to exclude

Return Value

int

Return integer <0 if KO, 0 if not found, >0 if OK

int updateAccAcc(int $id_cat, array<string, ?string> $cpts = array())

Function to add an accounting account in an accounting category

Parameters

int $id_cat

Id category

array<string, ?string> $cpts

list of accounts array

Return Value

int

Return integer <0 if KO, >0 if OK

int deleteCptCat(int $cpt_id)

Function to delete an accounting account from an accounting category

Parameters

int $cpt_id

Id of accounting account

Return Value

int

Return integer <0 if KO, >0 if OK

int getSumDebitCredit(int|array<?string> $cpt, int $date_start, int $date_end, int<0, 1> $sens, string $thirdparty_code = 'nofilter', int $month = 0, int $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_start

Date start

int $date_end

Date end

int<0, 1> $sens

Sens of the account: 0: credit - debit (use this by default), 1: debit - credit

string $thirdparty_code

Third party code

int $month

Specific month - Can be empty

int $year

Specific year - Can be empty

Return Value

int

Return integer <0 if KO, >= 0 if OK

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

$catid

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

Return list of custom groups.

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

Parameters

$categorytype
$active
$id_report

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

$cat_id
$predefinedgroupwhere