amortization.html : restructuration
This commit is contained in:
parent
8f3e689951
commit
b00c05021c
@ -1,7 +1,7 @@
|
|||||||
{{:admin_header title="Gestion des amortissements" custom_css=$custom_css current="module_amortissement"}}
|
{{:admin_header title="Gestion des amortissements" custom_css=$custom_css current="module_amortissement"}}
|
||||||
|
|
||||||
{{* barre de navigation *}}
|
{{* barre de navigation *}}
|
||||||
{{:include file="_nav.html" current="amortissements"}}
|
{{:include file="_nav.html" current="amortization"}}
|
||||||
|
|
||||||
{{* récupérer les infos de l'immobilisation *}}
|
{{* récupérer les infos de l'immobilisation *}}
|
||||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.line|intval}}
|
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.line|intval}}
|
||||||
@ -10,22 +10,14 @@
|
|||||||
{{:error message=$message}}
|
{{:error message=$message}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
|
|
||||||
{{*
|
|
||||||
["info_immo"]=> array(5) {
|
|
||||||
["id"]=> int(3)
|
|
||||||
["key"]=> string(36) "e0b5a8ab-b123-48ca-9a4c-8f623315818b"
|
|
||||||
["type"]=> string(4) "immo"
|
|
||||||
["line"]=> int(3890)
|
|
||||||
["duration"]=> int(5)
|
|
||||||
}
|
|
||||||
*}}
|
|
||||||
|
|
||||||
{{#select
|
{{#select
|
||||||
line.id as line_id,
|
line.id as line_id,
|
||||||
|
line.id_account as account_id,
|
||||||
trans.id as trans_id,
|
trans.id as trans_id,
|
||||||
line.debit as montant,
|
line.debit as montant,
|
||||||
trans.label as label,
|
trans.label as label,
|
||||||
trans.date as date_achat,
|
trans.date as date_achat,
|
||||||
|
y.id as year_id,
|
||||||
y.end_date as date_fin
|
y.end_date as date_fin
|
||||||
from acc_transactions_lines as line
|
from acc_transactions_lines as line
|
||||||
inner join acc_transactions as trans on line.id_transaction = trans.id
|
inner join acc_transactions as trans on line.id_transaction = trans.id
|
||||||
@ -40,63 +32,81 @@
|
|||||||
{{:error message=$message}}
|
{{:error message=$message}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
|
{{*:debug ligne_immo=$ligne_immo*}}
|
||||||
|
|
||||||
|
{{* lister les écritures d'amortissement *}}
|
||||||
|
{{#select
|
||||||
|
line.id as l_immo,
|
||||||
|
line.id_account as ammort_account,
|
||||||
|
line2.debit as montant,
|
||||||
|
line2.label as libelle,
|
||||||
|
links.id_transaction as t_amort,
|
||||||
|
line2.id as l_amort,
|
||||||
|
line2.id_transaction as trans_id,
|
||||||
|
line2.id_project as projet,
|
||||||
|
line2.id_account as account_id,
|
||||||
|
trans.date as date_immo,
|
||||||
|
acc.code as account_code,
|
||||||
|
acc.label as nom_compte,
|
||||||
|
acc.id_chart as PC
|
||||||
|
from acc_transactions_lines as line
|
||||||
|
inner JOIN acc_transactions_links as links on line.id_transaction = links.id_related
|
||||||
|
inner JOIN acc_transactions_lines as line2 on links.id_transaction = line2.id_transaction
|
||||||
|
inner join acc_accounts as acc on line2.id_account = acc.id
|
||||||
|
inner join acc_transactions as trans on line2.id_transaction = trans.id
|
||||||
|
where line.id = :line_id and line2.debit <> 0
|
||||||
|
order by trans.date;
|
||||||
|
:line_id = $info_immo.line|intval
|
||||||
|
assign=lines.
|
||||||
|
}}
|
||||||
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
||||||
|
{{/select}}
|
||||||
|
{{*:debug lines=$lines*}}
|
||||||
|
{{*:debug line=$lines.0*}}
|
||||||
|
{{*:debug line=$lines.1*}}
|
||||||
|
|
||||||
{{* calculer les amortissements *}}
|
{{* calculer les amortissements *}}
|
||||||
{{* :debug montant=$ligne_immo.montant *}}
|
|
||||||
{{* montant de l'annuité normale *}}
|
{{* montant de l'annuité normale *}}
|
||||||
{{:assign montant="%d"|math:$ligne_immo.montant|money}}
|
{{:assign montant="%f"|math:$ligne_immo.montant}}
|
||||||
{{:assign annuite="%d/%d"|math:$montant:$info_immo.duration|intval}}
|
{{:assign annuite="%f/%f"|math:$montant:$info_immo.duration|intval}}
|
||||||
{{* :debug annuite=$annuite *}}
|
{{*:debug montant=$montant *}}
|
||||||
|
{{*:debug annuite=$annuite *}}
|
||||||
|
|
||||||
|
{{* liste des exercices *}}
|
||||||
|
{{#years}}
|
||||||
|
{{:assign var="all_years.%d.label"|args:$id value=$label}}
|
||||||
|
{{:assign var="all_years.%d.end_date"|args:$id value=$end_date}}
|
||||||
|
{{:assign var="all_years.%d.closed"|args:$id value=$closed}}
|
||||||
|
{{/years}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
{{:debug all_years=$all_years}}
|
||||||
|
{{:assign current_year=8}}
|
||||||
|
{{:assign var="date_immo" from="all_years.%s.end_date"|args:$current_year}}
|
||||||
|
{{:debug date_immo=$date_immo}}
|
||||||
|
*}}
|
||||||
|
|
||||||
{{* première annuité *}}
|
{{* première annuité *}}
|
||||||
{{:assign date_achat=$ligne_immo.date_achat|date_short}}
|
{{:assign date_achat=$ligne_immo.date_achat|date_short}}
|
||||||
{{:assign date_fin=$ligne_immo.date_fin|date_short}}
|
{{:assign date_fin=$ligne_immo.date_fin|date_short}}
|
||||||
{{:include file="_calcul_dates.html" date_debut=$date_achat date_fin=$date_fin keep="nbjours"}}
|
{{:include file="_calcul_dates.html" date_debut=$date_achat date_fin=$date_fin keep="nbjours"}}
|
||||||
{{:assign annuite_1="%d/360*%d"|math:$annuite:$nbjours|intval}}
|
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
|
||||||
{{* :debug annuite1=$annuite_1 *}}
|
{{*:debug annuite1=$annuite_1 *}}
|
||||||
|
|
||||||
{{:assign date_immo=$date_fin}}
|
{{:assign date_immo=$date_fin}}
|
||||||
{{:assign annuite_courante=$annuite_1}}
|
{{:assign annuite_courante=$annuite_1}}
|
||||||
{{:assign solde=$montant}}
|
{{:assign solde=$montant}}
|
||||||
|
{{:assign current_year=$ligne_immo.year_id}}
|
||||||
<table class="list">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>N°</th>
|
|
||||||
<th>Date</th>
|
|
||||||
<th>Annuité</th>
|
|
||||||
<th>Solde</th>
|
|
||||||
<th class="actions"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{{#foreach count="%d+1"|math:$info_immo.duration|intval key="num"}}
|
|
||||||
{{:assign solde="%d-%d"|math:$solde:$annuite_courante}}
|
|
||||||
<tr>
|
|
||||||
<td>{{"%d+1"|math:$num}}</td>
|
|
||||||
<td>{{$date_immo}}</td>
|
|
||||||
<td class="money">{{"%f*100"|math:$annuite_courante|money}}</td>
|
|
||||||
<td class="money">{{"%f*100"|math:$solde|money}}</td>
|
|
||||||
</tr>
|
|
||||||
{{:assign annuite_courante="min(%d,%d)"|math:$annuite:$solde}}
|
|
||||||
{{:assign jour=$date_immo|date:"d"}}
|
|
||||||
{{:assign mois=$date_immo|date:"m"}}
|
|
||||||
{{:assign annee=$date_immo|date:"Y"}}
|
|
||||||
{{:assign annee="%d+1"|math:$annee}}
|
|
||||||
{{:assign date_immo="%s/%s/%s"|args:$jour:$mois:$annee|parse_date|date_short}}
|
|
||||||
{{* :debug date_immo=$date_immo *}}
|
|
||||||
{{/foreach}}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<section class="amortissement">
|
<section class="amortissement">
|
||||||
<h2 class="ruler">Liste des amortissements</h2>
|
<h2 class="ruler">Liste des amortissements</h2>
|
||||||
|
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>N°</th>
|
<th>N°</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th>Montant</th>
|
<th>Montant</th>
|
||||||
|
<th>Solde</th>
|
||||||
<th>Libellé</th>
|
<th>Libellé</th>
|
||||||
<th>ligne amort</th>
|
<th>ligne amort</th>
|
||||||
<th>Compte</th>
|
<th>Compte</th>
|
||||||
@ -105,44 +115,75 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#select
|
{{#foreach count="%d+1"|math:$info_immo.duration|intval key="num"}}
|
||||||
line.id as l_immo,
|
{{:assign var="line" from="lines.%s"|args:$num}}
|
||||||
line2.debit as montant,
|
{{*:debug line=$line*}}
|
||||||
line2.label as libelle,
|
|
||||||
links.id_transaction as t_amort,
|
{{if $line != null}}
|
||||||
line2.id as l_amort,
|
{{* données de l'écriture *}}
|
||||||
line2.id_transaction as trans_id,
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.t_amort}}
|
||||||
line2.id_project as projet,
|
{{:assign solde="%f-%d"|math:$solde:$line.montant}}
|
||||||
line2.id_account as compte,
|
<tr>
|
||||||
trans.date as date_achat,
|
<td class="num"><a href={{$trans_url}}>#{{$line.t_amort}}</a></td>
|
||||||
acc.code,
|
<td>{{$line.date_immo|date_short}}</td>
|
||||||
acc.label as nom_compte,
|
<td class="money">{{"%f"|math:$line.montant|money}}</td>
|
||||||
acc.id_chart as PC
|
<td class="money">{{"%f"|math:$solde|money}}</td>
|
||||||
from acc_transactions_lines as line
|
<td>{{$line.libelle}}</td>
|
||||||
inner JOIN acc_transactions_links as links on line.id_transaction = links.id_related
|
<td>{{$line.l_amort}}</td>
|
||||||
inner JOIN acc_transactions_lines as line2 on links.id_transaction = line2.id_transaction
|
<td>{{$line.account_code}}</td>
|
||||||
inner join acc_accounts as acc on line2.id_account = acc.id
|
<td>{{$line.nom_compte}}</td>
|
||||||
inner join acc_transactions as trans on line2.id_transaction = trans.id
|
<td class="actions"></td>
|
||||||
where line.id = :line_id and line2.debit <> 0
|
</tr>
|
||||||
order by trans.date;
|
{{:assign libelle=$line.libelle}}
|
||||||
:line_id = $info_immo.line|intval
|
{{:assign ammort_account=$line.ammort_account}}
|
||||||
assign=lines.
|
{{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}}
|
||||||
}}
|
{{:assign current_year="%d+1"|math:$current_year}}
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
{{:assign date_immo=$line.date_immo}}
|
||||||
<tr>
|
|
||||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
{{else}}
|
||||||
<td>{{$date_achat|date_short}}</td>
|
{{* pas d'écriture *}}
|
||||||
<td class="money">{{"%f"|math:$montant|money}}</td>
|
|
||||||
<td>{{$libelle}}</td>
|
{{:assign solde="%f-%d"|math:$solde:$annuite_courante}}
|
||||||
<td>{{$l_amort}}</td>
|
{{if $all_years|keys|has:$current_year}}
|
||||||
<td>{{$compte}}</td>
|
{{:assign var="date_immo" from="all_years.%s.end_date"|args:$current_year}}
|
||||||
<td>{{$nom_compte}}</td>
|
{{:assign date_immo=$date_immo|date_short}}
|
||||||
<td></td>
|
{{else}}
|
||||||
</tr>
|
{{:assign jour=$date_immo|date:"d"}}
|
||||||
{{/select}}
|
{{:assign mois=$date_immo|date:"m"}}
|
||||||
|
{{:assign annee=$date_immo|date:"Y"}}
|
||||||
|
{{:assign annee="%d+1"|math:$annee}}
|
||||||
|
{{:assign date_immo="%s/%s/%s"|args:$jour:$mois:$annee|parse_date|date_short}}
|
||||||
|
{{/if}}
|
||||||
|
<tr>
|
||||||
|
<td class="num">{{"%d+1"|math:$num}}</td>
|
||||||
|
<td>{{$date_immo}}</td>
|
||||||
|
<td class="money">{{"%f"|math:$annuite_courante|money}}</td>
|
||||||
|
<td class="money">{{if $solde == 0}}0,00{{else}}{{"%f"|math:$solde|money}}{{/if}}</td>
|
||||||
|
<td>
|
||||||
|
{{if $libelle == null}}
|
||||||
|
{{:assign libelle="Amortissement "|cat:$ligne_immo.label}}
|
||||||
|
{{/if}}
|
||||||
|
{{$libelle}}
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td class="actions">
|
||||||
|
{{if $all_years|keys|has:$current_year}}
|
||||||
|
{{:linkbutton
|
||||||
|
label="Enregistrer"
|
||||||
|
href="save_amort.html?amount=%d&account=%s&year=%s&label=%s"|args:$annuite_courante:$ligne_immo.account_id:$current_year:$libelle
|
||||||
|
shape="right"
|
||||||
|
}}
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{:assign current_year="%d+1"|math:$current_year}}
|
||||||
|
{{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}}
|
||||||
|
{{/if}}
|
||||||
|
{{/foreach}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
{{* :debug lines=$lines *}}
|
{{:form_errors}}
|
||||||
{{* :form_errors *}}
|
|
||||||
{{:admin_footer}}
|
{{:admin_footer}}
|
||||||
|
Loading…
Reference in New Issue
Block a user