Add a graphical option to define duration per year for depreciation

This commit is contained in:
Alexandre SPANGARO 2022-02-16 05:18:29 +01:00
parent 11d1d9a0af
commit 948f20c2b6
3 changed files with 11 additions and 2 deletions

View File

@ -47,7 +47,7 @@ $type = 'asset';
$arrayofparameters = array(
'ASSET_ACCOUNTANCY_CATEGORY'=>array('type'=>'accountancy_category', 'enabled'=>1),
//'ASSET_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1),
'ASSET_DEPRECIATION_DURATION_PER_YEAR'=>array('type'=>'string', 'css'=>'minwidth200', 'enabled'=>1),
//'ASSET_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
//'ASSET_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
//'ASSET_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),

View File

@ -971,7 +971,7 @@ class Asset extends CommonObject
// futures depreciation lines
//-----------------------------------------------------
$nb_days_in_year = !empty($conf->global->ASSET_DEPRECIATION_DURATION_PER_YEAR) ? $conf->global->ASSET_DEPRECIATION_DURATION_PER_YEAR : 360;
$nb_days_in_year = !empty($conf->global->ASSET_DEPRECIATION_DURATION_PER_YEAR) ? $conf->global->ASSET_DEPRECIATION_DURATION_PER_YEAR : 365;
$nb_days_in_month = !empty($conf->global->ASSET_DEPRECIATION_DURATION_PER_MONTH) ? $conf->global->ASSET_DEPRECIATION_DURATION_PER_MONTH : 30;
$period_amount = (double) price2num($depreciation_period_amount / $fields['duration'], 'MT');
$first_period_found = false;

View File

@ -103,6 +103,15 @@ class modAsset extends DolibarrModules
// 1=>array('ASSETS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
// );
$this->const = array();
$this->const[1] = array(
"ASSET_DEPRECIATION_DURATION_PER_YEAR",
"chaine",
"365",
"Duration per year to calculate depreciation. In some case, can be 360 days",
0,
'current',
1
);
if (!isset($conf->asset) || !isset($conf->asset->enabled)) {