From d9fa180be8315ca9ce639462eb54cb48a655166d Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Tue, 19 May 2026 11:43:40 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20d=C3=A9tection=20amortissem?= =?UTF-8?q?ents=20orphelins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _nav.html | 26 ++++++++++++++++++++++---- amortization.html | 25 +++++++++++++++++++------ other_amortizations.html | 2 ++ 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/_nav.html b/_nav.html index 57b9dee..a08ac55 100644 --- a/_nav.html +++ b/_nav.html @@ -5,13 +5,31 @@ + {{elseif $current == "index" && $subcurrent == "details"}} + {{elseif $subsubcurrent == "amortization" && $type_immo == null || $type_immo == "managed" || $type_immo == "other"}} {{/if}} @@ -20,7 +38,7 @@
  • Amorties
  • Sorties du bilan
  • En cours
  • -
  • Autres
  • +
  • À classer
  • Configuration
  • diff --git a/amortization.html b/amortization.html index 2d3e951..1af7148 100644 --- a/amortization.html +++ b/amortization.html @@ -101,27 +101,40 @@ {{/select}} {{/load}} -{{:assign autres_amortissements=false}} {{if $valeur_residuelle > 0}} {{* Chercher des amortissements non rattachés à une immo *}} {{#select line.id as amort_line_id, - line.id_transaction AS amort_trans_id + line.id_transaction AS amort_trans_id, + line.credit as amort_amount FROM acc_transactions_lines AS line INNER JOIN acc_accounts AS account ON account.id = line.id_account INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction INNER JOIN acc_years AS y ON y.id = trans.id_year WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) ORDER BY trans.date, trans.label; + assign="amort" }} - {{* cette ligne d'amortissement a-t-elle un doc associé ? *}} + {{* voir s'il existe des lignes d'immo liées à cette ligne d'amortissement *}} + {{:assign amort_amount=0}} + {{:assign keep_amort=true}} {{#load type="amort_link" where="$$.amort_line_id = :amort_line_id" :amort_line_id = $amort_line_id + assign="amort_link" }} + {{if $amort_link.amount == null || $amort_link.amount == 0}} + {{:assign amort_amount=$amort.amort_amount}} + {{:assign keep_amort=false}} + {{else}} + {{:assign amort_amount="%d+%d"|math:$amort_amount:$amort_link.amount}} + {{/if}} {{else}} - {{:assign autres_amortissements=true}} + {{* pas de ligne d'immo liée à cette ligne d'amort => garder cette ligne d'amortissement *}} {{/load}} + {{if $keep_amort && $amort_amount < $amort.amort_amount}} + {{:assign var="free_amort_lines." value=$amort}} + {{/if}} {{/select}} {{/if}} @@ -144,7 +157,7 @@ subcurrent="%s"|args:$subcurrent subsubcurrent="amortization" type_immo=$_GET.type_immo - autres_amort=$autres_amortissements + autres_amort=$free_amort_lines }} {{if $_GET.ok}} @@ -263,7 +276,7 @@

    Aucun amortissement enregistré pour cette immobilisation

    {{/if}} -{{if $autres_amortissements}} +{{if $free_amort_lines}}

    Il y a des écritures d'amortissement qui ne sont pas rattachées à une immobilisation !
    Utilisez le bouton « Rattacher un amortissement » pour les afficher ; vous pourrez choisir d'en attacher certaines à cette immobilisation. diff --git a/other_amortizations.html b/other_amortizations.html index 5163e78..e185d27 100644 --- a/other_amortizations.html +++ b/other_amortizations.html @@ -145,6 +145,8 @@ +{{else}} +

    Aucun amortissement à rattacher

    {{/if}} {{:form_errors}} {{:admin_footer}}