Compare commits

...

6 commits

Author SHA1 Message Date
Jean-Christophe Engel
01677ef1b6 Changement de version 2026-07-13 14:00:23 +02:00
Jean-Christophe Engel
dff8047bb9 Suppression bouton inutile 2026-07-13 13:49:11 +02:00
Jean-Christophe Engel
f005eba37c Modification libellé écriture cession 2026-07-13 13:48:40 +02:00
Jean-Christophe Engel
18df7a8386 Correction libellé lignes immo créée par transfert 2026-07-13 13:47:37 +02:00
Jean-Christophe Engel
0837b94dbe Suppression todo inutiles 2026-07-13 12:02:28 +02:00
Jean-Christophe Engel
24707afd31 Réorganisation sortie bilan (onglets) + contrôle cohérence montant 2026-07-13 11:47:32 +02:00
24 changed files with 331 additions and 193 deletions

View file

@ -153,7 +153,7 @@
<td><a href="{{$compte_url}}">{{$account_code}}</a></td>
<td>{{$account_label}}</td>
<td class="actions">
{{:linkbutton label="Modifier" href="exit_step1.html?immo_doc_id=%s"|args:$info_immo.id shape="edit"}}
{{:linkbutton label="Modifier" href="exit_step1.html?immo_doc_id=%s&from=exit"|args:$info_immo.id shape="edit"}}
</td>
</tr>
{{/select}}

View file

@ -129,7 +129,6 @@
{{*
TODO cas où :
- il y a (au moins) une écriture d'avoir
- il y a une écriture qui solde l'immo (montant = montant immo - avoir
*}}
{{* voir s'il existe une écriture qui solde l'immobilisation (voir ci-dessus) *}}

View file

@ -130,7 +130,7 @@
{{/if}}
{{if $_GET.from == "exit"}}
{{:redirect force="exit_step2.html?immo_doc_id=%s&ok=1&msg=attach_amort"|args:$_GET.immo_doc_id}}
{{:redirect force="exit_step2.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_amort"|args:$_GET.immo_doc_id}}
{{else}}
{{:redirect force="amortization.html?immo_doc_id=%s&type_immo=%s&ok=1&msg=attach_amort"|args:$_GET.immo_doc_id:$status}}
{{/if}}

View file

@ -36,4 +36,4 @@
cession_line_id=$_GET.cession_line_id|intval
}}
{{:redirect force="exit_step3.html?immo_doc_id=%s&ok=1&msg=attach_cession"|args:$_GET.immo_doc_id}}
{{:redirect force="exit_step3.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_cession"|args:$_GET.immo_doc_id}}

View file

@ -93,10 +93,6 @@
{{* Lier l'écriture de crédit à l'écriture d'immobilisation *}}
{{:include file="_common_attach.html" immo_doc_id=$_GET.immo_doc_id trans_id=$credit_line.trans_id}}
{{*
TODO ? vérifier le succès avant d'enregistrer le doc ?
*}}
{{* enregistrer la liaison des lignes d'immo *}}
{{:save
key=""|uuid
@ -107,7 +103,7 @@
}}
{{if $_GET.from == "exit"}}
{{:redirect force="exit_step1.html?immo_doc_id=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id}}
{{:redirect force="exit_step1.html?immo_doc_id=%s&from=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id:$_GET.from}}
{{else}}
{{:redirect force="amortization.html?immo_doc_id=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id}}
{{/if}}

View file

@ -36,4 +36,4 @@
exit_line_id=$_GET.exit_line_id|intval
}}
{{:redirect to="exit_step4.html?immo_doc_id=%s&ok=1&msg=attach_exit"|args:$_GET.immo_doc_id}}
{{:redirect to="exit_step4.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_exit"|args:$_GET.immo_doc_id}}

View file

@ -10,12 +10,6 @@
{{if $message != null}}
{{:error message=$message}}
{{/if}}
{{* TODO VÉRIFIER SI UTILE *}}
{{*
{{if $info_immo.duration == null || $info_immo.duration == 0}}
{{:error message="Vous devez renseigner la durée d'amortissement au préalable"}}
{{/if}}
*}}
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
{{if $label_immo|strpos:$ligne_immo.line_label === false}}

View file

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

View file

@ -18,4 +18,4 @@
{{:delete id=$id}}
{{/load}}
{{:redirect to="exit_step3.html?immo_doc_id=%s&ok=1&msg=detach_cession"|args:$_GET.immo_doc_id}}
{{:redirect to="exit_step3.html?immo_doc_id=%s&from=exit&ok=1&msg=detach_cession"|args:$_GET.immo_doc_id}}

View file

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

View file

@ -18,4 +18,4 @@
{{:delete id=$id}}
{{/load}}
{{:redirect to="exit_step4.html?immo_doc_id=%s&ok=1&msg=detach_exit"|args:$_GET.immo_doc_id}}
{{:redirect to="exit_step4.html?immo_doc_id=%s&from=exit&ok=1&msg=detach_exit"|args:$_GET.immo_doc_id}}

View file

@ -129,7 +129,6 @@
{{else}}
{{:assign current="archived"}}
{{/if}}
{{*:include file="_nav.html" current=$current subcurrent="exit"*}}
{{if $_GET.ok}}
{{if $_GET.msg|match:"attach_avoir"}}
@ -163,6 +162,15 @@
</dl>
</div>
{{if $credit_lines}}
<nav class="actions">
{{:linkbutton
label="Attacher une écriture d'avoir"
href="link_immo.html?immo_doc_id=%s&filter=true&from=%s"|args:$_GET.immo_doc_id:$_GET.from shape="link"
target="_dialog"}}
</nav>
{{/if}}
<h3 class="ruler">Écritures d'avoir attachées à l'immobilisation</h3>
{{if $linked_immos != null}}
<table class="list">
@ -203,42 +211,6 @@
</p>
{{/if}}
{{if $credit_lines}}
<h3 class="ruler">Autres écritures au crédit du compte d'immobilisation</h3>
<table class="list">
<thead>
<tr>
<td class="num"></td>
<td>Date</td>
<td>Libellé</td>
<td class="nombre">Montant</td>
<td>N° compte</td>
<td>Compte</td>
<td class="actions"></td>
</tr>
</thead>
<tbody>
{{#foreach from=$credit_lines}}
{{:assign credit_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$year}}
<tr>
<td class="num"><a href="{{$credit_url}}">#{{$trans_id}}</a></td>
<td>{{$date|date_short}}</td>
<td>{{$trans_label}}
{{if $line_label != null && $line_label != $trans_label}} — {{$line_label}}{{/if}}
</td>
<td class="money">{{$amount|money_html|raw}}</td>
<td><a href="{{$compte_url}}">{{$account_code}}</a></td>
<td>{{$account_label}}</td>
<td class="actions">
{{:linkbutton label="Attacher" href="attach_credit.html?immo_doc_id=%s&credit_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$credit_line_id shape="plus" target="_dialog"}}
</td>
</tr>
{{/foreach}}
</tbody>
</table>
{{/if}}
<form method="post" action="exit_step2.html?immo_doc_id={{$_GET.immo_doc_id}}&from={{$_GET.from}}">
<p class="submit">
{{:button type="submit" name="proceed" label="Poursuivre" shape="right" class="main"}}

View file

@ -95,7 +95,6 @@
{{else}}
{{:assign current="archived"}}
{{/if}}
{{*:include file="_nav.html" current=$current subcurrent="exit"*}}
{{if $_GET.ok}}
{{if $_GET.msg|match:"attach_amort"}}
@ -129,6 +128,15 @@
</dl>
</div>
{{if $free_amort_lines}}
<nav class="actions">
{{:linkbutton
label="Attacher une écriture d'amortissement"
href="other_amortizations.html?immo_doc_id=%s&filter=true&from=%s"|args:$_GET.immo_doc_id:$_GET.from shape="link"
target="_dialog"}}
</nav>
{{/if}}
<h3 class="ruler">Écritures d'amortissement attachées à l'immobilisation</h3>
{{if $linked_amort != null}}
<table class="list">
@ -181,55 +189,6 @@
</p>
{{/if}}
{{if $free_amort_lines}}
<h3 class="ruler">Autres écritures d'amortissements</h3>
<table class="list">
<thead>
<tr>
<td class="num"></td>
<td>Date</td>
<td>Libellé</td>
<td class="nombre">Montant</td>
<td>N° compte</td>
<td>Compte</td>
<td class="actions"></td>
</tr>
</thead>
<tbody>
{{#foreach from=$free_amort_lines item="line"}}
{{:assign amort_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.amort_trans_id}}
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
<tr>
<td class="num"><a href="{{$amort_url}}">#{{$line.amort_trans_id}}</a></td>
<td>{{$line.date|date_short}}</td>
<td>
{{if $line.line_label != null}}
{{$line.line_label}}
{{if $line.trans_label != $line.line_label}}
— {{$line.trans_label}}
{{/if}}
{{else}}
{{$line.trans_label}}
{{/if}}
{{*
{{$line.trans_label}}
{{if $line.line_label != null && $line.line_label != $line.trans_label}} — {{$line.line_label}}{{/if}}
*}}
</td>
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
<td>{{$line.account_label}}</td>
<td class="actions">
{{:linkbutton label="Attacher" href="attach_amort.html?immo_doc_id=%s&amort_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.amort_line_id shape="plus" target="_dialog"}}
</td>
</tr>
{{/foreach}}
</tbody>
</table>
{{/if}}
<form method="post" action="">
<p class="submit">
{{:button type="submit" name="backward" label="Revenir à l'étape précédente" shape="left" class="main"}}

View file

@ -92,7 +92,6 @@
{{:assign var="free_cessions." value=$line}}
{{/select}}
{{/select}}
{{*:debug linked_cessions=$linked_cessions free_cessions=$free_cessions total_cession=$total_cession*}}
{{:admin_header title="Immobilisation sortie du bilan" custom_css="./style.css" current="module_amortization"}}
{{if $_GET.from == "exit"}}
@ -100,7 +99,6 @@
{{else}}
{{:assign current="archived"}}
{{/if}}
{{*:include file="_nav.html" current=$current subcurrent="exit"*}}
{{if $_GET.ok}}
{{if $_GET.msg|match:"attach_cession"}}
@ -138,6 +136,15 @@
</dl>
</div>
{{if $linked_cessions == null && $free_cessions != null}}
<nav class="actions">
{{:linkbutton
label="Attacher une écriture de cession"
href="list_cessions.html?immo_doc_id=%s&filter=true&from=%s"|args:$_GET.immo_doc_id:$_GET.from shape="link"
target="_dialog"}}
</nav>
{{/if}}
<h3 class="ruler">Écriture de cession attachée à l'immobilisation</h3>
{{if $linked_cessions != null}}
<table class="list">
@ -190,51 +197,6 @@
</p>
{{/if}}
{{if $free_cessions}}
<h3 class="ruler">Autres écritures de cession</h3>
<table class="list">
<thead>
<tr>
<td class="num"></td>
<td>Date</td>
<td>Libellé</td>
<td class="nombre">Montant</td>
<td>N° compte</td>
<td>Compte</td>
<td class="actions"></td>
</tr>
</thead>
<tbody>
{{#foreach from=$free_cessions item="line"}}
{{:assign cession_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
<tr>
<td class="num"><a href="{{$cession_url}}">#{{$line.trans_id}}</a></td>
<td>{{$line.date|date_short}}</td>
<td>
{{if $line.line_label != null}}
{{$line.line_label}}
{{if $line.trans_label != $line.line_label}}
— {{$line.trans_label}}
{{/if}}
{{else}}
{{$line.trans_label}}
{{/if}}
</td>
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
<td>{{$line.account_label}}</td>
<td class="actions">
{{:linkbutton label="Attacher" href="attach_cession.html?immo_doc_id=%s&cession_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.line_id shape="plus"}}
</td>
</tr>
{{/foreach}}
</tbody>
</table>
{{/if}}
<form method="post" action="">
<p class="submit">
{{:button type="submit" name="backward" label="Revenir à l'étape précédente" shape="left" class="main"}}

View file

@ -12,23 +12,6 @@
{{:error message=$message}}
{{/if}}
{{#form on="backward"}}
{{:redirect to="exit_step3.html?immo_doc_id=%s&from=%s"|args:$_GET.immo_doc_id:$_GET.from}}
{{/form}}
{{#form on="validate"}}
{{* mettre à jour l'état de l'immobilisation *}}
{{:save
key=$info_immo.key
status="archived"
}}
{{:redirect to="index.html?type_immo=archived"}}
{{/form}}
{{#form on="finish"}}
{{:redirect to="index.html?type_immo=other"}}
{{/form}}
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
{{if $label_immo|strpos:$ligne_immo.line_label === false}}
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
@ -60,6 +43,7 @@
{{else}}
{{:assign montant_cession=$amount}}
{{/if}}
{{:assign cession_doc_id=$id}}
{{/load}}
{{* chercher une écriture de sortie de bilan associée *}}
@ -117,6 +101,13 @@
{{:assign erreur=1}}
{{:assign message="Le montant des amortissement dans l'écriture de sortie (%s) est différent du total des amortissements associés à l'immobilisation (%s)."|args:$exit_amort_display:$total_amort_display}}
{{/if}}
{{if $exit_line.amount != $solde}}
{{:assign erreur=2}}
{{:assign exit_line_amount=$exit_line.amount|money_currency:false|replace:" ":" "}}
{{:assign solde_immo=$solde|money_currency:false|replace:" ":" "}}
{{:assign message="Le montant de de l'immobilisation dans l'écriture de sortie (%s) est différent du montant à amortir (%s)."|args:$exit_line_amount:$solde_immo}}
{{/if}}
{{/if}}
{{*
@ -167,7 +158,6 @@
}}
{{* chercher des écritures d'amortissement correspondant au compte d'une immo sans doc associé *}}
{{* TODO écritures d'amort pas entièrement affectées *}}
{{#select
line.id as amort_line_id,
line.credit as amort_amount,
@ -214,13 +204,32 @@
{{/if}}
{{/select}}
{{#form on="backward"}}
{{:redirect to="exit_step3.html?immo_doc_id=%s&from=%s"|args:$_GET.immo_doc_id:$_GET.from}}
{{/form}}
{{#form on="validate"}}
{{* mettre à jour l'état de l'immobilisation *}}
{{:save
key=$info_immo.key
status="archived"
}}
{{:redirect to="index.html?type_immo=archived"}}
{{/form}}
{{#form on="cancel"}}
{{* supprimer les docs de cession et de sortie *}}
{{if $cession_doc_id != null}}{{:delete id=$cession_doc_id}}{{/if}}
{{if $exit_info != null}}{{:delete id=$exit_info.id}}{{/if}}
{{:redirect to="index.html?type_immo=other"}}
{{/form}}
{{:admin_header title="Immobilisation sortie du bilan" custom_css="./style.css" current="module_amortization"}}
{{if $_GET.from == "exit"}}
{{:assign current="other"}}
{{else}}
{{:assign current="archived"}}
{{/if}}
{{*:include file="_nav.html" current=$current subcurrent="exit"*}}
{{if $_GET.ok}}
{{if $_GET.msg|match:"attach_exit"}}
@ -259,7 +268,13 @@
</div>
{{if $erreur}}
<p class="block error">{{$message}}<br />Vérifiez si vous avez correctement attaché les écritures d'amortissement.</p>
<p class="block error">{{$message}}<br />
{{if $erreur == 1}}
Vérifiez si vous avez correctement attaché les écritures d'amortissement.
{{elseif $erreur == 2}}
Vérifiez si vous avez correctement attaché les éventuelles écritures d'avoir.
{{/if}}
</p>
<table class="list error">
<caption>Détails de l'écriture de sortie de bilan</caption>
<thead class="error">
@ -286,6 +301,15 @@
</table>
{{/if}}
{{if $exit_lines}}
<nav class="actions">
{{:linkbutton
label="Attacher une écriture sortie de bilan"
href="list_exit.html?immo_doc_id=%s&filter=true&from=%s"|args:$_GET.immo_doc_id:$_GET.from shape="link"
target="_dialog"}}
</nav>
{{/if}}
<h3 class="ruler">Écriture de sortie de bilan attachée à l'immobilisation</h3>
{{if $exit_line != null}}
{{:assign exit_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$exit_line.trans_id}}
@ -328,6 +352,7 @@
{{/if}}
{{if $exit_lines}}
{{*
<h3 class="ruler">Écritures non rattachées</h3>
<table class="list">
<thead>
@ -362,6 +387,7 @@
{{/foreach}}
</tbody>
</table>
*}}
{{elseif $exit_line == null}}
<p class="block error">Aucune écriture de sortie de bilan avec un
montant de {{$solde|money_currency_html:false|raw}} au crédit du
@ -385,7 +411,7 @@
{{if $exit_line && ! $erreur}}
{{:button type="submit" name="validate" label="Terminer" shape="check" class="main"}}
{{else}}
{{:button type="submit" name="finish" label="Annuler" shape="delete" class="main"}}
{{:button type="submit" name="cancel" label="Annuler" shape="delete" class="main"}}
{{/if}}
</p>
</form>

View file

@ -21,7 +21,7 @@
{{:include file="_nav.html" current=$type_immo}}
{{* Mise à niveau *}}
{{:assign module_version="0.33"}}
{{:assign module_version="0.40.0"}}
{{:include file="upgrade.html" module_version=$module_version}}
{{* supprimer les documents sans écriture associée *}}

View file

@ -12,7 +12,9 @@
{{/if}}
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
{{:assign date_immo=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
{{:assign montant_immo=$info_immo.amount|or:$ligne_immo.amount}}
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
{{if $label_immo|strpos:$ligne_immo.line_label ===false }}
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
@ -21,6 +23,10 @@
{{:assign var="ligne_immo.amount" value=$info_immo.amount}}
{{/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="linked_immos, total_credits"}}
{{:assign solde="%d-%d"|math:$montant_immo:$total_credits}}
{{*
lister les écritures au crédit du compte de l'immobilisation
*}}
@ -59,8 +65,11 @@
:account_code = $account_code
!table = $module.table
:date_immo = $date_immo
assign="other_immos."
assign="credit_line"
}}
{{if $credit_line.credit_amount < $solde}}
{{:assign var="other_immos." value=$credit_line}}
{{/if}}
{{/select}}
{{:admin_header title="Écritures au crédit du compte d'immobilisation" custom_css="./style.css" current="module_amortization"}}
@ -78,12 +87,12 @@
<nav class="tabs">
<ul>
<li {{if $_GET.filter}}class="current"{{/if}}>
<a href="link_immo.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}&filter=true">
<a href="link_immo.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}&filter=true&from={{$_GET.from}}">
Compte {{$ligne_immo.account_code}} et sous-comptes
</a>
</li>
<li {{if ! $_GET.filter}}class="current"{{/if}}>
<a href="link_immo.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}">
<a href="link_immo.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}&from={{$_GET.from}}">
Compte {{$ligne_immo.account_code|substr:0:2}} et sous-comptes
</a>
</li>
@ -98,7 +107,7 @@
<dt>Montant</dt>
<dd class="money strong">{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}</dd>
<dt>Date de l'immobilisation</dt>
<dd>{{$date_debut|date_short}}</dd>
<dd>{{$date_immo|date_short}}</dd>
</dl>
</div>
@ -129,7 +138,7 @@
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
<td>{{$line.account_label}}</td>
<td class="actions">
{{:linkbutton label="Attacher" href="attach_credit.html?credit_line_id=%d&immo_doc_id=%s"|args:$line.credit_line_id:$_GET.immo_doc_id shape="plus"}}
{{:linkbutton label="Attacher" href="attach_credit.html?credit_line_id=%d&immo_doc_id=%s&from=%s"|args:$line.credit_line_id:$_GET.immo_doc_id:$_GET.from shape="plus"}}
</td>
</tr>
{{/foreach}}

118
list_cessions.html Normal file
View file

@ -0,0 +1,118 @@
{{* -*- brindille -*- *}}
{{*
Lister les écritures de cession du compte de l'immobilisation
paramètre et proposer de les attacher à l'immo paramètre
@param immo_doc_id : document associé à l'immo
*}}
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
{{if $message != null}}
{{:error message=$message}}
{{/if}}
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
{{if $label_immo|strpos:$ligne_immo.line_label ===false }}
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
{{/if}}
{{if $info_immo.amount != null}}
{{:assign var="ligne_immo.amount" value=$info_immo.amount}}
{{/if}}
{{:assign total_cession=0}}
{{#select
line.id as line_id,
line.credit as amount,
line.label as line_label,
trans.id as trans_id,
trans.date as date,
trans.label as trans_label,
trans.id_year as year,
account.id as account_id,
account.code as account_code,
account.label as account_label
FROM acc_transactions_lines AS line
INNER JOIN acc_accounts AS account ON line.id_account = account.id
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
WHERE account.code LIKE :code_cession_new OR account.code LIKE :code_cession_old
;
:code_cession_new = "757%"
:code_cession_old = "775%"
assign="line"
}}
{{#select
CASE WHEN links.id_related = :trans_id
THEN links.id_transaction
ELSE links.id_related
END as linked_id
FROM acc_transactions_links as links
WHERE links.id_transaction = :trans_id OR links.id_related = :trans_id
;
:trans_id = $line.trans_id
}}
{{if $linked_id == $ligne_immo.trans_id}}
{{:assign total_cession="%d+%d"|math:$total_cession:$line.amount}}
{{:assign var="line.linked_id" value=$linked_id}}
{{:assign var="linked_cessions." value=$line}}
{{/if}}
{{else}}
{{:assign var="free_cessions." value=$line}}
{{/select}}
{{/select}}
{{:admin_header title="Écritures de cession du compte d'immobilisation" custom_css="./style.css" current="module_amortization"}}
<div class="informations">
<dl class="describe">
<dt>Immobilisation</dt>
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.trans_id}}</a></span> {{$label_immo}}</dd>
<dt>Montant</dt>
<dd class="money strong">{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}</dd>
<dt>Date de l'immobilisation</dt>
<dd>{{$date_debut|date_short}}</dd>
</dl>
</div>
{{if $free_cessions}}
<table class="list">
<thead>
<tr>
<td class="num"></td>
<td>Date</td>
<td>Libellé</td>
<td class="nombre">Montant</td>
<td>N° compte</td>
<td>Compte</td>
<td class="actions"></td>
</tr>
</thead>
<tbody>
{{#foreach from=$free_cessions item="line"}}
{{:assign cession_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
<tr>
<td class="num"><a href="{{$cession_url}}">#{{$line.trans_id}}</a></td>
<td>{{$line.date|date_short}}</td>
<td>
{{if $line.line_label != null}}
{{$line.line_label}}
{{if $line.trans_label != $line.line_label}}
— {{$line.trans_label}}
{{/if}}
{{else}}
{{$line.trans_label}}
{{/if}}
</td>
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
<td>{{$line.account_label}}</td>
<td class="actions">
{{:linkbutton label="Attacher" href="attach_cession.html?immo_doc_id=%s&cession_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.line_id shape="plus"}}
</td>
</tr>
{{/foreach}}
</tbody>
<p class="help">Sélectionner une écriture de cession pour l'associer à l'immobilisation</p>
</table>
{{/if}}

108
list_exit.html Normal file
View file

@ -0,0 +1,108 @@
{{* -*- brindille -*- *}}
{{*
Lister les écritures de sortie de bilan du compte de l'immobilisation
paramètre et proposer de les attacher à l'immo paramètre
@param immo_doc_id : document associé à l'immo
*}}
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
{{if $message != null}}
{{:error message=$message}}
{{/if}}
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
{{if $label_immo|strpos:$ligne_immo.line_label ===false }}
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
{{/if}}
{{if $info_immo.amount != null}}
{{:assign var="ligne_immo.amount" value=$info_immo.amount}}
{{/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="linked_immos, total_credits"}}
{{:assign solde="%d-%d"|math:$ligne_immo.amount:$total_credits}}
{{#select
trans.id as trans_id,
trans.label as trans_label,
trans.date as date,
trans.id_year as year,
line.id as credit_line_id,
line.label as line_label,
line.credit as amount,
acc.id as account_id,
acc.code as account_code,
acc.label as account_label
FROM acc_transactions AS trans
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
LEFT JOIN module_data_amortization AS mda ON json_extract(mda.document, '$.amort_line_id') = line.id
WHERE
acc.code = :acc_code
AND line.credit > 0
AND credit_line_id NOT IN (
SELECT json_extract(credit_link.document, '$.credit_line_id') AS line_id FROM !table as credit_link
WHERE json_extract(credit_link.document, '$.type') == "credit_link"
UNION
SELECT json_extract(exit_link.document, '$.exit_line_id') AS line_id FROM !table as exit_link
WHERE json_extract(exit_link.document, '$.type') == "exit_link"
)
;
:acc_code=$ligne_immo.account_code
!table =$module.table
assign="credit_line"
}}
{{if $credit_line.amount == $solde}}
{{:assign var="exit_lines." value=$credit_line}}
{{/if}}
{{/select}}
{{:admin_header title="Écritures de cession du compte d'immobilisation" custom_css="./style.css" current="module_amortization"}}
<div class="informations">
<dl class="describe">
<dt>Immobilisation</dt>
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.trans_id}}</a></span> {{$label_immo}}</dd>
<dt>Montant</dt>
<dd class="money strong">{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}</dd>
<dt>Date de l'immobilisation</dt>
<dd>{{$date_debut|date_short}}</dd>
</dl>
</div>
{{if $exit_lines}}
<table class="list">
<thead>
<tr>
<td class="num"></td>
<td>Date</td>
<td>Libellé</td>
<td class="nombre">Montant</td>
<td>N° compte</td>
<td>Compte</td>
<td class="actions"></td>
</tr>
</thead>
<tbody>
{{#foreach from=$exit_lines item="line"}}
{{:assign exit_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
<tr>
<td class="num"><a href="{{$exit_url}}">#{{$line.trans_id}}</a></td>
<td>{{$line.date|date_short}}</td>
<td>{{$line.trans_label}}
{{if $line.line_label != null && $line.line_label != $line.trans_label}} — {{$line.line_label}}{{/if}}
</td>
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
<td>{{$line.account_label}}</td>
<td class="actions">
{{:linkbutton label="Attacher" href="attach_exit.html?immo_doc_id=%s&exit_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.credit_line_id shape="plus"}}
</td>
</tr>
{{/foreach}}
</tbody>
<p class="help">Sélectionner une écriture de sortie de bilan pour l'associer à l'immobilisation</p>
</table>
{{/if}}

View file

@ -1,5 +1,5 @@
name="Amortissements"
description="Immobilisations et amortissements\nversion 0.33"
description="Immobilisations et amortissements\nversion 0.40.0"
author="Jean-Christophe Engel"
author_url="https://gitea.zaclys.com/lesanges"
home_button=false

View file

@ -59,12 +59,12 @@
<nav class="tabs">
<ul>
<li {{if $_GET.filter}}class="current"{{/if}}>
<a href="other_amortizations.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}&filter=true">
<a href="other_amortizations.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}&filter=true&from={{$_GET.from}}">
Amortissements du compte {{$code_amort}}
</a>
</li>
<li {{if ! $_GET.filter}}class="current"{{/if}}>
<a href="other_amortizations.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}">
<a href="other_amortizations.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}&from={{$_GET.from}}">
Tous les amortissements
</a>
</li>
@ -118,7 +118,7 @@
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
<td>{{$line.account_label}}</td>
<td class="actions">
{{:linkbutton label="Attacher" href="attach_amort.html?immo_doc_id=%s&amort_line_id=%s"|args:$_GET.immo_doc_id:$line.line_id shape="plus"}}
{{:linkbutton label="Attacher" href="attach_amort.html?immo_doc_id=%s&amort_line_id=%s&from=%s"|args:$_GET.immo_doc_id:$line.line_id:$_GET.from shape="plus"}}
</td>
</tr>
{{/foreach}}
@ -130,7 +130,6 @@
{{/if}}
</section>
{{:form_errors}}
{{:admin_footer}}

View file

@ -44,7 +44,6 @@
SUM(line.debit) AS line_debit,
account.code AS account_code,
account.label AS account_label,
line.label as line_label,
line.id_project as project_id
FROM acc_transactions AS trans
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
@ -56,7 +55,7 @@
}}
{{:assign var="transactions.%s"|args:$trans_id
amount=$line_debit
line_label=$line_label
line_label=$trans_label
date=$trans_date
code=$account_code
label=$account_label

View file

@ -40,6 +40,3 @@
{{:save key="config" version=$module_version}}
<p class="block alert">Nouvelle version enregistrée : {{$module_version}}</p>
{{/if}}
{{:linkbutton label="Revenir à la page d'accueil du module" href="index.html" shape="right"}}

View file

@ -219,7 +219,7 @@
{{if $montant_cession > 0}}
{{* Cession de l'immobilisation *}}
{{:assign libelle="Produit cession "|cat:$label_immo}}
{{:assign libelle="Cession "|cat:$label_immo}}
{{:include
file="_get_codes.html"
account=$_POST.creance_account