début réorganisation classement immobilisations

This commit is contained in:
Jean-Christophe Engel 2025-02-04 16:25:32 +01:00
parent 2c11d3e4f3
commit fb0d34a4f4
8 changed files with 202 additions and 59 deletions

View File

@ -14,9 +14,10 @@
{{if $current == 'index'}} {{if $current == 'index'}}
<ul class="sub"> <ul class="sub">
<li {{if $subcurrent == 'amort'}}class="current"{{/if}}><a href="index.html?amort=amort">Amortissables</a></li> <li {{if $subcurrent == 'encours'}}class="current"{{/if}}><a href="index.html?amort=encours">En cours</a></li>
<li {{if $subcurrent == 'fini'}}class="current"{{/if}}><a href="index.html?amort=fini">Terminées</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> <li {{if $subcurrent == 'archive'}}class="current"{{/if}}><a href="index.html?amort=archive">Archivées</a></li>
<li {{if $subcurrent == 'autres'}}class="current"{{/if}}><a href="index.html?amort=autres">Autres</a></li>
</ul> </ul>
{{if $subsubcurrent == 'amortization'}} {{if $subsubcurrent == 'amortization'}}

View File

@ -106,9 +106,9 @@
noamort=$noamort noamort=$noamort
}} }}
{{if $_POST.no_amort}} {{if $_POST.no_amort}}
{{:assign amort=0}} {{:assign amort="autres"}}
{{else}} {{else}}
{{:assign amort=1}} {{:assign amort="encours"}}
{{/if}} {{/if}}
{{:redirect force="index.html?ok=1&msg=immobilisation&amort=%s"|args:$amort}} {{:redirect force="index.html?ok=1&msg=immobilisation&amort=%s"|args:$amort}}
{{/form}} {{/form}}

View File

@ -55,9 +55,9 @@
}} }}
{{if $_POST.no_amort}} {{if $_POST.no_amort}}
{{:assign amort=0}} {{:assign amort="autres"}}
{{else}} {{else}}
{{:assign amort=1}} {{:assign amort="encours"}}
{{/if}} {{/if}}
{{:redirect force="index.html?ok=1&msg=infos&amort=%s"|args:$amort}} {{:redirect force="index.html?ok=1&msg=infos&amort=%s"|args:$amort}}
{{else}} {{else}}

View File

@ -3,12 +3,14 @@
{{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortissement"}} {{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortissement"}}
{{* barre de navigation *}} {{* barre de navigation *}}
{{if $_GET.amort == null || $_GET.amort == "amort"}} {{if $_GET.amort == null || $_GET.amort == "encours"}}
{{:assign subcurrent="amort"}} {{:assign subcurrent="encours"}}
{{elseif $_GET.amort == "fini"}} {{elseif $_GET.amort == "fini"}}
{{:assign subcurrent="fini"}} {{:assign subcurrent="fini"}}
{{elseif $_GET.amort == "archive"}}
{{:assign subcurrent="archive"}}
{{else}} {{else}}
{{:assign subcurrent="no_amort"}} {{:assign subcurrent="autres"}}
{{/if}} {{/if}}
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$subcurrent subsubcurrent="amortization"}} {{:include file="_nav.html" current="index" subcurrent="%s"|args:$subcurrent subsubcurrent="amortization"}}
@ -16,7 +18,7 @@
{{if $_GET.msg|match:"attach"}} {{if $_GET.msg|match:"attach"}}
{{:assign msg="Attachement effectué (écriture %s)"|args:$_GET.trans_id}} {{:assign msg="Attachement effectué (écriture %s)"|args:$_GET.trans_id}}
{{elseif $_GET.msg|match:"detach"}} {{elseif $_GET.msg|match:"detach"}}
{{:assign msg="Attachement supprimé (écriture %s)"|args:$_GET.trans_id}} {{:assign msg="Attachement détaché (écriture %s)"|args:$_GET.trans_id}}
{{elseif $_GET.msg|match:"amortissement"}} {{elseif $_GET.msg|match:"amortissement"}}
{{:assign msg="Amortissement enregistré"}} {{:assign msg="Amortissement enregistré"}}
{{/if}} {{/if}}
@ -72,9 +74,8 @@
trans.id_year as amort_year, trans.id_year as amort_year,
account.id as account_id, account.id as account_id,
account.code as account_code, account.code as account_code,
account.label as account_name account.label as account_label
FROM FROM acc_transactions_lines as l_immo
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 as t_immo on t_immo.id = l_immo.id_transaction
INNER JOIN acc_transactions_links as links INNER JOIN acc_transactions_links as links
ON ( ON (
@ -165,7 +166,7 @@
{{/if}} {{/if}}
</td> </td>
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td> <td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
<td>{{$line.account_name}}</td> <td>{{$line.account_label}}</td>
<td> <td>
{{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line:$ligne_immo.immo_id shape="plus"}} {{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line:$ligne_immo.immo_id shape="plus"}}
</td> </td>
@ -242,19 +243,19 @@
{{* Autres amortissements non rattachés *}} {{* Autres amortissements non rattachés *}}
{{#select {{#select
li.id as l_id, line.id as l_id,
li.id_transaction as t_id, line.id_transaction as t_id,
li.credit as montant, line.credit as amort_amount,
li.reference, line.label as l_label,
li.label as l_label,
trans.date as t_date, trans.date as t_date,
trans.label as t_label, trans.label as t_label,
account.code as a_code, trans.id_year as amort_year,
account.label as a_label, account.id as account_id,
y.label as y_label account.code as account_code,
FROM acc_transactions_lines AS li account.label as account_label
INNER JOIN acc_accounts AS account ON account.id = li.id_account FROM acc_transactions_lines AS line
INNER JOIN acc_transactions AS trans ON trans.id = li.id_transaction 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 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) WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16)
ORDER BY trans.date, trans.label; ORDER BY trans.date, trans.label;
@ -288,21 +289,21 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{#foreach from=$autres_amortissements item="line"}} {{#foreach from=$autres_amortissements item="line"}}
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.t_id}} {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.t_id}}
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
<tr> <tr>
<td class="num"><a href={{$trans_url}}>#{{$line.t_id}}</a></td> <td class="num"><a href={{$trans_url}}>#{{$line.t_id}}</a></td>
<td>{{$line.t_date|date_short}}</td> <td>{{$line.t_date|date_short}}</td>
<td class="money">{{"%f"|math:$line.montant|money}}</td> <td class="money">{{"%f"|math:$line.amort_amount|money}}</td>
<td>{{if $line.l_label == null}} <td>{{if $line.l_label == null}}
{{$line.t_label}} {{$line.t_label}}
{{else}} {{else}}
{{$line.l_label}} {{$line.l_label}}
{{/if}} {{/if}}
</td> </td>
<td>{{$line.a_code}}</td> <td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
<td>{{$line.a_label}}</td> <td>{{$line.account_label}}</td>
<td> <td>
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$line.l_id:$ligne_immo.immo_id shape="plus"}} {{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$line.l_id:$ligne_immo.immo_id shape="plus"}}
</td> </td>

View File

@ -3,9 +3,9 @@
{{* Liste des immobilisations amortissable ou à définir *}} {{* Liste des immobilisations amortissable ou à définir *}}
<section class="immobilisation"> <section class="immobilisation">
{{if $amort == "amort"}} {{if $amort == "encours"}}
<h2 class="ruler">Immobilisations en cours</h2> <h2 class="ruler">Immobilisations en cours</h2>
{{else}} {{elseif $amort == "fini"}}
<h2 class="ruler">Immobilisations amorties</h2> <h2 class="ruler">Immobilisations amorties</h2>
{{/if}} {{/if}}
@ -19,7 +19,6 @@
<th class="nombre">Durée</th> <th class="nombre">Durée</th>
<th>N° compte</th> <th>N° compte</th>
<th>Compte</th> <th>Compte</th>
<th>Projet</th>
<th class="actions"></th> <th class="actions"></th>
</tr> </tr>
</thead> </thead>
@ -46,13 +45,11 @@
account.code as account_code, account.code as account_code,
account.label as account_label, account.label as account_label,
line.debit AS debit, line.debit AS debit,
project.label as project_label,
trans.id_year as trans_id_year trans.id_year as trans_id_year
FROM acc_transactions AS trans FROM acc_transactions AS trans
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id 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_accounts AS account ON line.id_account = account.id
INNER JOIN acc_years AS years ON trans.id_year = years.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 WHERE !condition
ORDER BY trans.date DESC; ORDER BY trans.date DESC;
!condition=$condition !condition=$condition
@ -98,7 +95,7 @@
AND AND
account.code LIKE '28%'; account.code LIKE '28%';
:line_id = $immo_id|intval :line_id = $immo_id|intval
}} }}
{{if $amort_amount == null}} {{if $amort_amount == null}}
{{:assign exist_amort=false}} {{:assign exist_amort=false}}
{{:assign amort_amount=0}} {{:assign amort_amount=0}}
@ -108,8 +105,9 @@
{{/if}} {{/if}}
{{/select}} {{/select}}
{{* immo amortie ? *}} {{* immo amortie ? *}}
{{if $amort == "amort" && $amort_amount >= $debit || {{if $amort == "encours" && $amort_amount >= $debit ||
$amort == "fini" && $amort_amount < $debit $amort == "fini" && $amort_amount < $debit ||
$amortissable == "nsp" && ! $exist_amort
}} }}
{{:continue}} {{:continue}}
{{/if}} {{/if}}
@ -121,30 +119,40 @@
<td class="money">{{if $duration != null}}{{$duration}}{{/if}}</td> <td class="money">{{if $duration != null}}{{$duration}}{{/if}}</td>
<td><a href={{$compte_url}}>{{$account_code}}</a></td> <td><a href={{$compte_url}}>{{$account_code}}</a></td>
<td>{{$account_label}}</td> <td>{{$account_label}}</td>
<td>{{$project_label}}</td>
<td class="actions"> <td class="actions">
{{if ! $exist_amort && $duration == null}} {{if ! $exist_amort}}
{{:linkbutton {{: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" label="Modifier infos"
href="modif_infos.html?immo_id=%s&amort=1"|args:$immo_id href="modif_infos.html?immo_id=%s&amort=1"|args:$immo_id
shape="help" shape="settings"
target="_dialog" target="_dialog"
}} }}
{{/if}} {{elseif $amortissable == "nsp"}}
{{:linkbutton {{:linkbutton
label="Amortissements" label="Ajouter infos"
href="amortization.html?immo_id=%s&amort=%s"|args:$immo_id:$amort href="add_infos.html?immo_id=%s&amort=1"|args:$immo_id
shape="table" shape="settings"
target="_dialog"
}} }}
{{/if}} {{/if}}
{{if $amort == "encours"}}
{{:linkbutton
label="Cession"
href=""
shape="money"
}}
{{elseif $amort == "fini"}}
{{:linkbutton
label="Rebut"
href=""
shape="export"
}}
{{/if}}
{{:linkbutton
label="Amortissements"
href="amortization.html?immo_id=%s&amort=%s"|args:$immo_id:$amort
shape="table"
}}
</td> </td>
</tr> </tr>
{{/select}} {{/select}}

133
immobilisations_autres.html Normal file
View File

@ -0,0 +1,133 @@
{{* -*- brindille -*- *}}
{{* Liste des immobilisations non amortissables ou non (encore) gérées *}}
<section class="immobilisation">
<h2 class="ruler">Autres immobilisations</h2>
<table class="list">
<thead>
<tr>
<th></th>
<th>Date</th>
<th>Libellé</th>
<th class="nombre">Montant</th>
<th>N° compte</th>
<th>Compte</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 AND NOT (trans.status & 16)"}}
{{#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,
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
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}}
{{* voir si l'immo est prise en charge *}}
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
{{if $noamort}}
{{:assign amortissable="non"}}
{{else}}
{{:assign amortissable="oui"}}
{{/if}}
{{else}}
{{:assign amortissable="nsp"}}
{{/load}}
{{if $amortissable == "oui"}}
{{: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
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
WHERE
l_immo.id = :line_id
AND
l_amort.credit <> 0
AND
account.code LIKE '28%';
:line_id = $immo_id|intval
}}
{{if $amort_amount != null}}
{{:assign ignore=true}}
{{else}}
{{:assign ignore=false}}
{{/if}}
{{/select}}
{{if $ignore}}
{{: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:false}}</td>
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
<td>{{$account_label}}</td>
<td class="actions">
{{if $amortissable == "nsp"}}
{{:linkbutton
label="Ajouter infos"
href="add_infos.html?immo_id=%s&amort=1"|args:$immo_id
shape="settings"
target="_dialog"
}}
{{else}}
{{:linkbutton
label="Modifier infos"
href="modif_infos.html?immo_id=%s&amort=0"|args:$immo_id
shape="help"
target="_dialog"
}}
{{/if}}
</td>
</tr>
{{/select}}
</tbody>
</table>
</section>

View File

@ -3,7 +3,7 @@
{{* barre de navigation *}} {{* barre de navigation *}}
{{if $_GET.amort == null}} {{if $_GET.amort == null}}
{{:assign amort="amort"}} {{:assign amort="encours"}}
{{else}} {{else}}
{{:assign amort=$_GET.amort}} {{:assign amort=$_GET.amort}}
{{/if}} {{/if}}
@ -47,9 +47,9 @@
{{/select}} {{/select}}
{{/load}} {{/load}}
{{if $amort == "no_amort"}} {{if $amort == "autres"}}
{{:include file="./immobilisations_non.html"}} {{:include file="./immobilisations_autres.html"}}
{{else}} {{elseif $amort == "encours" || $amort == "fini"}}
{{:include file="./immobilisations.html"}} {{:include file="./immobilisations.html"}}
{{/if}} {{/if}}

View File

@ -58,9 +58,9 @@
}} }}
{{if $_POST.no_amort}} {{if $_POST.no_amort}}
{{:assign amort=0}} {{:assign amort="autres"}}
{{else}} {{else}}
{{:assign amort=1}} {{:assign amort="encours"}}
{{/if}} {{/if}}
{{:redirect force="index.html?ok=1&msg=infos&amort=%s"|args:$amort}} {{:redirect force="index.html?ok=1&msg=infos&amort=%s"|args:$amort}}
{{else}} {{else}}