270 lines
9.5 KiB
HTML
270 lines
9.5 KiB
HTML
{{* -*- brindille -*- *}}
|
||
|
||
{{*
|
||
Lister les écritures d'amortissement associées à une immobilisation
|
||
@param immo_doc_id : id du doc associé à l'immo
|
||
@param type_immo : managed, amortized, archived, others
|
||
*}}
|
||
|
||
{{* données de l'immobilisation *}}
|
||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id 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 $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||
{{: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}}
|
||
|
||
{{if $info_immo.status == 'ignored'}}
|
||
{{:error message="Cette immobilisation ne doit pas être amortie"}}
|
||
{{/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}}
|
||
|
||
{{if $info_immo.status == "amortized"}}
|
||
{{:assign amort_amount=$solde}}
|
||
{{:assign valeur_residuelle=0}}
|
||
{{else}}
|
||
{{:assign valeur_residuelle=$solde}}
|
||
{{/if}}
|
||
|
||
{{* 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"}}
|
||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$total_amort}}
|
||
|
||
{{if $valeur_residuelle > 0}}
|
||
{{* lister les amortissements non attachés à une immo *}}
|
||
{{:assign account_filter="28%"|quote_sql}}
|
||
{{:assign filter_condition="account.code LIKE "|cat:$account_filter}}
|
||
{{:include file="./_get_free_amort.html" filter_condition=$filter_condition keep="free_amort_lines"}}
|
||
{{/if}}
|
||
|
||
{{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortization"}}
|
||
|
||
{{* barre de navigation *}}
|
||
{{if $_GET.type_immo == "amortized" || $valeur_residuelle== 0 }}
|
||
{{:assign subcurrent="amortized"}}
|
||
{{elseif $_GET.type_immo == "archived"}}
|
||
{{:assign subcurrent="archived"}}
|
||
{{elseif $_GET.type_immo == null || $_GET.type_immo == "managed"}}
|
||
{{:assign subcurrent="managed"}}
|
||
{{else}}
|
||
{{:assign subcurrent="other"}}
|
||
{{/if}}
|
||
|
||
{{:include
|
||
file="_nav.html"
|
||
current="index"
|
||
subcurrent="%s"|args:$subcurrent
|
||
subsubcurrent="amortization"
|
||
type_immo=$_GET.type_immo
|
||
autres_amort=$free_amort_lines
|
||
}}
|
||
|
||
{{if $_GET.ok}}
|
||
{{if $_GET.msg|match:"attach_amort"}}
|
||
{{:assign msg="Attachement amortissement effectué"}}
|
||
{{elseif $_GET.msg|match:"detach_amort"}}
|
||
{{:assign msg="Détachement amortissement affectué"}}
|
||
{{elseif $_GET.msg|match:"attach_avoir"}}
|
||
{{:assign msg="Attachement avoir affectué"}}
|
||
{{elseif $_GET.msg|match:"detach_avoir"}}
|
||
{{:assign msg="Détachement avoir affectué"}}
|
||
{{elseif $_GET.msg|match:"amortissement"}}
|
||
{{:assign msg="Amortissement enregistré"}}
|
||
{{elseif $_GET.msg|match:"modif"}}
|
||
{{:assign msg="Modifications enregistrées"}}
|
||
{{/if}}
|
||
<p class="block confirm">{{$msg}}</p>
|
||
{{elseif $_GET.err}}
|
||
{{if $_GET.msg|match:"attach"}}
|
||
{{:assign msg="Échec attachement amortissement"}}
|
||
{{elseif $_GET.msg|match:"amortissement"}}
|
||
{{:assign msg="Échec enregistrement amortissement"}}
|
||
{{/if}}
|
||
<p class="block error">{{$msg}}</p>
|
||
{{/if}}
|
||
|
||
<form method="post" action="">
|
||
<fieldset>
|
||
<legend>Sortir l'immobilisation du bilan ?</legend>
|
||
<p class="submit">
|
||
{{:linkbutton
|
||
label="Sortir du bilan"
|
||
href="balance_sheet_exit.html?immo_doc_id=%s&type_immo=%s"|args:$_GET.immo_doc_id:$_GET.type_immo
|
||
shape="export"
|
||
class="main"
|
||
}}
|
||
</p>
|
||
<p class="help">
|
||
Il sera possible de choisir la date de sortie et d'indiquer
|
||
le montant de la cession le cas échéant.
|
||
</p>
|
||
</fieldset>
|
||
</form>
|
||
|
||
<h3 class="ruler">Immobilisation</h3>
|
||
<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}}
|
||
</nav>
|
||
|
||
|
||
<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>Compte d'immobilisation</dt>
|
||
<dd>{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}</dd>
|
||
<dt>Début d'amortissement</dt>
|
||
<dd>{{$date_debut|date_short}}</dd>
|
||
{{if $info_immo.duration != null}}
|
||
<dt>Durée</dt>
|
||
<dd>{{$info_immo.duration}} ans</dd>
|
||
{{/if}}
|
||
<dt>Montant de l'immobilisation</dt>
|
||
<dd class="money strong">{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}</dd>
|
||
{{if $total_credits > 0}}
|
||
<dt>Montant des avoirs</dt>
|
||
<dd class="money">{{"%f"|math:$total_credits|money_currency_html:false|raw}}</dd>
|
||
<dt>Montant à amortir</dt>
|
||
<dd class="money strong">{{"%f"|math:$solde|money_currency_html:false|raw}}</dd>
|
||
{{/if}}
|
||
{{if $valeur_residuelle > 0}}
|
||
<dt>Montant des amortissements</dt>
|
||
<dd>{{"%d-%d"|math:$solde:$valeur_residuelle|money_currency_html:false|raw}}</dd>
|
||
<dt>Valeur nette résiduelle</dt>
|
||
<dd>{{$valeur_residuelle|money_currency_html:false|raw}}</dd>
|
||
{{/if}}
|
||
{{if $info_immo.duration != null && $valeur_residuelle > 0}}
|
||
<dt>Annuité estimée</dt>
|
||
<dd>{{"min(%d, %f/%d)"|math:$valeur_residuelle:$solde:$info_immo.duration|money_currency_html:false|raw}}</dd>
|
||
{{/if}}
|
||
</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">N°</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>
|
||
<nav class="actions">
|
||
{{if $free_amort_lines && ! $created_amort}}
|
||
{{:linkbutton
|
||
label="Attacher un amortissement"
|
||
title="Attacher un amortissement existant"
|
||
href="other_amortizations.html?immo_doc_id=%s&filter=true"|args:$_GET.immo_doc_id
|
||
shape="link"
|
||
target="_dialog"}}
|
||
{{/if}}
|
||
{{:linkbutton
|
||
label="Enregistrer un amortissement"
|
||
title="Enregistrer un nouvel amortissement"
|
||
href="save_amort.html?immo_doc_id=%s"|args:$_GET.immo_doc_id target="_dialog"
|
||
shape="plus"
|
||
}}
|
||
</nav>
|
||
|
||
{{if $linked_amort != null}}
|
||
<section class="amortissement">
|
||
<table class="list">
|
||
<thead>
|
||
<tr>
|
||
<th class="num">N°</th>
|
||
<th>Date</th>
|
||
<th>Libellé</th>
|
||
<th class="nombre">Montant</th>
|
||
<th class="nombre">Valeur nette</th>
|
||
<th>N° compte</th>
|
||
<th>Compte</th>
|
||
<th class="actions"></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{{#foreach from=$linked_amort|ksort item="line"}}
|
||
{{* données de l'écriture *}}
|
||
{{:assign trans_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}}
|
||
{{:assign solde="%f-%d"|math:$solde:$line.amount}}
|
||
<tr>
|
||
<td class="num"><a href="{{$trans_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 class="money">{{"%f"|math:$solde|money_html:false|raw}}</td>
|
||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||
<td>{{$line.account_label}}</td>
|
||
<td>
|
||
{{if ! $created_amort}}
|
||
{{:linkbutton label="Détacher" href="detach_amort.html?immo_doc_id=%s&amort_line_id=%s"|args:$_GET.immo_doc_id:$line.line_id shape="minus"}}
|
||
{{/if}}
|
||
</td>
|
||
</tr>
|
||
{{/foreach}}
|
||
</tbody>
|
||
</table>
|
||
</section>
|
||
{{/if}}
|
||
|
||
{{if $free_amort_lines && ! $created_amort}}
|
||
<p class="block alert">
|
||
Il y a des écritures d'amortissement qui ne sont pas attachées à une immobilisation ! <br />
|
||
Utilisez le bouton « Attacher un amortissement » pour les afficher ; vous pourrez choisir d'en attacher certaines à cette immobilisation.
|
||
</p>
|
||
{{/if}}
|
||
|
||
{{if $linked_amort == null}}
|
||
<p class="block alert">Aucun amortissement enregistré pour cette immobilisation ; utilisez le bouton « Enregistrer un amortissement » pour enregistrer un nouvel amortissement</p>
|
||
{{/if}}
|
||
|
||
{{:form_errors}}
|
||
{{:admin_footer}}
|