Supprimer les documents sans écriture associée

This commit is contained in:
Jean-Christophe Engel 2026-06-11 09:44:45 +02:00
parent 6495737428
commit 65112720ba
2 changed files with 31 additions and 16 deletions

28
_remove_orphan_docs.tpl Normal file
View file

@ -0,0 +1,28 @@
{{* -*- brindille -*- *}}
{{* supprimer les documents sans écriture associée *}}
{{:assign var="docs." type="amort_link" field="amort_line_id"}}
{{:assign var="docs." type="credit_link" field="credit_line_id"}}
{{:assign var="docs." type="cession_link" field="cession_line_id"}}
{{:assign var="docs." type="exit_link" field="exit_line_id"}}
{{:assign var="docs." type="immo" field="line"}}
{{#foreach from=$docs}}
{{:assign join_field="$$."|cat:$field}}
{{:assign type_name=$type|quote_sql}}
{{:assign type_cond="$$.type"|cat:" = "|cat:$type_name}}
{{#select
info.id
FROM !table AS info
LEFT JOIN acc_transactions_lines as line ON !join_field = line.id
WHERE !type_cond AND line.id IS NULL
;
!table=$module.table
!type_cond = $type_cond
!join_field = $join_field
}}
{{:delete id=$id}}
{{/select}}
{{/foreach}}

View file

@ -19,7 +19,7 @@
{{:admin_header title="Immobilisations en cours de constitution" custom_css="./style.css" current="module_amortization" subcurrent="unfinished"}} {{:admin_header title="Immobilisations en cours de constitution" custom_css="./style.css" current="module_amortization" subcurrent="unfinished"}}
{{/if}} {{/if}}
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$type_immo}} {{:include file="_nav.html" current="index" subcurrent=$type_immo}}
{{if $_GET.ok}} {{if $_GET.ok}}
{{if $_GET.msg|match:"immobilisation"}} {{if $_GET.msg|match:"immobilisation"}}
@ -34,21 +34,8 @@
<p class="block error">Échec enregistrement immobilisation</p> <p class="block error">Échec enregistrement immobilisation</p>
{{/if}} {{/if}}
{{#load type="immo"}} {{* supprimer les documents sans écriture associée *}}
{{* supprimer les documents sans écriture associée *}} {{:include file="_remove_orphan_docs.tpl"}}
{{#select
line.id as line_id
FROM acc_transactions_lines as line
WHERE line.id = :line_id;
:line_id = $line
}}
{{else}}
{{:delete key=$key}}
{{/select}}
{{/load}}
{{* chercher des immos antérieures à la date de début du 1er exercice *}}
{{*:include file="_old_assets.html"*}}
{{if $type_immo == "other"}} {{if $type_immo == "other"}}
{{:include file="_immobilisations_autres.html"}} {{:include file="_immobilisations_autres.html"}}