Amélioration détection immobilisations archivées

This commit is contained in:
Jean-Christophe Engel 2025-05-22 11:30:40 +02:00
parent 255ffe10aa
commit c096282f08

View file

@ -2,25 +2,7 @@
{{* Liste des immobilisations archivées *}}
<section class="immobilisation">
<h2 class="ruler">Immobilisations archivées</h2>
{{:assign nb_immo=0}}
<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>Projet</th>
<th class="actions"></th>
</tr>
</thead>
<tbody>
{{* Immobilisation archivées prises en charge *}}
{{#load type="immo" where="$$.status = 'archived'"}}
{{:assign var="lines." value="'%s'"|args:$line}}
{{/load}}
@ -47,7 +29,74 @@
WHERE !condition
ORDER BY trans.date DESC;
!condition=$condition
assign="immo_archivee"
}}
{{:assign var="immo_archivees.%s"|args:$trans_id value=$immo_archivee}}
{{/select}}
{{* Immobilisation avec une écriture de sortie de bilan *}}
{{:read file="./defaut.json" assign="config_json"}}
{{:assign config_defaut=$config_json|json_decode}}
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
{{:assign condition="("}}
{{#foreach from=$prefix_array item="code"}}
{{:assign code=$code|cat:"%"|quote_sql}}
{{:assign condition=$condition|cat:"account.code LIKE "|cat:$code|cat:" OR "}}
{{/foreach}}
{{:assign condition=$condition|cat:"0)"}}
{{:assign cond2=$condition|replace:"account.":"acc2."}}
{{:assign condition=$condition|cat:" AND "|cat:$cond2}}
{{:assign condition=$condition|cat:" AND line.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,
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
INNER JOIN acc_transactions_lines AS line2 ON line.debit = line2.credit
INNER JOIN acc_transactions AS trans2 ON trans2.id = line2.id_transaction
INNER JOIN acc_accounts AS acc2 ON acc2.id = line2.id_account
LEFT JOIN acc_projects AS project ON line.id_project = project.id
WHERE !condition
ORDER BY trans.date DESC;
!condition=$condition
assign="immo_archivee"
}}
{{if ! $trans_id|key_in:$immo_archivees}}
{{:assign var="immo_archivees.%s"|args:$trans_id value=$immo_archivee}}
{{/if}}
{{/select}}
<section class="immobilisation">
<h2 class="ruler">Immobilisations archivées</h2>
{{:assign nb_immo=0}}
<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>Projet</th>
<th class="actions"></th>
</tr>
</thead>
<tbody>
{{#foreach from=$immo_archivees}}
{{: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 nb_immo="%d+1"|math:$nb_immo}}
@ -62,7 +111,7 @@
<td class="actions">
</td>
</tr>
{{/select}}
{{/foreach}}
</tbody>
</table>
{{if $nb_immo == 0}}