Compare commits

..

8 commits

Author SHA1 Message Date
Jean-Christophe Engel
d6bcaedd05 Autres amortissements : filtrer uniquement sur numéro compte 2026-06-12 12:08:46 +02:00
Jean-Christophe Engel
2b61fba8c1 Autres amortissements : afficher montant non affecté 2026-06-12 12:08:16 +02:00
Jean-Christophe Engel
dde5240860 Simplification traitement immo amortie pour cas suppression écriture amortissement 2026-06-12 11:48:53 +02:00
Jean-Christophe Engel
83c9fcb7cd Correction erreur message fin attachement avoir 2026-06-12 11:12:53 +02:00
Jean-Christophe Engel
4ec6c5b5b3 À classer : correction affichage lignes filtrées 2026-06-12 10:32:49 +02:00
Jean-Christophe Engel
f69b5a0ee8 Amélioration présentation page amortissements 2026-06-12 10:27:11 +02:00
Jean-Christophe Engel
a69737c429 Harmonisation affichage 2026-06-12 10:12:42 +02:00
Jean-Christophe Engel
f4205b372a Amélioration suppression documents orphelins 2026-06-12 10:02:57 +02:00
9 changed files with 93 additions and 92 deletions

View file

@ -41,6 +41,7 @@
{{* pas de ligne d'immo liée à cette ligne d'amort => garder cette ligne d'amortissement *}}
{{/load}}
{{if $keep_amort && $amort_amount < $amort_line.amount}}
{{:assign var="amort_line.amount" value="%d-%d"|math:$amort_line.amount:$amort_amount}}
{{:assign var="free_amort_lines." value=$amort_line}}
{{/if}}
{{/select}}

View file

@ -124,7 +124,7 @@
<td><a href="{{$compte_url}}">{{$account_code}}</a></td>
<td class="actions">
{{:linkbutton
label="Voir"
label="Détails"
href="amortization.html?immo_doc_id=%s&type_immo=%s"|args:$immo_doc_id:$type_immo shape="eye"
}}
</td>

View file

@ -114,7 +114,6 @@
{{:assign var="immo_lines." value=$immo_line}}
{{/select}}
{{*:debug lines=$immo_lines nb_lines=$immo_lines|count nb_null=$nb_null nb_managed=$nb_managed nb_ignored=$nb_ignored nb_other=$nb_other unhide=$unhide*}}
<form method="post" action="">
<fieldset>
@ -148,7 +147,7 @@
{{else}}
{{* vérifier si le libellé aurait pu être filtré *}}
{{#foreach from=$module.config.filters item="filter"}}
{{if $filter|strpos:$trans_label !== false}}
{{if $trans_label|strpos:$filter !== false}}
{{:assign status="ignored"}}
{{/if}}
{{/foreach}}

View file

@ -1,28 +1,45 @@
{{* -*- brindille -*- *}}
{{* supprimer les documents sans écriture associée *}}
{{:assign var="docs." type="amort_link" field="amort_line_id"}}
{{:assign var="docs." type="credit_link" field="credit_line_id"}}
{{:assign var="docs." type="cession_link" field="cession_line_id"}}
{{:assign var="docs." type="exit_link" field="exit_line_id"}}
{{:assign var="docs." type="immo" field="line"}}
{{if $module.table}}
{{* supprimer les documents sans écriture associée *}}
{{:assign var="docs." type="amort_link" field="amort_line_id"}}
{{:assign var="docs." type="credit_link" field="credit_line_id"}}
{{:assign var="docs." type="cession_link" field="cession_line_id"}}
{{:assign var="docs." type="exit_link" field="exit_line_id"}}
{{:assign var="docs." type="immo" field="line"}}
{{#foreach from=$docs}}
{{#foreach from=$docs}}
{{:assign join_field="$$."|cat:$field}}
{{:assign type_name=$type|quote_sql}}
{{:assign type_cond="$$.type"|cat:" = "|cat:$type_name}}
{{* vérifier existence écriture associée au doc *}}
{{#select
info.id
info.id as info_id,
$$.immo_doc_id as immo_doc_id,
line.id as line_id
FROM !table AS info
LEFT JOIN acc_transactions_lines as line ON !join_field = line.id
WHERE !type_cond AND line.id IS NULL
WHERE !type_cond
;
!table=$module.table
!type_cond = $type_cond
!join_field = $join_field
assign="line"
}}
{{:delete id=$id}}
{{if $line.line_id == null}}
{{:delete id=$line.info_id}}
{{/if}}
{{* vérifier existence doc immo *}}
{{if $type != "immo"}}
{{#load id=$immo_doc_id assign="immo_doc"}}
{{else}}
{{:delete id=$line.info_id}}
{{/load}}
{{/if}}
{{/select}}
{{/foreach}}
{{/foreach}}
{{/if}}

View file

@ -29,13 +29,7 @@
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_immos, total_credits"}}
{{:assign solde="%d-%d"|math:$ligne_immo.amount:$total_credits}}
{{if $info_immo.status == "amortized"}}
{{:assign amort_amount=$solde}}
{{:assign valeur_residuelle=0}}
{{else}}
{{:assign valeur_residuelle=$solde}}
{{/if}}
{{:assign valeur_residuelle=$solde}}
{{* lister les amortissements liés à l'immobilisation *}}
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, total_amort, created_amort"}}
@ -113,15 +107,14 @@
</form>
<h3 class="ruler">Immobilisation</h3>
<p class="actions-center">
<nav class="actions">
{{if $total_amort == 0}}
{{:linkbutton label="Modifier les paramètres" href="modify_infos.html?immo_doc_id=%s"|args:$_GET.immo_doc_id shape="edit" target="_dialog"}}
{{if ! $info_immo.created}}
{{:linkbutton label="Supprimer les paramètres" href="delete_infos.html?immo_doc_id=%s"|args:$_GET.immo_doc_id shape="delete" target="_dialog"}}
{{/if}}
{{/if}}
</p>
</nav>
<div class="informations">
<dl class="describe">
@ -145,7 +138,7 @@
{{/if}}
{{if $valeur_residuelle > 0}}
<dt>Montant des amortissements</dt>
<dd>{{"%d-%d"|math:$solde:$valeur_residuelle|money_currency_html:false|raw}}</dd>
<dd>{{$total_amort|money_currency_html:false|raw}}</dd>
<dt>Valeur nette résiduelle</dt>
<dd>{{$valeur_residuelle|money_currency_html:false|raw}}</dd>
{{/if}}
@ -156,8 +149,43 @@
</dl>
</div>
<h3 class="ruler">Avoirs</h3>
<nav class="actions">
{{if $total_amort == 0}}
{{:linkbutton label="Attacher une écriture d'avoir" href="link_immo.html?immo_doc_id=%s"|args:$_GET.immo_doc_id shape="link" target="_dialog"}}
{{/if}}
</nav>
{{if $linked_immos != null}}
<table class="list">
<thead>
<th class="num"></th>
<th>Date</th>
<th>Libellé</th>
<th class="nombre">Montant</th>
<th class="actions"></th>
</thead>
<tbody>
{{#foreach from=$linked_immos item="line"}}
{{:assign url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
<tr>
<td class="num"><a href="{{$url}}">#{{$line.trans_id}}</a></td>
<td>{{$line.date|date_short}}</td>
<td>{{$line.label}}</td>
<td class="money">{{"%f"|math:$line.amount|money_currency_html:false|raw}}</td>
<td>
{{if $total_amort == 0}}
{{:linkbutton label="Détacher" href="detach_credit.html?immo_doc_id=%s&credit_line_id=%s"|args:$_GET.immo_doc_id:$line.credit_line_id shape="minus"}}
{{/if}}
</td>
</tr>
{{/foreach}}
</tbody>
</table>
{{/if}}
<h3 class="ruler">Amortissements</h3>
<p class="actions-center">
<nav class="actions">
{{if $free_amort_lines && ! $created_amort}}
{{:linkbutton
label="Attacher un amortissement"
@ -172,7 +200,7 @@
href="save_amort.html?immo_doc_id=%s"|args:$_GET.immo_doc_id target="_dialog"
shape="plus"
}}
</p>
</nav>
{{if $linked_amort != null}}
<section class="amortissement">
@ -231,40 +259,5 @@
<p class="block alert">Aucun amortissement enregistré pour cette immobilisation ; utilisez le bouton « Enregistrer un amortissement » pour enregistrer un nouvel amortissement</p>
{{/if}}
<h3 class="ruler">Avoirs</h3>
<p class="actions-center">
{{if $total_amort == 0}}
{{:linkbutton label="Attacher une écriture d'avoir" href="link_immo.html?immo_doc_id=%s"|args:$_GET.immo_doc_id shape="link" target="_dialog"}}
{{/if}}
</p>
{{if $linked_immos != null}}
<table class="list">
<thead>
<th class="num"></th>
<th>Date</th>
<th>Libellé</th>
<th class="nombre">Montant</th>
<th class="actions"></th>
</thead>
<tbody>
{{#foreach from=$linked_immos item="line"}}
{{:assign url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
<tr>
<td class="num"><a href="{{$url}}">#{{$line.trans_id}}</a></td>
<td>{{$line.date|date_short}}</td>
<td>{{$line.label}}</td>
<td class="money">{{"%f"|math:$line.amount|money_currency_html:false|raw}}</td>
<td>
{{if $total_amort == 0}}
{{:linkbutton label="Détacher" href="detach_credit.html?immo_doc_id=%s&credit_line_id=%s"|args:$_GET.immo_doc_id:$line.credit_line_id shape="minus"}}
{{/if}}
</td>
</tr>
{{/foreach}}
</tbody>
</table>
{{/if}}
{{:form_errors}}
{{:admin_footer}}

View file

@ -107,7 +107,7 @@
{{if $_GET.from == "exit"}}
{{:redirect force="exit_step1.html?immo_doc_id=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id}}
{{else}}
{{:redirect force="amortization.html?immo_doc_id=%s&ok=1&msg=attach_credit"|args:$_GET.immo_doc_id}}
{{:redirect force="amortization.html?immo_doc_id=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id}}
{{/if}}
{{/form}}

View file

@ -188,14 +188,14 @@
<fieldset>
<legend>Paramètres de l'amortissement</legend>
<dl>
{{:input type="number" name="duree" label="Durée d'amortissement" min=1 default=$info_immo.duration}}
{{:input type="text" name="libelle" label="Libellé" default=$info_immo.label}}
{{:input type="number" name="duree" label="Durée d'amortissement" min=1 default=$info_immo.duration suffix="année(s)"}}
{{if $info_immo.amount != null}}
{{:assign max_aff="%f"|math:$max_disponible|money_currency:false}}
{{:input type="money" name="montant" label="Montant de l'immobilisation" default=$montant_immo help="Montant maximum : %s"|args:$max_aff}}
{{/if}}
{{:input type="date" name="date_achat" label="Date d'acquisition" default=$info_immo.date_achat}}
{{:input type="date" name="date_mes" label="Date de mise en service" default=$info_immo.date_mes}}
{{:input type="date" name="date_achat" label="Date d'acquisition" default=$info_immo.date_achat help="si différente de la date de l'écriture d'immobilisation"}}
{{:input type="date" name="date_mes" label="Date de mise en service" default=$info_immo.date_mes help="si différente de la date d'acquisition"}}
{{:input type="text" name="libelle" label="Libellé" default=$info_immo.label help="si différent du libellé de l'écriture d'immobilisation"}}
</dl>
</fieldset>
<p class="submit">

View file

@ -23,14 +23,7 @@
code_immo=$ligne_immo.account_code
keep="code_amort"
}}
{{:include file="_get_config.html" keep="module.config"}}
{{:assign account_condition="account.code = "|cat:$code_amort}}
{{:assign filter_condition=$account_condition|cat:" AND NOT ("}}
{{#foreach from=$module.config.filters item="filter"}}
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
{{:assign filter_condition=$filter_condition|cat:" trans.label LIKE "|cat:$filter|cat:" OR "}}
{{/foreach}}
{{:assign filter_condition=$filter_condition|cat:"0)"}}
{{:assign filter_condition="account.code = "|cat:$code_amort}}
{{else}}
{{:assign account_filter="28%"|quote_sql}}
{{:assign filter_condition="account.code LIKE "|cat:$account_filter}}

View file

@ -22,10 +22,6 @@
{{/if}}
{{:assign var="amort_label" value="Amortissement %s"|args:$amort_label}}
{{if $info_immo.status == "amortized" || $info_immo.status == "archived"}}
{{:error message="Cette immobilisation est complètement amortie ; il est impossible d'ajouter une écriture d'amortissement"}}
{{/if}}
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_credits"}}
{{:assign var="ligne_immo.amount" value="%d-%d"|math:$ligne_immo.amount:$total_credits}}
@ -82,7 +78,9 @@
{{:assign var="years_data.%d"|args:$id value=$ts_debut|cat:" "|cat:$ts_fin}}
{{:assign msg_years=$msg_years|cat:"\n"|cat:" - "|cat:$label|cat:" : "|cat:$debut|cat:" à "|cat:$fin}}
{{else}}
{{:error message="Aucun exercice ouvert pour enregistrer un amortissement"}}
{{:assign date_debut=$date_debut|date_short}}
{{:assign msg="Pas d'exercice ouvert pour enregistrer un amortissement à partir du %s"|args:$date_debut}}
{{:error message=$msg}}
{{/years}}
{{* Traiter l'envoi du formulaire *}}