Ajout possibilité détachement écriture crédit
This commit is contained in:
parent
18ce7b0edd
commit
12a88ab4c5
2 changed files with 118 additions and 38 deletions
73
detach_immo.html
Normal file
73
detach_immo.html
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
Supprimer l'association entre une écriture d'immobilisation et
|
||||||
|
une écriture au crédit du compte d'immobilisation
|
||||||
|
@param immo_line_id : id de la ligne d'immo
|
||||||
|
@param credit__line_id : id de la ligne de crédit
|
||||||
|
@param immo_doc_id : id du doc associé à l'immo
|
||||||
|
*}}
|
||||||
|
{{:debug get=$_GET}}
|
||||||
|
{{* chercher l'écriture d'immobilisation *}}
|
||||||
|
{{#select
|
||||||
|
id_transaction
|
||||||
|
FROM acc_transactions_lines
|
||||||
|
WHERE id = :line_id;
|
||||||
|
:line_id = $_GET.immo_line_id|intval
|
||||||
|
}}
|
||||||
|
{{:assign immo_trans_id=$id_transaction}}
|
||||||
|
{{else}}
|
||||||
|
{{:error message="Immobilisation non trouvée"}}
|
||||||
|
{{/select}}
|
||||||
|
|
||||||
|
{{* chercher l'écriture au crédit *}}
|
||||||
|
{{#select
|
||||||
|
id_transaction
|
||||||
|
FROM acc_transactions_lines
|
||||||
|
WHERE id = :line_id;
|
||||||
|
:line_id = $_GET.credit_line_id|intval
|
||||||
|
}}
|
||||||
|
{{:assign credit_id=$id_transaction}}
|
||||||
|
{{else}}
|
||||||
|
{{:error message="Écriture au crédit non trouvée"}}
|
||||||
|
{{/select}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
chercher les liaisons de l'écriture d'immobilisation
|
||||||
|
et supprimer la liaison avec l'écriture au crédit
|
||||||
|
*}}
|
||||||
|
{{#select
|
||||||
|
CASE links.id_related = :immo_trans_id
|
||||||
|
WHEN true THEN links.id_transaction
|
||||||
|
WHEN false THEN links.id_related
|
||||||
|
END as linked_id
|
||||||
|
FROM acc_transactions_links as links
|
||||||
|
WHERE id_transaction = :immo_trans_id or id_related = :immo_trans_id;
|
||||||
|
:immo_trans_id = $immo_trans_id
|
||||||
|
}}
|
||||||
|
{{if $linked_id != $credit_id}}
|
||||||
|
{{:assign var="linked_transactions." value=$linked_id}}
|
||||||
|
{{/if}}
|
||||||
|
{{/select}}
|
||||||
|
{{:debug linked_transactions=$linked_transactions}}
|
||||||
|
{{* Enregistrer les liaisons *}}
|
||||||
|
{{:api
|
||||||
|
method="POST"
|
||||||
|
path="accounting/transaction/%s/transactions"|args:$immo_trans_id
|
||||||
|
assign="result"
|
||||||
|
assign_code="result_code"
|
||||||
|
transactions=$linked_transactions
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{* supprimer le doc de liaison entre les lignes *}}
|
||||||
|
{{#load type="credit_link"
|
||||||
|
where="$$.immo_doc_id = :immo_doc_id AND $$.credit_line_id = :credit_line_id"
|
||||||
|
:immo_doc_id=$_GET.immo_doc_id|intval
|
||||||
|
:credit_line_id = $_GET.credit_line_id|intval
|
||||||
|
}}
|
||||||
|
{{:delete id=$id}}
|
||||||
|
{{/load}}
|
||||||
|
|
||||||
|
{{:redirect
|
||||||
|
to="details_immo.html?immo_doc_id=%s&ok=1&msg=detach&"|args:$_GET.immo_doc_id}}
|
||||||
|
*}}
|
||||||
|
|
@ -9,12 +9,6 @@
|
||||||
@param immo_doc_id : numéro du doc d'immo
|
@param immo_doc_id : numéro du doc d'immo
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{*
|
|
||||||
TODO : permettre la modification des param (en cas d'erreur de saisie)
|
|
||||||
TODO : permettre de corriger le montant de l'amort et/ou de supprimer l'attachement
|
|
||||||
FAIT : déduire montant au crédit de la ligne d'immo
|
|
||||||
*}}
|
|
||||||
|
|
||||||
{{* données de l'immobilisation *}}
|
{{* données de l'immobilisation *}}
|
||||||
{{#load type="immo" id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
{{#load type="immo" id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
@ -58,7 +52,8 @@
|
||||||
{{#load type="credit_link" where="$$.immo_doc_id=:immo_doc_id" :immo_doc_id=$_GET.immo_doc_id|intval}}
|
{{#load type="credit_link" where="$$.immo_doc_id=:immo_doc_id" :immo_doc_id=$_GET.immo_doc_id|intval}}
|
||||||
{{#select
|
{{#select
|
||||||
line.credit,
|
line.credit,
|
||||||
trans.id,
|
line.id as line_id,
|
||||||
|
trans.id as trans_id,
|
||||||
trans.label,
|
trans.label,
|
||||||
trans.date
|
trans.date
|
||||||
FROM acc_transactions_lines AS line
|
FROM acc_transactions_lines AS line
|
||||||
|
|
@ -67,7 +62,7 @@
|
||||||
:credit_line_id=$credit_line_id
|
:credit_line_id=$credit_line_id
|
||||||
}}
|
}}
|
||||||
{{:assign credit=$credit}}
|
{{:assign credit=$credit}}
|
||||||
{{:assign var="linked_immos." id=$id label=$label amount=$credit date=$date}}
|
{{:assign var="linked_immos." trans_id=$trans_id credit_line_id=$line_id label=$label amount=$credit date=$date}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
{{if $amount == null}}
|
{{if $amount == null}}
|
||||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||||
|
|
@ -127,11 +122,15 @@
|
||||||
|
|
||||||
{{if $_GET.ok}}
|
{{if $_GET.ok}}
|
||||||
{{if $_GET.msg|match:"attach_amort"}}
|
{{if $_GET.msg|match:"attach_amort"}}
|
||||||
{{:assign msg="Attachement amortissement effectué"}}
|
{{:assign msg="Écriture d'amortissement attachée"}}
|
||||||
{{elseif $_GET.msg|match:"attach_immo"}}
|
{{elseif $_GET.msg|match:"attach_immo"}}
|
||||||
{{:assign msg="Attachement avoir effectué"}}
|
{{:assign msg="Écriture au crédit attachée"}}
|
||||||
{{elseif $_GET.msg|match:"info"}}
|
{{elseif $_GET.msg|match:"info"}}
|
||||||
{{:assign msg="Données de l'immobilisation enregistrées"}}
|
{{: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}}
|
{{/if}}
|
||||||
<p class="block confirm">{{$msg}}</p>
|
<p class="block confirm">{{$msg}}</p>
|
||||||
{{elseif $_GET.err}}
|
{{elseif $_GET.err}}
|
||||||
|
|
@ -139,24 +138,26 @@
|
||||||
<p class="block error">{{$msg}}</p>
|
<p class="block error">{{$msg}}</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{*
|
|
||||||
<h3 class="ruler">
|
<h3 class="ruler">
|
||||||
Paramètres de l'immobilisation
|
Immobilisation
|
||||||
<span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span>
|
<span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span>
|
||||||
|
{{$info_immo.label}}
|
||||||
</h3>
|
</h3>
|
||||||
*}}
|
|
||||||
{{if $linked_immos != null}}
|
{{if $linked_immos != null}}
|
||||||
<aside class="right">
|
<aside class="right">
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<caption>Écritures d'avoir liées</caption>
|
<caption>Écritures d'avoir liées</caption>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#foreach from=$linked_immos item="elem"}}
|
{{#foreach from=$linked_immos item="line"}}
|
||||||
{{:assign url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$elem.id}}
|
{{:assign url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="num"><a href="{{$url}}">#{{$elem.id}}</a></td>
|
<td class="num"><a href="{{$url}}">#{{$line.trans_id}}</a></td>
|
||||||
<td>{{$elem.label}}</td>
|
<td>{{$line.label}}</td>
|
||||||
<td>{{$elem.date|date_short}}</td>
|
<td>{{$line.date|date_short}}</td>
|
||||||
<td class="money">{{"%f"|math:$elem.amount|money_currency_html:false|raw}}</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>
|
</tr>
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
@ -165,27 +166,12 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="informations">
|
<div class="informations">
|
||||||
<dl class="describe">
|
<dl class="describe">
|
||||||
|
{{*
|
||||||
<dt>Immobilisation</dt>
|
<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>
|
<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>
|
<dt>Compte d'immobilisation</dt>
|
||||||
<dd>{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}</dd>
|
<dd>{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}</dd>
|
||||||
<dt>Montant de l'immobilisation</dt>
|
|
||||||
<dd class="money strong">{{"%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="elem"}}
|
|
||||||
{{:assign url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$elem.id}}
|
|
||||||
<span class="num"><a href="{{$url}}">#{{$elem.id}}</a></span>
|
|
||||||
{{/foreach}}
|
|
||||||
</dd>
|
|
||||||
*}}
|
|
||||||
<dt>Montant à amortir</dt>
|
|
||||||
<dd class="money strong">{{"%f"|math:$solde|money_currency_html:false|raw}}</dd>
|
|
||||||
{{/if}}
|
|
||||||
<dt>Date d'acquisition</dt>
|
<dt>Date d'acquisition</dt>
|
||||||
<dd>{{$info_immo.date_achat|date_short}}</dd>
|
<dd>{{$info_immo.date_achat|date_short}}</dd>
|
||||||
{{if $info_immo.date_mes != null && $info_immo.date_mes != $info_immo.date_achat}}
|
{{if $info_immo.date_mes != null && $info_immo.date_mes != $info_immo.date_achat}}
|
||||||
|
|
@ -194,7 +180,28 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<dt>Durée d'amortissement</dt>
|
<dt>Durée d'amortissement</dt>
|
||||||
<dd>{{$info_immo.duration}} ans</dd>
|
<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>
|
<dt>Montant des amortissements</dt>
|
||||||
<dd>{{$total_amort|money_currency_html:false|raw}}</dd>
|
<dd>{{$total_amort|money_currency_html:false|raw}}</dd>
|
||||||
|
<dt>Valeur nette comptable</dt>
|
||||||
|
<dd>{{"%d-%d-%d"|math:$info_immo.amount:$total_credits:$total_amort|money_currency_html:false|raw}}</dd>
|
||||||
|
{{/if}}
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue