221 lines
7.5 KiB
HTML
221 lines
7.5 KiB
HTML
{{* -*- brindille -*- *}}
|
|
|
|
{{:admin_header title="Immobilisation sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
|
{{*
|
|
Associer une écriture de cession à une immo créée et sortie du
|
|
bilan avant la mise en service du module
|
|
@param immo_doc_id : id du doc associé à l'immobilisation
|
|
*}}
|
|
|
|
{{* 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}}
|
|
|
|
{{#form on="backward"}}
|
|
{{:redirect to="exit_step2.html?immo_doc_id=%s"|args:$_GET.immo_doc_id}}
|
|
{{/form}}
|
|
|
|
{{#form on="forward"}}
|
|
{{:redirect to="exit_step4.html?immo_doc_id=%s"|args:$_GET.immo_doc_id}}
|
|
{{/form}}
|
|
|
|
{{: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}}
|
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
|
{{: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}}
|
|
|
|
{{* 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 amortissements liés à l'immobilisation *}}
|
|
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, total_amort"}}
|
|
|
|
{{* chercher des écritures de cession *}}
|
|
{{: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"
|
|
}}
|
|
{{* voir si l'écriture de cession est déjà liée à une immo *}}
|
|
{{#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}}
|
|
{{*:debug linked_cessions=$linked_cessions free_cessions=$free_cessions total_cession=$total_cession*}}
|
|
|
|
{{if $_GET.ok}}
|
|
{{if $_GET.msg|match:"attach_cession"}}
|
|
{{:assign msg="Écriture de cession attachée"}}
|
|
{{elseif $_GET.msg|match:"detach_cession"}}
|
|
{{:assign msg="Écriture de cession détachée"}}
|
|
{{/if}}
|
|
<p class="block confirm">{{$msg}}</p>
|
|
{{/if}}
|
|
|
|
<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>Montant de l'immobilisation</dt>
|
|
<dd><span class="money">{{$ligne_immo.amount|money_html|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">{{"%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"|math:$solde:$total_amort|money_currency_html:false|raw}}</dd>
|
|
{{/if}}
|
|
{{if $total_cession > 0}}
|
|
<dt>Montant de la cession</dt>
|
|
<dd>{{$total_cession|money_currency_html:false|raw}}</dd>
|
|
{{/if}}
|
|
</dl>
|
|
</div>
|
|
|
|
{{if $linked_cessions != null}}
|
|
<h3 class="ruler">Écriture de cession attachée à l'immobilisation</h3>
|
|
<table class="list">
|
|
<thead>
|
|
<tr>
|
|
<td class="num">N°</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=$linked_cessions 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}}
|
|
<tr>
|
|
<td class="num"><a href="{{$trans_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>
|
|
{{:linkbutton label="Détacher" href="detach_cession.html?immo_doc_id=%s&cession_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.line_id shape="minus"}}
|
|
</td>
|
|
</tr>
|
|
{{/foreach}}
|
|
</tbody>
|
|
</table>
|
|
{{elseif $free_cessions}}
|
|
<p class="block alert">
|
|
Vous pouvez attacher une écriture de cession à l'immobilisation
|
|
</p>
|
|
{{else}}
|
|
<p class="block alert">
|
|
Aucune écriture de cession... que faire ?
|
|
</p>
|
|
{{/if}}
|
|
|
|
|
|
{{if $free_cessions}}
|
|
<h3 class="ruler">Autres écritures de cession</h3>
|
|
<table class="list">
|
|
<thead>
|
|
<tr>
|
|
<td class="num">N°</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>
|
|
{{: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"}}
|
|
{{:button type="submit" name="forward" label="Poursuivre" shape="right" class="main"}}
|
|
</p>
|
|
</form>
|