dolibarr 25.0.0-alpha
mod_codecompta_minga Class Reference

Class to manage accountancy code of thirdparties with Minga rules. More...

Inheritance diagram for mod_codecompta_minga:
Collaboration diagram for mod_codecompta_minga:

Public Member Functions

 __construct ()
 Constructor.
 
 info ($langs)
 Return description of module.
 
 getExample ($langs=null, $objsoc='', $type=-1)
 Return an example of result returned by getNextValue.
 
 get_code ($db, $societe, $type='')
 Set accountancy account code for a third party into this->code.
 
 getNumberFromCode ($code)
 Return the last group of digits of a thirdparty code ('CU2607-0435' gives '435'), limited to its last $this->nbdigits digits if set.
 
- Public Member Functions inherited from ModeleAccountancyCode
 getToolTip ($langs, $soc, $type)
 Return description of module parameters.
 
- Public Member Functions inherited from CommonNumRefGenerator
 getNom ($langs)
 Return model name.
 
 getName ($langs)
 Return model name.
 
 isEnabled ()
 Return if a module can be used or not.
 
 canBeActivated ($object)
 Checks if the numbers already in the database do not cause conflicts that would prevent this numbering working.
 
 getVersion ()
 Returns version of numbering module.
 

Public Attributes

const RANDOM_TRIES = 50
 Max number of random picks before scanning the range for a free number.
 

Private Member Functions

 cleanNumber ($value, $default)
 Return the number made of the digits of a string, or the default value if there is no digit.
 
 getUsedNumbers ($db, $start, $end)
 Load the numbers of the range already used as customer or supplier accountancy code.
 
 findFreeNumber ($used, $min, $max, $from, $step)
 Return the first free number of the range, starting at $from and moving in direction $step.
 

Detailed Description

Class to manage accountancy code of thirdparties with Minga rules.

Codes are numeric and taken from a range of numbers (one range for customers, one for suppliers), like the debtor (10000-69999) and creditor (70000-99999) accounts of the German charts SKR03/SKR04.

Definition at line 33 of file mod_codecompta_minga.php.

Member Function Documentation

◆ cleanNumber()

mod_codecompta_minga::cleanNumber ( $value,
$default )
private

Return the number made of the digits of a string, or the default value if there is no digit.

Parameters
string$valueValue to clean
int$defaultDefault value
Returns
int Number

Definition at line 113 of file mod_codecompta_minga.php.

Referenced by __construct().

◆ findFreeNumber()

mod_codecompta_minga::findFreeNumber ( $used,
$min,
$max,
$from,
$step )
private

Return the first free number of the range, starting at $from and moving in direction $step.

When a bound of the range is reached, the search continues from the other bound.

Parameters
array<int,int>$used Array with used numbers as keys
int$minStart of range
int$maxEnd of range
int$fromNumber to start the search from
int<-1,1>$step 1 to search upward, -1 to search downward
Returns
int Free number, -1 if the range is full

Definition at line 351 of file mod_codecompta_minga.php.

Referenced by get_code().

◆ get_code()

mod_codecompta_minga::get_code ( $db,
$societe,
$type = '' )

Set accountancy account code for a third party into this->code.

Parameters
DoliDB$dbDatabase handler
?Societe$societeThird party object
'customer'|'supplier'|''$type 'customer' or 'supplier'
Returns
int >=0 if OK, <0 if KO

Reimplemented from ModeleAccountancyCode.

Definition at line 208 of file mod_codecompta_minga.php.

References dol_syslog(), findFreeNumber(), getNumberFromCode(), and getUsedNumbers().

◆ getExample()

mod_codecompta_minga::getExample ( $langs = null,
$objsoc = '',
$type = -1 )

Return an example of result returned by getNextValue.

Parameters
?Translate$langsObject langs
Societe | string$objsocObject thirdparty
int<-1,2>$type Type of third party (1:customer, 2:supplier, -1:autodetect)
Returns
string Return string example

Reimplemented from ModeleAccountancyCode.

Definition at line 178 of file mod_codecompta_minga.php.

References getNumberFromCode().

◆ getNumberFromCode()

mod_codecompta_minga::getNumberFromCode ( $code)

Return the last group of digits of a thirdparty code ('CU2607-0435' gives '435'), limited to its last $this->nbdigits digits if set.

Parameters
string$codeCustomer or supplier code
Returns
string Number without leading zeros, '' if the code contains no digit

Definition at line 283 of file mod_codecompta_minga.php.

Referenced by get_code(), and getExample().

◆ getUsedNumbers()

mod_codecompta_minga::getUsedNumbers ( $db,
$start,
$end )
private

Load the numbers of the range already used as customer or supplier accountancy code.

Both columns are checked because customer and supplier accounts share the same numbering in accounting software (DATEV, ...).

Parameters
DoliDB$dbDatabase handler
int$startStart of range
int$endEnd of range
Returns
array<int,int>|int<-1,-1> Array with used numbers as keys, -1 if error

Definition at line 301 of file mod_codecompta_minga.php.

References getDolGlobalString().

Referenced by get_code().

◆ info()

mod_codecompta_minga::info ( $langs)

Return description of module.

Parameters
Translate$langsObject langs
Returns
string Description of module

Reimplemented from CommonNumRefGenerator.

Definition at line 126 of file mod_codecompta_minga.php.

References name.


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