Paramétrisation nom table dans les requêtes

This commit is contained in:
Jean-Christophe Engel 2026-01-27 17:17:54 +01:00
parent 1b1680af5c
commit b14463ecf2
6 changed files with 32 additions and 24 deletions

View file

@ -39,7 +39,7 @@
{{:include file="./_get_config.html" keep="config"}}
{{#foreach from=$config.output_nature key="key"}}
{{if $type == 'temporaire'}}
{{if $type == 'temporaire' && $fee != 'payant'}}
{{:assign var="output_types." value=$key|quote_sql}}
{{/if}}
{{/foreach}}
@ -56,11 +56,11 @@
json_extract(mvt.document, '$.amount') AS out_amount,
json_extract(mvt.document, '$.return_date') AS return_date,
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(retour.document, '$.amount')), 0) AS remain
FROM {!$module.table} AS mvt
FROM !table AS mvt
LEFT JOIN users ON json_extract(mvt.document, '$.user') = users.id
LEFT JOIN {!$module.table} AS links ON mvt.key = json_extract(links.document, '$.temp_key')
LEFT JOIN {!$module.table} AS retour ON retour.key = json_extract(links.document, '$.return')
INNER JOIN {!$module.table} AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
LEFT JOIN !table AS links ON mvt.key = json_extract(links.document, '$.temp_key')
LEFT JOIN !table AS retour ON retour.key = json_extract(links.document, '$.return')
INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
WHERE
json_extract(mvt.document, '$.type') = 'movement'
AND
@ -69,6 +69,7 @@
HAVING remain != 0
ORDER BY out_date, nom
;
!table=$module.table
!op = $output_ops
}}
{{if $premier}}