207 lines
7.4 KiB
HTML
207 lines
7.4 KiB
HTML
{{* -*- brindille -*- *}}
|
|
|
|
|
|
{{*
|
|
Afficher les détails d'une immmo
|
|
- permettre l'association d'une immo au crédit du compte de l'immo
|
|
- permettre de modifier les paramètres de l'immo
|
|
@param (OBSOLÈTE ?) immo_line_id : numéro de ligne de l'écriture d'immobilisation
|
|
@param immo_doc_id : numéro du doc d'immo
|
|
*}}
|
|
|
|
{{* données de l'immobilisation *}}
|
|
{{#load type="immo" id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
|
{{else}}
|
|
{{:error message="Immobilisation non trouvée"}}
|
|
{{/load}}
|
|
|
|
{{#select
|
|
trans.id as immo_trans_id,
|
|
trans.label as label,
|
|
trans.date as date_achat,
|
|
line.id as immo_line_id,
|
|
line.debit as montant,
|
|
line.label as line_label,
|
|
account.code as account_code,
|
|
account.label as account_label
|
|
FROM acc_transactions_lines AS line
|
|
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
|
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
|
WHERE line.id = :line_id;
|
|
:line_id = $info_immo.line
|
|
assign="ligne_immo"
|
|
}}
|
|
{{else}}
|
|
{{:error message="Immobilisation non trouvée"}}
|
|
{{/select}}
|
|
|
|
{{:assign var="info_immo.amount" value=$info_immo.amount|or:$ligne_immo.montant}}
|
|
{{:assign var="info_immo.date_achat" value=$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
|
{{:assign var="info_immo.date_mes" value=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
|
{{:assign var="info_immo.label" value=$info_immo.label|or:$ligne_immo.label}}
|
|
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $info_immo.label}}
|
|
{{:assign var="info_immo.label" value=$info_immo.label|cat:" — "|cat:$ligne_immo.line_label}}
|
|
{{/if}}
|
|
|
|
{{*
|
|
chercher des écritures liées à l'immo courante au crédit du même compte
|
|
et déduire leur montant de celui de l'immo
|
|
*}}
|
|
{{:assign linked_immos=null}}
|
|
{{:assign total_credits=0}}
|
|
{{#load type="credit_link" where="$$.immo_doc_id=:immo_doc_id" :immo_doc_id=$_GET.immo_doc_id|intval}}
|
|
{{#select
|
|
line.credit,
|
|
line.id as line_id,
|
|
trans.id as trans_id,
|
|
trans.label,
|
|
trans.date
|
|
FROM acc_transactions_lines AS line
|
|
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
|
WHERE line.id = :credit_line_id;
|
|
:credit_line_id=$credit_line_id
|
|
}}
|
|
{{:assign credit=$credit}}
|
|
{{:assign var="linked_immos." trans_id=$trans_id credit_line_id=$line_id label=$label amount=$credit date=$date}}
|
|
{{/select}}
|
|
{{if $amount == null}}
|
|
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
|
{{else}}
|
|
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
|
{{/if}}
|
|
{{/load}}
|
|
{{:assign solde="%d-%d"|math:$info_immo.amount:$total_credits}}
|
|
|
|
{{:assign total_amort=0}}
|
|
{{* lister les docs d'amortissement liées à la ligne d'immobilisation *}}
|
|
{{#load type="amort_link"
|
|
where="$$.immo_doc_id = :immo_doc_id"
|
|
:immo_doc_id=$_GET.immo_doc_id|intval
|
|
}}
|
|
{{if $amount != null}}
|
|
{{:assign total_amort="%d+%d"|math:$total_amort:$amount}}
|
|
{{else}}
|
|
{{#select credit FROM acc_transactions_lines WHERE id = :amort_line_id;
|
|
:amort_line_id=$amort_line_id
|
|
}}
|
|
{{:assign total_amort="%d+%d"|math:$total_amort:$credit}}
|
|
{{/select}}
|
|
{{/if}}
|
|
{{/load}}
|
|
|
|
{{:admin_header title="Détails de l'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
|
|
|
{{*
|
|
{{if ! $dialog}}
|
|
{{:assign subsubcurrent=null}}
|
|
{{if $total_credits == 0 && $total_amort == 0}}
|
|
{{:assign subsubcurrent="credit"}}
|
|
{{/if}}
|
|
{{if $total_amort == 0}}
|
|
{{:assign subsubcurrent=$subsubcurrent|cat:"-modif"}}
|
|
{{/if}}
|
|
{{:include file="_nav.html" current="index" subcurrent="details" subsubcurrent=$subsubcurrent}}
|
|
{{/if}}
|
|
*}}
|
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.immo_trans_id}}
|
|
|
|
<nav class="tabs">
|
|
<aside>
|
|
{{*if $total_credits == 0*}}
|
|
{{:linkbutton label="Rattacher une écriture d'immobilisation" href="link_immo.html?immo_doc_id=%s"|args:$_GET.immo_doc_id shape="link" target="_dialog"}}
|
|
{{*/if*}}
|
|
</aside>
|
|
<nav style="margin-bottom: 1em;">
|
|
{{*:linkbutton shape="left" label="Retour à la liste des immobilisations" href="index.html*}}
|
|
{{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"}}
|
|
{{:linkbutton label="Supprimer les paramètres" href="delete_infos.html?immo_doc_id=%s"|args:$_GET.immo_doc_id shape="delete" target="_dialog"}}
|
|
{{/if}}
|
|
</nav>
|
|
</nav>
|
|
|
|
{{if $_GET.ok}}
|
|
{{if $_GET.msg|match:"attach_amort"}}
|
|
{{:assign msg="Écriture d'amortissement attachée"}}
|
|
{{elseif $_GET.msg|match:"attach_immo"}}
|
|
{{:assign msg="Écriture au crédit attachée"}}
|
|
{{elseif $_GET.msg|match:"info"}}
|
|
{{:assign msg="Données de l'immobilisation enregistrées"}}
|
|
{{elseif $_GET.msg|match:"detach"}}
|
|
{{:assign msg="Écriture au crédit détachée"}}
|
|
{{else}}
|
|
{{:assign msg="Opération effectuée avec succès"}}
|
|
{{/if}}
|
|
<p class="block confirm">{{$msg}}</p>
|
|
{{elseif $_GET.err}}
|
|
{{:assign msg="L'opération a échoué"}}
|
|
<p class="block error">{{$msg}}</p>
|
|
{{/if}}
|
|
|
|
<h3 class="ruler">
|
|
Immobilisation
|
|
<span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span>
|
|
{{$info_immo.label}}
|
|
</h3>
|
|
{{if $linked_immos != null}}
|
|
<aside class="right">
|
|
<table class="list">
|
|
<caption>Écritures d'avoir liées</caption>
|
|
<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.label}}</td>
|
|
<td>{{$line.date|date_short}}</td>
|
|
<td class="money">{{"%f"|math:$line.amount|money_currency_html:false|raw}}</td>
|
|
<td>
|
|
{{:linkbutton label="Détacher" href="detach_immo.html?credit_line_id=%d&immo_line_id=%d&immo_doc_id=%s"|args:$line.credit_line_id:$ligne_immo.immo_line_id:$_GET.immo_doc_id shape="minus"}}
|
|
</td>
|
|
</tr>
|
|
{{/foreach}}
|
|
</tbody>
|
|
</table>
|
|
</aside>
|
|
{{/if}}
|
|
<div class="informations">
|
|
<dl class="describe">
|
|
{{*
|
|
<dt>Immobilisation</dt>
|
|
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span><span class="label"> {{$info_immo.label}}</span></dd>
|
|
*}}
|
|
<dt>Compte d'immobilisation</dt>
|
|
<dd>{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}</dd>
|
|
<dt>Date d'acquisition</dt>
|
|
<dd>{{$info_immo.date_achat|date_short}}</dd>
|
|
{{if $info_immo.date_mes != null && $info_immo.date_mes != $info_immo.date_achat}}
|
|
<dt>Date de mise en service</dt>
|
|
<dd>{{$info_immo.date_mes|date_short}}</dd>
|
|
{{/if}}
|
|
<dt>Durée d'amortissement</dt>
|
|
<dd>{{$info_immo.duration}} ans</dd>
|
|
<dt>Montant de l'immobilisation</dt>
|
|
<dd class="money">{{"%f"|math:$info_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>Écritures d'avoir</dt>
|
|
<dd>
|
|
{{#foreach from=$linked_immos item="line"}}
|
|
{{:assign url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.id}}
|
|
<span class="num"><a href="{{$url}}">#{{$line.id}}</a></span>
|
|
{{/foreach}}
|
|
</dd>
|
|
*}}
|
|
<dt>Montant à amortir</dt>
|
|
<dd class="money">{{"%f"|math:$solde|money_currency_html:false|raw}}</dd>
|
|
{{/if}}
|
|
{{if $total_amort > 0}}
|
|
<dt>Montant des amortissements</dt>
|
|
<dd>{{$total_amort|money_currency_html:false|raw}}</dd>
|
|
<dt>Valeur nette résiduelle</dt>
|
|
<dd>{{"%d-%d-%d"|math:$info_immo.amount:$total_credits:$total_amort|money_currency_html:false|raw}}</dd>
|
|
{{/if}}
|
|
</dl>
|
|
</div>
|