From 65112720ba200828cd78329cb514964b8c63b08b Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Thu, 11 Jun 2026 09:44:45 +0200 Subject: [PATCH] =?UTF-8?q?Supprimer=20les=20documents=20sans=20=C3=A9crit?= =?UTF-8?q?ure=20associ=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _remove_orphan_docs.tpl | 28 ++++++++++++++++++++++++++++ index.html | 19 +++---------------- 2 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 _remove_orphan_docs.tpl diff --git a/_remove_orphan_docs.tpl b/_remove_orphan_docs.tpl new file mode 100644 index 0000000..4799e33 --- /dev/null +++ b/_remove_orphan_docs.tpl @@ -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}} diff --git a/index.html b/index.html index 234de28..5007c48 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@ {{:admin_header title="Immobilisations en cours de constitution" custom_css="./style.css" current="module_amortization" subcurrent="unfinished"}} {{/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.msg|match:"immobilisation"}} @@ -34,21 +34,8 @@

Échec enregistrement immobilisation

{{/if}} -{{#load type="immo"}} - {{* supprimer les documents sans écriture associée *}} - {{#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"*}} +{{* supprimer les documents sans écriture associée *}} +{{:include file="_remove_orphan_docs.tpl"}} {{if $type_immo == "other"}} {{:include file="_immobilisations_autres.html"}}