Compare commits

...

2 commits

Author SHA1 Message Date
Jean-Christophe Engel
4b504f6eb9 Configuration : traitement cas particuliers exercices 2025-11-03 14:11:39 +01:00
Jean-Christophe Engel
ab8f695e31 Immobilisations archivées : simplification et affichage date sortie 2025-11-03 14:11:24 +01:00
3 changed files with 94 additions and 114 deletions

View file

@ -2,38 +2,6 @@
{{* Liste des immobilisations archivées *}} {{* Liste des immobilisations archivées *}}
{{* Immobilisation archivées prises en charge *}}
{{#load type="immo" where="$$.status = 'archived'"}}
{{:assign var="lines." value="'%s'"|args:$line}}
{{/load}}
{{:assign lines=$lines|implode:","}}
{{:assign lines="("|cat:$lines|cat:")"}}
{{:assign condition="line.id IN %s"|args:$lines}}
{{#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="immo_archivee"
}}
{{:assign var="immo_archivees.%s"|args:$trans_id value=$immo_archivee}}
{{/select}}
{{* Immobilisation avec une écriture de sortie de bilan *}} {{* Immobilisation avec une écriture de sortie de bilan *}}
{{:read file="./defaut.json" assign="config_json"}} {{:read file="./defaut.json" assign="config_json"}}
{{:assign config_defaut=$config_json|json_decode}} {{:assign config_defaut=$config_json|json_decode}}
@ -44,9 +12,7 @@
{{:assign condition=$condition|cat:"account.code LIKE "|cat:$code|cat:" OR "}} {{:assign condition=$condition|cat:"account.code LIKE "|cat:$code|cat:" OR "}}
{{/foreach}} {{/foreach}}
{{:assign condition=$condition|cat:"0)"}} {{:assign condition=$condition|cat:"0)"}}
{{:assign cond2=$condition|replace:"account.":"acc2."}} {{:assign condition=$condition|cat:" AND acc2.code = account.code AND line.debit > 0 AND line.debit = line2.credit AND NOT (trans.status & 16)"}}
{{:assign condition=$condition|cat:" AND "|cat:$cond2}}
{{:assign condition=$condition|cat:" AND line.debit > 0 AND NOT (trans.status & 16)"}}
{{#select {{#select
trans.id as trans_id, trans.id as trans_id,
@ -58,7 +24,8 @@
account.label as account_label, account.label as account_label,
line.debit AS debit, line.debit AS debit,
project.label as project_label, project.label as project_label,
trans.id_year as trans_id_year trans.id_year as trans_id_year,
trans2.date as exit_date
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
@ -72,9 +39,7 @@
!condition=$condition !condition=$condition
assign="immo_archivee" assign="immo_archivee"
}} }}
{{if ! $trans_id|key_in:$immo_archivees}}
{{:assign var="immo_archivees.%s"|args:$trans_id value=$immo_archivee}} {{:assign var="immo_archivees.%s"|args:$trans_id value=$immo_archivee}}
{{/if}}
{{/select}} {{/select}}
<section class="immobilisation"> <section class="immobilisation">
@ -83,7 +48,8 @@
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
<th>Date</th> <th>Mise en service</th>
<th>Date sortie</th>
<th>Libellé</th> <th>Libellé</th>
<th class="nombre">Montant</th> <th class="nombre">Montant</th>
<th>N° compte</th> <th>N° compte</th>
@ -100,6 +66,7 @@
<tr> <tr>
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td> <td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
<td>{{$trans_date|date_short}}</td> <td>{{$trans_date|date_short}}</td>
<td>{{$exit_date|date_short}}</td>
<td>{{$trans_label}}</td> <td>{{$trans_label}}</td>
<td class="money">{{"%f"|math:$debit|money:false}}</td> <td class="money">{{"%f"|math:$debit|money:false}}</td>
<td><a href={{$compte_url}}>{{$account_code}}</a></td> <td><a href={{$compte_url}}>{{$account_code}}</a></td>

View file

@ -13,6 +13,8 @@
{{if $ts_debut <= $now && $now <= $ts_fin}} {{if $ts_debut <= $now && $now <= $ts_fin}}
{{:assign selected_year=$id}} {{:assign selected_year=$id}}
{{/if}} {{/if}}
{{else}}
{{:error message="Aucun exercice ouvert"}}
{{/years}} {{/years}}
{{* Traiter l'envoi du formulaire *}} {{* Traiter l'envoi du formulaire *}}

View file

@ -3,6 +3,7 @@
{{:admin_header title="Configuration" custom_css="./style.css" current="module_amortissement"}} {{:admin_header title="Configuration" custom_css="./style.css" current="module_amortissement"}}
{{* barre de navigation *}} {{* barre de navigation *}}
{{:include file="_nav.html" current="config"}} {{:include file="_nav.html" current="config"}}
{{if $_GET.ok == 1}} {{if $_GET.ok == 1}}
<p class="block confirm">Configuration enregistrée.</p> <p class="block confirm">Configuration enregistrée.</p>
{{/if}} {{/if}}
@ -39,19 +40,29 @@
{{:redirect to="./config.html?ok=%d"|args:$ok}} {{:redirect to="./config.html?ok=%d"|args:$ok}}
{{/form}} {{/form}}
{{* récupérer l'exercice courant *}} {{* récupérer l'exercice courant ou sinon le plus récent *}}
{{:assign var="selected_year" from="logged_user.preferences.accounting_year}} {{:assign var="selected_year" from="logged_user.preferences.accounting_year}}
{{if $selected_year == null}} {{if $selected_year == null}}
{{* sélectionner l'exercice le plus probable *}} {{* sélectionner l'exercice le plus probable *}}
{{#years closed=false order="start_date"}} {{#years}}
{{:assign var="open_years.%d"|args:$id value=$label}}
{{if $start_date|strtotime <= $now && $end_date|strtotime >= $now}} {{if $start_date|strtotime <= $now && $end_date|strtotime >= $now}}
{{:assign selected_year=$id}} {{:assign selected_year=$id}}
{{:break}} {{:break}}
{{/if}} {{/if}}
{{:assign last_year=$id}}
{{/years}} {{/years}}
{{/if}} {{/if}}
{{if $selected_year == null}}
{{if $last_year == null}}
<p class="block alert">Aucun exercice</p>
{{else}}
{{:assign selected_year=$last_year}}
{{/if}}
{{/if}}
{{if $selected_year != null}}
{{* libellés des comptes d'immobilisation *}} {{* libellés des comptes d'immobilisation *}}
{{:assign condition="("}} {{:assign condition="("}}
{{#foreach from=$config.prefixes item="code"}} {{#foreach from=$config.prefixes item="code"}}
@ -98,7 +109,6 @@
<td> <td>
{{:assign var="immo_account.%s.%s"|args:$code:$code value="%s — "|args:$code|cat:$elem.label}} {{:assign var="immo_account.%s.%s"|args:$code:$code value="%s — "|args:$code|cat:$elem.label}}
{{:assign var="current_account" from="immo_account.%s"|args:$code}} {{:assign var="current_account" from="immo_account.%s"|args:$code}}
{{*:debug immo_account=$immo_account current_account=$current_account*}}
{{:input {{:input
type="list" type="list"
name="immo_accounts[]" name="immo_accounts[]"
@ -130,6 +140,7 @@
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}} {{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
</p> </p>
</form> </form>
{{/if}}
<script type="text/javascript" src="scripts.js"></script> <script type="text/javascript" src="scripts.js"></script>
<script type="text/javascript"> <script type="text/javascript">