2024-02-15 14:23:03 +01:00
{{:admin_header title="Gestion des amortissements" custom_css=$custom_css current="module_amortissement"}}
{{* barre de navigation *}}
2024-02-16 11:54:50 +01:00
{{:include file="_nav.html" current="amortization"}}
2024-02-15 14:23:03 +01:00
{{* récupérer les infos de l'immobilisation *}}
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.line|intval}}
{{else}}
{{:assign message="Immobilisation %s non trouvée"|args:$_GET.line}}
{{:error message=$message}}
{{/load}}
{{#select
line.id as line_id,
2024-02-16 11:54:50 +01:00
line.id_account as account_id,
2024-02-17 19:00:24 +01:00
line.id_project as project_id,
2024-02-15 14:23:03 +01:00
trans.id as trans_id,
line.debit as montant,
trans.label as label,
trans.date as date_achat,
2024-02-16 11:54:50 +01:00
y.id as year_id,
2024-02-17 19:00:24 +01:00
y.end_date as date_fin,
project.label as project_label
2024-02-15 14:23:03 +01:00
from acc_transactions_lines as line
inner join acc_transactions as trans on line.id_transaction = trans.id
inner join acc_years as y on trans.id_year = y.id
2024-02-17 19:00:24 +01:00
left join acc_projects AS project ON line.id_project = project.id
2024-02-15 14:23:03 +01:00
where line.id = :line_id;
:line_id = $_GET.line|intval
assign=ligne_immo
}}
2024-02-17 19:00:24 +01:00
< h2 > Amortissement de « {{$label}} » d'un montant de {{"%f"|math:$montant|money_currency}} en date du {{$date_achat|date_short}} sur {{$info_immo.duration}} ans< / h2 >
2024-02-15 14:23:03 +01:00
{{else}}
{{:assign message="Immobilisation %s non trouvée"|args:$_GET.line}}
{{:error message=$message}}
{{/select}}
2024-02-16 11:54:50 +01:00
{{* 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,
2024-02-17 19:00:24 +01:00
line2.id_project as project_id,
project.label as project_label,
2024-02-16 11:54:50 +01:00
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
2024-02-17 19:00:24 +01:00
left join acc_projects AS project ON line.id_project = project.id
2024-02-16 11:54:50 +01:00
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}}
2024-02-15 14:23:03 +01:00
{{* calculer les amortissements *}}
{{* montant de l'annuité normale *}}
2024-02-16 11:54:50 +01:00
{{:assign montant="%f"|math:$ligne_immo.montant}}
{{:assign annuite="%f/%f"|math:$montant:$info_immo.duration|intval}}
{{* 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}}
2024-02-15 14:23:03 +01:00
{{* première annuité *}}
{{:assign date_achat=$ligne_immo.date_achat|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"}}
2024-02-16 11:54:50 +01:00
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
2024-02-15 14:23:03 +01:00
{{:assign date_immo=$date_fin}}
{{:assign annuite_courante=$annuite_1}}
{{:assign solde=$montant}}
2024-02-16 11:54:50 +01:00
{{:assign current_year=$ligne_immo.year_id}}
2024-02-17 19:00:24 +01:00
{{:assign project_id=$ligne_immo.project_id}}
{{:assign project_label=$ligne_immo.project_label}}
2024-02-15 14:23:03 +01:00
< section class = "amortissement" >
< h2 class = "ruler" > Liste des amortissements< / h2 >
< table class = "list" >
< thead >
< tr >
< th > N°< / th >
< th > Date< / th >
< th > Montant< / th >
2024-02-16 11:54:50 +01:00
< th > Solde< / th >
2024-02-15 14:23:03 +01:00
< th > Libellé< / th >
2024-02-17 19:00:24 +01:00
< th > N° compte< / th >
2024-02-15 14:23:03 +01:00
< th > Compte< / th >
2024-02-17 19:00:24 +01:00
< th > Projet< / th >
2024-02-15 14:23:03 +01:00
< th class = "actions" > < / th >
< / tr >
< / thead >
< tbody >
2024-02-16 11:54:50 +01:00
{{#foreach count="%d+1"|math:$info_immo.duration|intval key="num"}}
{{:assign var="line" from="lines.%s"|args:$num}}
{{if $line != null}}
{{* données de l'écriture *}}
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.t_amort}}
{{:assign solde="%f-%d"|math:$solde:$line.montant}}
< tr >
< td class = "num" > < a href = {{$trans_url}} > #{{$line.t_amort}}< / a > < / td >
< td > {{$line.date_immo|date_short}}< / td >
< td class = "money" > {{"%f"|math:$line.montant|money}}< / td >
< td class = "money" > {{"%f"|math:$solde|money}}< / td >
< td > {{$line.libelle}}< / td >
< td > {{$line.account_code}}< / td >
< td > {{$line.nom_compte}}< / td >
2024-02-17 19:00:24 +01:00
< td > {{$line.project_label}}< / td >
2024-02-16 11:54:50 +01:00
< td class = "actions" > < / td >
< / tr >
{{:assign libelle=$line.libelle}}
{{:assign ammort_account=$line.ammort_account}}
2024-02-17 19:00:24 +01:00
{{:assign project_id=$line.project_id}}
{{:assign project_label=$line.project_label}}
2024-02-16 11:54:50 +01:00
{{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}}
{{:assign current_year="%d+1"|math:$current_year}}
{{:assign date_immo=$line.date_immo}}
{{else}}
{{* pas d'écriture *}}
{{:assign solde="%f-%d"|math:$solde:$annuite_courante}}
{{if $all_years|keys|has:$current_year}}
{{:assign var="date_immo" from="all_years.%s.end_date"|args:$current_year}}
{{:assign date_immo=$date_immo|date_short}}
{{else}}
{{: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}}
{{/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 >
2024-02-17 19:00:24 +01:00
< td > {{$project_label}}< / td >
2024-02-16 11:54:50 +01:00
< td class = "actions" >
{{if $all_years|keys|has:$current_year}}
{{:linkbutton
label="Enregistrer"
2024-02-17 19:00:24 +01:00
href="save_amort.html?amount=%d& account=%s& year=%s& trans_id=%d& line_id=%s& project_id=%d& label=%s"|args:$annuite_courante:$ligne_immo.account_id:$current_year:$ligne_immo.trans_id:$_GET.line:$project_id:$libelle
2024-02-16 11:54:50 +01:00
shape="right"
}}
2024-02-17 19:00:24 +01:00
{{else}}
{{:linkbutton label="Enregistrer" href="" shape="alert"}}
2024-02-16 11:54:50 +01:00
{{/if}}
< / td >
< / tr >
{{:assign current_year="%d+1"|math:$current_year}}
{{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}}
{{/if}}
{{/foreach}}
2024-02-15 14:23:03 +01:00
< / tbody >
< / table >
< / section >
2024-02-16 11:54:50 +01:00
{{:form_errors}}
2024-02-15 14:23:03 +01:00
{{:admin_footer}}