From d54887a18d66d24619016d63e0295502eff01260 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Wed, 21 Oct 2026 13:49:29 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20incoh=C3=A9rence=20calcul=20montan?= =?UTF-8?q?t=20amortissement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- save_amort.html | 2 +- scripts.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/save_amort.html b/save_amort.html index 43cc871..97a6e93 100644 --- a/save_amort.html +++ b/save_amort.html @@ -229,7 +229,7 @@ {{:assign var=date_amort value=$years.0.end_date}} {{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}} {{* montant de l'amortissement *}} - {{:assign montant_amort="%f/%f/365*%d"|math:$ligne_immo.amount:$info_immo.duration:$nbjours|intval}} + {{:assign montant_amort="round(%f/%f/365*%d,2)"|math:$ligne_immo.amount:$info_immo.duration:$nbjours|intval}} {{:assign montant_amort="min(%f, %d-%d)"|math:$montant_amort:$ligne_immo.amount:$total_amort}} {{/if}} diff --git a/scripts.js b/scripts.js index 1585e53..644ae39 100644 --- a/scripts.js +++ b/scripts.js @@ -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)