Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset Amortissement France: num_between_day360 #30416

Open
alain029 opened this issue Jul 18, 2024 · 1 comment
Open

Asset Amortissement France: num_between_day360 #30416

alain029 opened this issue Jul 18, 2024 · 1 comment
Assignees
Labels
Feature request This is a feature request

Comments

@alain029
Copy link

Feature Request

En France, l'amortissement annuel porte sur 360 jours. Aussi dans le core/lib/date.lib.php, il serait utile de rajouter la fonction suivante: num_between_day360()
qui serait appelée dans le fichier asset.class.php à la ligne 1044 au lieu de num_between() pour l'amortissement annuel
Cela permet d'obtenir des tableaux d'amortissement conformes à la compta France.

/**

  • Function to return number of dys between two dates with 360 days in Year
  • Comptabilité France: Amortissement annuel sur 360 jours
    */

function num_between_day360($timestampStart, $timestampEnd, $lastday = 0)
{
if ($timestampStart < $timestampEnd) {
if ($lastday == 1) {
$bit = 0;
} else {
$bit = 1;
}
//$nbjours = (int) floor(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit;
$dateStart = new DateTime();
$dateStart->setTimestamp($timestampStart);
$dateEnd = new DateTime();
$dateEnd->setTimestamp($timestampEnd);
$diff = $dateStart->diff($dateEnd);
$days = $diff->d >= 30 ? 30 : $diff->d;
$nbjours = $diff->y * 360 + $diff->m * 30 + $days + 1 - $bit;

} else {
	$nbjours = 0;
}
//print ($timestampEnd - $timestampStart) - $lastday;
//print $nbjours;

return $nbjours;

}

Use case

No response

Suggested implementation

No response

Suggested steps

No response

@alain029 alain029 added the Feature request This is a feature request label Jul 18, 2024
@aspangaro aspangaro self-assigned this Aug 10, 2024
@aspangaro
Copy link
Member

Hello @alain029 ,

Interesting ! You have an example of a calculating problem with 360 days ?


Bonjour @alain029

Intéressant ! Vous avez un exemple de problème de calcul avec 360 jours ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request This is a feature request
Projects
None yet
Development

No branches or pull requests

2 participants