NEW FY Changed Period handle in Module Asset (#31618)
* NEW FY Changed Period handle in Module Asset NEW This is the code modification to take in consideration any changed in fiscal year period adjustments to shortened or extended periods (e.g., fiscal years of 9 or 15 months) * Clean asset.class.php
This commit is contained in:
parent
6dd6ab7906
commit
e98402ab64
1 changed files with 10 additions and 4 deletions
|
|
@ -1109,9 +1109,14 @@ class Asset extends CommonObject
|
|||
}
|
||||
}
|
||||
$depreciation_ht = (float) price2num($period_amount * $nb_days / $nb_days_in_month, 'MT');
|
||||
} else { // Annually
|
||||
$nb_days = min($nb_days_in_year, num_between_day($begin_date, $end_date, 1));
|
||||
$depreciation_ht = (float) price2num($period_amount * $nb_days / $nb_days_in_year, 'MT');
|
||||
} else { // Annually, taking care for adjustments to shortened or extended periods (e.g., fiscal years of 9 or 15 months)
|
||||
$nb_days_real = num_between_day($begin_date, $end_date, 1);
|
||||
if (($nb_days_real > 366) || (num_between_day($fiscal_period_start, $fiscal_period_end, 1) < $nb_days_in_year)) { // FY Period changed
|
||||
$nb_days = $nb_days_real;
|
||||
} else {
|
||||
$nb_days = min($nb_days_in_year, $nb_days_real);
|
||||
}
|
||||
$depreciation_ht = (double) price2num($period_amount * $nb_days / $nb_days_in_year, 'MT');
|
||||
}
|
||||
if (getDolGlobalInt('ASSET_ROUND_INTEGER_NUMBER_UPWARDS') == 1) {
|
||||
if ($idx_loop < $max_loop) { // avoid last depreciation value
|
||||
|
|
@ -1135,12 +1140,13 @@ class Asset extends CommonObject
|
|||
|
||||
// Next fiscal period (+1 day/month/year)
|
||||
$fiscal_period_start = dol_time_plus_duree($fiscal_period_end, 1, 'd');
|
||||
$dates_fiscal_period = getCurrentPeriodOfFiscalYear($this->db, $conf, $fiscal_period_start, 'gmt');
|
||||
if ($fields['duration_type'] == 2) { // Daily
|
||||
$fiscal_period_end = $fiscal_period_start;
|
||||
} elseif ($fields['duration_type'] == 1) { // Monthly
|
||||
$fiscal_period_end = dol_time_plus_duree(dol_time_plus_duree($fiscal_period_start, 1, 'm'), -1, 'd');
|
||||
} else { // Annually
|
||||
$fiscal_period_end = dol_time_plus_duree(dol_time_plus_duree($fiscal_period_start, 1, 'y'), -1, 'd');
|
||||
$fiscal_period_end = $dates_fiscal_period['date_end'];
|
||||
}
|
||||
$last_period_date = $disposal_date !== "" && $disposal_date < $depreciation_date_end ? $disposal_date : $depreciation_date_end;
|
||||
} while ($fiscal_period_start < $last_period_date);
|
||||
|
|
|
|||
Loading…
Reference in a new issue