2024-10-28 09:53:29 +01:00
|
|
|
{{* -*- brindille -*- *}}
|
|
|
|
|
2023-11-20 11:18:50 +01:00
|
|
|
{{*
|
2023-12-06 09:59:11 +01:00
|
|
|
Calcul des entrées/sorties de matériels à une date donnée
|
|
|
|
paramètres :
|
2024-10-29 15:19:04 +01:00
|
|
|
- category_keys : liste de clés de catégories
|
|
|
|
- date : date supérieure des mouvements
|
|
|
|
résultat : cumul_mvt,category_keys,equipments
|
2023-11-20 11:18:50 +01:00
|
|
|
*}}
|
|
|
|
|
|
|
|
{{* liste des catégories *}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{if $category_keys === null}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{#load type="category"}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{:assign var="cumul_mvt.%s.name"|args:$key value=$name}}
|
|
|
|
{{/load}}
|
|
|
|
{{else}}
|
|
|
|
{{#load type="category" where="key"|sql_where:'IN':$category_keys}}
|
|
|
|
{{:assign var="cumul_mvt.%s.name"|args:$key value=$name}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/load}}
|
2023-11-20 11:18:50 +01:00
|
|
|
{{/if}}
|
|
|
|
|
2023-12-07 17:33:49 +01:00
|
|
|
{{#foreach from=$cumul_mvt key="cat_key" item="elem"}}
|
|
|
|
{{:assign var="in_categories." value="'%s'"|args:$cat_key}}
|
|
|
|
{{/foreach}}
|
2023-11-20 11:18:50 +01:00
|
|
|
|
2023-12-07 17:33:49 +01:00
|
|
|
{{:assign in_categories=$in_categories|implode:","}}
|
|
|
|
{{:assign in_categories="("|cat:$in_categories|cat:")"}}
|
2023-11-20 11:18:50 +01:00
|
|
|
|
2023-12-07 17:33:49 +01:00
|
|
|
{{* liste des matériels dans les catégories passées en paramètre *}}
|
|
|
|
{{#load type="equipment" where="$$.category IN %s"|args:$in_categories}}
|
|
|
|
{{:assign var="equipments.%s.category"|args:$key value=$category}}
|
|
|
|
{{:assign var="equipments.%s.designation"|args:$key value=$designation}}
|
|
|
|
{{:assign var="in_equipments." value="'%s'"|args:$key}}
|
|
|
|
{{/load}}
|
|
|
|
{{:assign in_equipments=$in_equipments|implode:","}}
|
|
|
|
{{:assign in_equipments="("|cat:$in_equipments|cat:")"}}
|
2023-11-20 11:18:50 +01:00
|
|
|
|
2023-12-07 17:33:49 +01:00
|
|
|
{{* récupérer la config des entrées/sorties *}}
|
|
|
|
{{:include file="./_get_config.html" keep="config"}}
|
|
|
|
|
|
|
|
{{* parcourir les mouvements et cumuler les entrées/sorties *}}
|
2024-10-21 11:02:47 +02:00
|
|
|
{{if $date == null}}
|
|
|
|
{{:assign condition="$$.equipment IN %s"|args:$in_equipments}}
|
|
|
|
{{else}}
|
|
|
|
{{:assign condition="$$.equipment IN %s AND $$.date <= '%s'"|args:$in_equipments:$date}}
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{#load type="movement" where="%s"|args:$condition assign="mvt" order="$$.date ASC"}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{* matériel propriété de l'asso en stock *}}
|
|
|
|
{{:assign
|
|
|
|
var="stock"
|
2023-12-07 17:33:49 +01:00
|
|
|
from="equipments.%s.stock"|args:$mvt.equipment}}
|
|
|
|
{{if $stock == null}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:assign stock=0}}
|
|
|
|
{{/if}}
|
2023-11-20 11:18:50 +01:00
|
|
|
|
2023-12-06 09:59:11 +01:00
|
|
|
{{* matériel propriété de l'asso à l'extérieur *}}
|
|
|
|
{{:assign
|
|
|
|
var="exterieur"
|
2023-12-07 17:33:49 +01:00
|
|
|
from="equipments.%s.exterieur"|args:$mvt.equipment}}
|
|
|
|
{{if $exterieur == null}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:assign exterieur=0}}
|
|
|
|
{{/if}}
|
2023-11-20 11:18:50 +01:00
|
|
|
|
2023-12-06 09:59:11 +01:00
|
|
|
{{* matériel non propriété de l'asso *}}
|
|
|
|
{{:assign
|
|
|
|
var="nonproprio"
|
2023-12-07 17:33:49 +01:00
|
|
|
from="equipments.%s.nonproprio"|args:$mvt.equipment}}
|
|
|
|
{{if $nonproprio == null}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:assign nonproprio=0}}
|
|
|
|
{{/if}}
|
2023-11-20 11:18:50 +01:00
|
|
|
|
2023-12-07 17:33:49 +01:00
|
|
|
{{* déterminer le type de mouvement *}}
|
|
|
|
{{:assign var="mvt_nature" from="mvt.%s_nature"|args:$mvt.direction}}
|
|
|
|
{{:assign var="type_mvt" from="config.%s_nature.%s"|args:$mvt.direction:$mvt_nature}}
|
2023-11-30 18:14:46 +01:00
|
|
|
|
2023-12-07 17:33:49 +01:00
|
|
|
{{if $mvt.direction === 'input'}}
|
|
|
|
{{if $type_mvt == 'définitif'}}
|
|
|
|
{{:assign stock="%d+%d"|math:$stock:$mvt.amount}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.stock"|args:$mvt.equipment
|
|
|
|
from=stock}}
|
|
|
|
{{elseif $type_mvt == 'retour'}}
|
|
|
|
{{:assign exterieur="%d-%d"|math:$exterieur:$mvt.amount}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.exterieur"|args:$mvt.equipment
|
|
|
|
from=exterieur}}
|
|
|
|
{{elseif $type_mvt == 'temporaire'}}
|
|
|
|
{{:assign nonproprio="%d+%d"|math:$nonproprio:$mvt.amount}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.nonproprio"|args:$mvt.equipment
|
|
|
|
from=nonproprio}}
|
|
|
|
{{/if}}
|
|
|
|
{{elseif $mvt.direction === 'output'}}
|
|
|
|
{{if $type_mvt == 'définitif'}}
|
|
|
|
{{:assign stock="%d-%d"|math:$stock:$mvt.amount}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.stock"|args:$mvt.equipment
|
|
|
|
from=stock}}
|
|
|
|
{{elseif $type_mvt == 'temporaire'}}
|
|
|
|
{{:assign exterieur="%d+%d"|math:$exterieur:$mvt.amount}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.exterieur"|args:$mvt.equipment
|
|
|
|
from=exterieur}}
|
|
|
|
{{elseif $type_mvt == 'retour'}}
|
|
|
|
{{:assign nonproprio="%d-%d"|math:$nonproprio:$mvt.amount}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.nonproprio"|args:$mvt.equipment
|
|
|
|
from=nonproprio}}
|
|
|
|
{{/if}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
2023-12-07 17:33:49 +01:00
|
|
|
|
|
|
|
{{/load}}
|
|
|
|
|
|
|
|
{{* grouper les résultats par catégorie *}}
|
|
|
|
{{#foreach from=$equipments key="eqpmt_key" item="eqpmt"}}
|
|
|
|
{{:assign
|
|
|
|
var="cumul_mvt.%s.eqpmt.%s"|args:$eqpmt.category:$eqpmt_key
|
|
|
|
value=$eqpmt}}
|
|
|
|
{{/foreach}}
|