restructuration et complément classification immobilisations

This commit is contained in:
Jean-Christophe Engel 2025-01-10 13:53:47 +01:00
parent 3ef33e15e3
commit 5fcf510b25
5 changed files with 132 additions and 277 deletions

View File

@ -1,4 +1,10 @@
<nav class="tabs">
{{if $current == 'index'}}
<aside>
{{:linkbutton label="Ajouter une immobilisation" shape="plus" href="add_asset.html" target="_dialog"}}
</aside>
{{/if}}
<ul>
<li {{if $current == 'index'}} class="current"{{/if}}><a href="{{$module.url}}index.html">Immobilisations</a></li>
<li {{if $current == 'aide'}} class="current"{{/if}}><a href="{{$module.url}}aide.html">Aide</a></li>
@ -6,9 +12,9 @@
{{if $current == 'index'}}
<ul class="sub">
<li {{if $subcurrent == 'amort'}}class="current"{{/if}}><a href="index.html?amort=1">Amortissables</a></li>
<li {{if $subcurrent == 'fini'}}class="current"{{/if}}><a href="index.html?amort=2">Terminées</a></li>
<li {{if $subcurrent == 'no_amort'}}class="current"{{/if}}><a href="index.html?amort=0">Non amortissables</a></li>
<li {{if $subcurrent == 'amort'}}class="current"{{/if}}><a href="index.html?amort=amort">Amortissables</a></li>
<li {{if $subcurrent == 'fini'}}class="current"{{/if}}><a href="index.html?amort=fini">Terminées</a></li>
<li {{if $subcurrent == 'no_amort'}}class="current"{{/if}}><a href="index.html?amort=no_amort">Non amortissables</a></li>
</ul>
{{if $subsubcurrent == 'amortization'}}
<ul class="sub">

View File

@ -3,9 +3,9 @@
{{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortissement"}}
{{* barre de navigation *}}
{{if $_GET.fini == null || $_GET.fini == 0}}
{{if $_GET.amort == null || $_GET.amort == "amort"}}
{{:assign subcurrent="amort"}}
{{elseif $_GET.fini == 1}}
{{elseif $_GET.amort == "fini"}}
{{:assign subcurrent="fini"}}
{{else}}
{{:assign subcurrent="no_amort"}}
@ -31,13 +31,6 @@
{{/if}}
{{* récupérer les infos de l'immobilisation *}}
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
{{else}}
{{:error message="Pas d'info concernant l'immobilisation %s"|args:$_GET.immo_id}}
{{/load}}
{{:assign var="duree" from="info_immo.duration"|args:$_GET.immo_id}}
{{:assign date_debut=$info_immo.date}}
{{#select
line.id as immo_id,
line.id_account as account_id,
@ -56,11 +49,15 @@
:line_id = $_GET.immo_id|intval
assign=ligne_immo
}}
<h2>Amortissement de « {{$label}} » d'un montant de {{"%f"|math:$montant|money_currency}} en date du {{$date_debut|date_short}} sur {{$duree}} ans</h2>
{{else}}
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
{{/select}}
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
{{:assign var="duree" from="info_immo.duration"|args:$_GET.immo_id}}
{{:assign date_debut=$info_immo.date}}
{{/load}}
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
{{#select
l_amort.credit as amort_amount,
@ -97,25 +94,32 @@
assign=linked_lines.
}}
{{:assign var="amort_years." value=$amort_year}}
{{if $date_debut == null}}
{{:assign date_debut=$amort_date}}
{{/if}}
{{/select}}
{{* montant de l'annuité théorique *}}
{{:assign montant="%f"|math:$ligne_immo.montant}}
{{:assign annuite="%f/%f"|math:$montant:$duree}}
{{* première annuité *}}
{{:assign date_amort=$ligne_immo.date_amort}}
{{if $date_amort|strtotime < $date_debut|strtotime}}
<h2>Amortissement de « {{$ligne_immo.label}} » d'un montant de {{"%f"|math:$ligne_immo.montant|money_currency}} en date du {{$date_debut|date_short}}{{if $duree != null}} sur {{$duree}} ans{{/if}}</h2>
{{if $duree != null}}
{{* montant de l'annuité théorique *}}
{{:assign montant="%f"|math:$ligne_immo.montant}}
{{:assign annuite="%f/%f"|math:$montant:$duree}}
{{* première annuité *}}
{{:assign date_amort=$ligne_immo.date_amort}}
{{if $date_amort|strtotime < $date_debut|strtotime}}
{{* changer d'exercice *}}
{{:include file="_next_year.html" date=$date_amort keep="date_amort"}}
{{:assign date_amort=$date_amort|parse_date}}
{{/if}}
{{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}}
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
{{:assign annuite_courante=$annuite_1}}
{{:assign current_year=$ligne_immo.year_id}}
{{:assign nbamort=0}}
{{/if}}
{{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}}
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
{{:assign annuite_courante=$annuite_1}}
{{:assign current_year=$ligne_immo.year_id}}
{{:assign solde=$ligne_immo.montant}}
{{:assign nbamort=0}}
{{:assign solde=$ligne_immo.montant}}
{{if $linked_lines != null}}
<section class="amortissement">
<h3 class="ruler">
@ -172,7 +176,7 @@
</section>
{{/if}}
{{if $solde > 0}}
{{if $duree != null && $solde > 0}}
{{:assign project_id=$ligne_immo.project_id}}
{{:assign project_label=$ligne_immo.project_label}}
{{:assign nbamort="%d-%d"|math:$duree:$nbamort}}
@ -231,16 +235,16 @@
</section>
{{/if}}
{{if $_GET.fini == null || $_GET.fini != 1}}
{{if $_GET.amort == null || $_GET.amort != "fini"}}
{{* amortissement à exclure *}}
{{:include
{{* amortissement à exclure *}}
{{:include
file="_amort_exclus.html"
keep="amort_exclus"
}}
}}
{{* Autres amortissements non rattachés *}}
{{#select
{{* Autres amortissements non rattachés *}}
{{#select
li.id as l_id,
li.id_transaction as t_id,
li.credit as montant,
@ -255,10 +259,10 @@
inner join acc_accounts as acc on acc.id = li.id_account
inner join acc_transactions as trans on trans.id = li.id_transaction
inner join acc_years as y on y.id = trans.id_year
where acc.code like "28%"
where acc.code like "28%" AND credit > 0
order by trans.date, trans.label;
assign=autre_amort
}}
}}
{{#select
id_transaction,
id_related
@ -272,9 +276,9 @@
{{:assign var="autres_amortissements." value=$autre_amort}}
{{/if}}
{{/select}}
{{/select}}
{{/select}}
{{if $autres_amortissements != null}}
{{if $autres_amortissements != null}}
<section class="amortissement">
<h3 class="ruler">Autres amortissements non rattachés</h3>
<table class="list">
@ -313,7 +317,7 @@
</tbody>
</table>
</section>
{{/if}}
{{/if}}
{{/if}}
{{:form_errors}}
{{:admin_footer}}

View File

@ -3,7 +3,11 @@
{{* Liste des immobilisations amortissable ou à définir *}}
<section class="immobilisation">
{{if $amort == "amort"}}
<h2 class="ruler">Immobilisations en cours</h2>
{{else}}
<h2 class="ruler">Immobilisations amorties</h2>
{{/if}}
<table class="list">
<thead>
@ -101,7 +105,9 @@
{{/if}}
{{/select}}
{{* immo amortie ? *}}
{{if $amort_amount >= $debit}}
{{if $amort == "amort" && $amort_amount >= $debit ||
$amort == "fini" && $amort_amount < $debit
}}
{{:continue}}
{{/if}}
<tr>
@ -114,7 +120,7 @@
<td>{{$account_label}}</td>
<td>{{$project_label}}</td>
<td class="actions">
{{if $duration == null}}
{{if ! $exist_amort && $duration == null}}
{{:linkbutton
label="Ajouter infos"
href="add_infos.html?immo_id=%s&amort=1"|args:$immo_id
@ -132,7 +138,7 @@
{{/if}}
{{:linkbutton
label="Amortissements"
href="amortization.html?immo_id=%s"|args:$immo_id
href="amortization.html?immo_id=%s&amort=%s"|args:$immo_id:$amort
shape="table"
}}
{{/if}}
@ -142,17 +148,3 @@
</tbody>
</table>
</section>
<form method="post" action="">
<fieldset>
<legend>Ajouter une immobilisation</legend>
<p class="submit">
{{:linkbutton
label="Ajouter une immobilisation"
shape="plus"
href="add_asset.html"
target="_dialog"
}}
</p>
</fieldset>
</form>

View File

@ -1,144 +0,0 @@
{{* -*- brindille -*- *}}
{{* Liste des immobilisations totalement amorties *}}
<section class="immobilisation">
<h2 class="ruler">Immobilisations amorties</h2>
<table class="list">
<thead>
<tr>
<th></th>
<th>Date</th>
<th>Libellé</th>
<th class="nombre">Montant</th>
<th class="nombre">Durée</th>
<th>N° compte</th>
<th>Compte</th>
<th>Projet</th>
<th class="actions"></th>
</tr>
</thead>
<tbody>
{{* lister les immobilisations *}}
{{:read file="./defaut.json" assign="config_json"}}
{{:assign config_defaut=$config_json|json_decode}}
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
{{:assign quote="'"}}
{{:assign condition="("}}
{{#foreach from=$prefix_array item="code"}}
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}}
{{/foreach}}
{{:assign condition=$condition|cat:"0)"}}
{{:assign condition=$condition|cat:" AND debit > 0"}}
{{#select
trans.id as trans_id,
trans.label as trans_label,
trans.date as trans_date,
line.id as immo_id,
account.id as account_id,
account.code as account_code,
account.label as account_label,
line.debit AS debit,
project.label as project_label,
trans.id_year as trans_id_year
FROM acc_transactions AS trans
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
INNER JOIN acc_accounts AS account ON line.id_account = account.id
INNER JOIN acc_years AS years ON trans.id_year = years.id
LEFT JOIN acc_projects AS project ON line.id_project = project.id
WHERE !condition
ORDER BY trans.date DESC;
!condition=$condition
}}
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}}
{{:assign duration=null}}
{{* voir si l'immo est prise en charge *}}
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
{{:assign duration=$duration}}
{{if $noamort}}
{{:assign amortissable="non"}}
{{else}}
{{:assign amortissable="oui"}}
{{/if}}
{{else}}
{{:assign amortissable="nsp"}}
{{/load}}
{{if $amortissable == "non"}}
{{:continue}}
{{/if}}
{{* voir s'il existe des écritures d'amortissement associées *}}
{{#select
sum(l_amort.credit) as amort_amount,
CASE links.id_related = t_immo.id
WHEN true THEN links.id_transaction
WHEN false THEN links.id_related
END as amort_trans_id
FROM acc_transactions_lines as l_immo
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
INNER JOIN acc_transactions_links as links
ON (
t_immo.id = links.id_transaction
OR
t_immo.id = links.id_related
)
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
WHERE
l_immo.id = :line_id
AND
l_amort.credit <> 0;
:line_id = $immo_id|intval
}}
{{if $amort_amount == null}}
{{:assign exist_amort=false}}
{{:assign amort_amount=0}}
{{else}}
{{:assign amort_amount=$amort_amount}}
{{:assign exist_amort=true}}
{{/if}}
{{/select}}
{{* immo amortie ? *}}
{{if $amort_amount < $debit}}
{{:continue}}
{{/if}}
<tr>
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
<td>{{$trans_date|date_short}}</td>
<td>{{$trans_label}}</td>
<td class="money">{{"%f"|math:$debit|money}}</td>
<td class="money">{{if $duration != null}}{{$duration}}{{/if}}</td>
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
<td>{{$account_label}}</td>
<td>{{$project_label}}</td>
<td class="actions">
{{if $duration == null}}
{{:linkbutton
label="Ajouter infos"
href="add_infos.html?immo_id=%s&amort=1"|args:$immo_id
shape="help"
target="_dialog"
}}
{{else}}
{{if ! $exist_amort}}
{{:linkbutton
label="Modifier infos"
href="modif_infos.html?immo_id=%s&amort=1"|args:$immo_id
shape="help"
target="_dialog"
}}
{{/if}}
{{:linkbutton
label="Amortissements"
href="amortization.html?immo_id=%s&fini=1"|args:$immo_id
shape="table"
}}
{{/if}}
</td>
</tr>
{{/select}}
</tbody>
</table>
</section>

View File

@ -2,12 +2,10 @@
{{:admin_header title="Gestion des amortissements" custom_css="./style.css" current="module_amortissement"}}
{{* barre de navigation *}}
{{if $_GET.amort == null || $_GET.amort == 1}}
{{if $_GET.amort == null}}
{{:assign amort="amort"}}
{{elseif $_GET.amort == 2}}
{{:assign amort="fini"}}
{{else}}
{{:assign amort="no_amort"}}
{{:assign amort=$_GET.amort}}
{{/if}}
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$amort}}
@ -37,11 +35,10 @@
{{/select}}
{{/load}}
{{if $amort == "amort"}}
{{:include file="./immobilisations.html"}}
{{elseif $amort == "fini"}}
{{:include file="./immobilisations_achevees.html"}}
{{else}}
{{if $amort == "no_amort"}}
{{:include file="./immobilisations_non.html"}}
{{else}}
{{:include file="./immobilisations.html"}}
{{/if}}
{{:admin_footer}}