liaisons écritures remplacées par liaisons lignes
This commit is contained in:
parent
d5c62b6ef3
commit
87a1f31bb3
3 changed files with 216 additions and 282 deletions
|
|
@ -4,6 +4,7 @@
|
|||
Lister les écritures d'amortissement indépendantes
|
||||
et proposer des les attacher à l'immo sélectionnée
|
||||
@param immo_line_id = id de la ligne d'immo
|
||||
@param immo_doc_id id du doc d'immo associé
|
||||
*}}
|
||||
|
||||
{{* récupérer les infos de l'immobilisation *}}
|
||||
|
|
@ -17,11 +18,19 @@
|
|||
assign=ligne_immo
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_line_id}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
{{#load id=$_GET.immo_doc_id|intval}}
|
||||
{{:assign label_immo=$label|or:$ligne_immo.label}}
|
||||
{{else}}
|
||||
{{:error message="Informations de l'immobilisation %s (%s) non trouvées"|args:$_GET.immo_line_id:$ligne_immo.label}}
|
||||
{{/load}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
{{if $_POST.unhide == null}}
|
||||
{{:assign filter_condition=" NOT ("}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
|
|
@ -54,46 +63,26 @@
|
|||
!filter_condition=$filter_condition
|
||||
assign="amort"
|
||||
}}
|
||||
|
||||
{{* voir s'il existe des écritures liées avec un numéro de compte d'immobilisation *}}
|
||||
{{#select
|
||||
links.id_transaction,
|
||||
links.id_related,
|
||||
trans.id AS trans_id
|
||||
FROM acc_transactions_links AS links
|
||||
INNER JOIN acc_transactions AS trans ON (
|
||||
CASE
|
||||
WHEN links.id_transaction = :id_amort THEN links.id_related
|
||||
WHEN links.id_related = :id_amort THEN links.id_transaction
|
||||
END) = trans.id
|
||||
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
|
||||
WHERE
|
||||
links.id_transaction = :id_amort OR links.id_related = :id_amort
|
||||
AND acc.code LIKE '21%'
|
||||
LIMIT 1
|
||||
;
|
||||
:id_amort=$amort.amort_trans_id
|
||||
{{* voir s'il existe des lignes d'immo liées à cette ligne d'amortissement *}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{:assign keep_amort=true}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.amort_line_id = :amort_line_id"
|
||||
:amort_line_id=$amort.amort_line_id|intval
|
||||
assign="amort_link"
|
||||
}}
|
||||
{{* voir s'il existe un doc associé à une ligne de l'amortissement *}}
|
||||
{{:assign keep=true}}
|
||||
{{#load type="link"
|
||||
where="$$.amort_trans_id = :amort_trans_id"
|
||||
:amort_trans_id = $amort.amort_trans_id
|
||||
}}
|
||||
{{if $amort_line_id == $amort.amort_line_id}}
|
||||
{{:assign keep=false}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{if $amort_link.amount == null || $amort_link.amount == 0}}
|
||||
{{:assign amort_amount=$amort.amort_amount}}
|
||||
{{:assign keep_amort=false}}
|
||||
{{else}}
|
||||
{{:assign keep=false}}
|
||||
{{/load}}
|
||||
{{if $keep}}
|
||||
{{:assign var="autres_amortissements." value=$amort}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amort_link.amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$amort}}
|
||||
{{/select}}
|
||||
{{* pas de ligne d'immo liée à cette ligne d'amort => garder cette ligne d'amortissement *}}
|
||||
{{/load}}
|
||||
{{if $keep_amort && $amort_amount < $amort.amort_amount}}
|
||||
{{:assign var="free_amort_lines." value=$amort}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{:admin_header title="Amortissements non rattachés" custom_css="./style.css" current="module_amortization"}}
|
||||
|
|
@ -106,7 +95,7 @@
|
|||
subcurrent="other"
|
||||
subsubcurrent="amortization"
|
||||
type_immo="other"
|
||||
autres_amort=$autres_amortissements
|
||||
autres_amort=$free_amort_lines
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
|
|
@ -116,13 +105,13 @@
|
|||
|
||||
<form method="post" action="">
|
||||
<fieldset>
|
||||
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher toutes les écritures" }}
|
||||
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher les écritures ignorées"}}
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
{{if $autres_amortissements != null}}
|
||||
{{if $free_amort_lines != null}}
|
||||
<section class="amortissement">
|
||||
<h3 class="ruler">Immobilisation « {{$ligne_immo.label}}{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $ligne_immo.label}} — {{$ligne_immo.line_label}}{{/if}} »</h3>
|
||||
<h3 class="ruler">Immobilisation « {{$label_immo}} »</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -136,20 +125,24 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$autres_amortissements item="line"}}
|
||||
{{#foreach from=$free_amort_lines item="line"}}
|
||||
{{:assign trans_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.amort_year}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$line.amort_trans_id}}</a></td>
|
||||
<td class="num"><a href="{{$trans_url}}">#{{$line.amort_trans_id}}</a></td>
|
||||
<td>{{$line.trans_date|date_short}}</td>
|
||||
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
||||
<td>{{$line.trans_label}}
|
||||
{{if $line.line_label != null && $line.line_label != $line.trans_label}} - {{$line.line_label}}{{/if}}
|
||||
</td>
|
||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_line_id=%d&immo_line_id=%d"|args:$line.amort_line_id:$_GET.immo_line_id shape="plus"}}
|
||||
{{if $_GET.init == null}}
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_line_id=%d&immo_line_id=%d&immo_doc_id=%s"|args:$line.amort_line_id:$_GET.immo_line_id:$_GET.immo_doc_id shape="plus"}}
|
||||
{{elseif $_GET.init}}
|
||||
{{:linkbutton label="Attacher" href="attach_amort_init.html?amort_line_id=%d&immo_line_id=%d&immo_doc_id=%s"|args:$line.amort_line_id:$_GET.immo_line_id:$_GET.immo_doc_id shape="plus"}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue