Correction incohérence calcul montant amortissement

This commit is contained in:
Jean-Christophe Engel 2026-10-21 13:49:29 +02:00
parent 579ae55434
commit d54887a18d
2 changed files with 3 additions and 3 deletions

View file

@ -93,7 +93,7 @@ function getNumber(text) {
// @param date de fin
// @result montant de l'amortissement
function computeAmort(montant_immo, duree_immo, somme_amort, date_debut, date_fin) {
const nbjours = 1 + (date_fin - date_debut) / (60*60*24);
const nbjours = Math.round(1 + Math.abs((date_fin - date_debut)) / (60*60*24));
return Math.round(Math.min(montant_immo / duree_immo / 365 * nbjours, montant_immo - somme_amort));
}
@ -131,7 +131,7 @@ function displayAmort(id_immo, id_duree, id_amort, id_years, id_exercices, id_mo
const somme_amort = Number(document.getElementById(id_amort).value);
const montant_amort = computeAmort(montant_immo, duree_immo, somme_amort, date_debut, date_fin);
case_montant.value = montant_amort/100;
case_montant.innerText = montant_amort;
case_montant.innerText = montant_amort/100;
}
function setSelectorYear(button_names, f_years_selector)