Mutualisation infos immo, écritures crédit, amortissements liés et libres
This commit is contained in:
parent
91795c69a8
commit
780eb206ce
21 changed files with 410 additions and 879 deletions
|
|
@ -7,62 +7,28 @@
|
|||
*}}
|
||||
|
||||
{{* 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
|
||||
line.id as immo_line_id,
|
||||
line.debit as montant,
|
||||
line.label as line_label,
|
||||
trans.id as immo_trans_id,
|
||||
trans.label as label,
|
||||
trans.date as date_achat,
|
||||
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 trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.immo_trans_id}}
|
||||
{{: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.label}}
|
||||
{{: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.montant" value=$info_immo.amount}}
|
||||
{{: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}}
|
||||
|
||||
{{*
|
||||
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 total_credits=0}}
|
||||
{{#load type="credit_link" where="$$.immo_doc_id=:immo_doc_id" :immo_doc_id=$_GET.immo_doc_id|intval}}
|
||||
{{if $amount == null}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
||||
:credit_line_id=$credit_line_id
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{:assign solde="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
||||
{{* 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="total_credits"}}
|
||||
{{:assign solde="%d-%d"|math:$ligne_immo.amount:$total_credits}}
|
||||
|
||||
{{if $info_immo.status == "amortized"}}
|
||||
{{:assign amort_amount=$solde}}
|
||||
|
|
@ -71,71 +37,13 @@
|
|||
{{:assign valeur_residuelle=$solde}}
|
||||
{{/if}}
|
||||
|
||||
{{* lister les lignes des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id = $_GET.immo_doc_id|intval
|
||||
}}
|
||||
{{#select
|
||||
line.id as amort_line_id,
|
||||
line.credit,
|
||||
line.label as amort_line_label,
|
||||
trans.id as amort_trans_id,
|
||||
trans.label as amort_trans_label,
|
||||
trans.date as amort_date,
|
||||
trans.id_year as amort_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_transactions AS trans ON line.id_transaction = trans.id
|
||||
INNER join acc_accounts AS account on line.id_account = account.id
|
||||
WHERE line.id = :amort_line_id
|
||||
;
|
||||
:amort_line_id = $amort_line_id
|
||||
assign="amort_line"
|
||||
}}
|
||||
{{:assign var="amort_line.amort_amount" value=$amount|or:$credit}}
|
||||
{{:assign var="linked_amort.%s_%d"|args:$amort_date:$id value=$amort_line}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$amort_line.amort_amount}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
{{* 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"}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$total_amort}}
|
||||
|
||||
{{if $valeur_residuelle > 0}}
|
||||
{{* Chercher des amortissements non rattachés à une immo *}}
|
||||
{{#select
|
||||
line.id as amort_line_id,
|
||||
line.id_transaction AS amort_trans_id,
|
||||
line.credit as amort_amount
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
||||
INNER JOIN acc_years AS y ON y.id = trans.id_year
|
||||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16)
|
||||
ORDER BY trans.date, trans.label;
|
||||
assign="amort"
|
||||
}}
|
||||
{{* 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_line_id
|
||||
assign="amort_link"
|
||||
}}
|
||||
{{if $amort_link.amount == null || $amort_link.amount == 0}}
|
||||
{{:assign amort_amount=$amort.amort_amount}}
|
||||
{{:assign keep_amort=false}}
|
||||
{{else}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amort_link.amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{* 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}}
|
||||
{{* lister les amortissements non rattachés à une immo *}}
|
||||
{{:include file="./_get_free_amort.html" filter_condition="1" keep="free_amort_lines"}}
|
||||
{{/if}}
|
||||
|
||||
{{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortization"}}
|
||||
|
|
@ -199,7 +107,7 @@
|
|||
<div class="informations">
|
||||
<dl class="describe">
|
||||
<dt>Immobilisation</dt>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span> {{$label_immo}}</dd>
|
||||
<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>
|
||||
|
|
@ -209,7 +117,7 @@
|
|||
<dd>{{$info_immo.duration}} ans</dd>
|
||||
{{/if}}
|
||||
<dt>Montant de l'immobilisation</dt>
|
||||
<dd class="money strong">{{"%f"|math:$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
||||
<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>
|
||||
|
|
@ -237,9 +145,9 @@
|
|||
<tr>
|
||||
<th class="num">N°</th>
|
||||
<th>Date</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th class="nombre">Valeur nette</th>
|
||||
<th>Libellé</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th class="actions"></th>
|
||||
|
|
@ -248,24 +156,24 @@
|
|||
<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.amort_trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
||||
{{:assign solde="%f-%d"|math:$solde:$line.amort_amount}}
|
||||
{{: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.amort_trans_id}}</a></td>
|
||||
<td>{{$line.amort_date|date_short}}</td>
|
||||
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
||||
<td class="money">{{"%f"|math:$solde|money_html:false|raw}}</td>
|
||||
<td class="num"><a href="{{$trans_url}}">#{{$line.trans_id}}</a></td>
|
||||
<td>{{$line.date|date_short}}</td>
|
||||
<td>
|
||||
{{$line.amort_trans_label}}
|
||||
{{if $line.amort_line_label != null && $line.amort_line_label != $line.amort_trans_label}}
|
||||
— {{$line.amort_line_label}}
|
||||
{{$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>
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?immo_doc_id=%s&amort_line_id=%s"|args:$_GET.immo_doc_id:$line.amort_line_id shape="minus"}}
|
||||
{{: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"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue