Distinguer matériel de stock nul et matériel non présent
This commit is contained in:
parent
f8e5d43888
commit
c681b47e7f
@ -21,17 +21,17 @@
|
||||
},
|
||||
"stock": {
|
||||
"description": "Quantité en stock",
|
||||
"type" : "integer",
|
||||
"type" : ["integer", "null"],
|
||||
"minimum": 0
|
||||
},
|
||||
"out": {
|
||||
"description": "Quantité sortie temporairement",
|
||||
"type" : "integer",
|
||||
"type" : ["integer", "null"],
|
||||
"minimum": 0
|
||||
},
|
||||
"notowned": {
|
||||
"description": "Quantité présente temporairement",
|
||||
"type" : "integer",
|
||||
"type" : ["integer", "null"],
|
||||
"minimum": 0
|
||||
}
|
||||
},
|
||||
|
@ -48,7 +48,7 @@
|
||||
(SELECT $$.stock - $$.out) AS 'Disponible'
|
||||
"
|
||||
type="equipment"
|
||||
where="$$.status <> 'archived' AND $$.stock != 0 AND %s"|args:$condition
|
||||
where="$$.status <> 'archived' AND $$.stock NOT NULL AND %s"|args:$condition
|
||||
order=1
|
||||
}}
|
||||
{{:assign var=cat_name from=categories.%s|args:$category}}
|
||||
|
@ -71,10 +71,10 @@
|
||||
{{:assign equipment_key=""|uuid}}
|
||||
{{if $type_mvt == 'définitif'}}
|
||||
{{:assign stock=$_POST.amount|intval}}
|
||||
{{:assign notowned=0}}
|
||||
{{:assign notowned=null}}
|
||||
{{elseif $type_mvt == 'temporaire'}}
|
||||
{{:assign notowned=$_POST.amount|intval}}
|
||||
{{:assign stock=0}}
|
||||
{{:assign stock=null}}
|
||||
{{/if}}
|
||||
{{:save
|
||||
key=$equipment_key
|
||||
|
@ -87,6 +87,7 @@
|
||||
- insérer le mvt modifié à sa place par date croissante
|
||||
*}}
|
||||
{{:assign insere=false}}
|
||||
{{:assign entree_def=false}}
|
||||
{{#load
|
||||
where="
|
||||
$$.type = 'movement'
|
||||
@ -172,6 +173,24 @@
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{if $equipment.stock == 0}}
|
||||
{{* vérifier s'il y a au moins une entrée définitive *}}
|
||||
{{#foreach from=$config.input_nature key=key}}
|
||||
{{if $type == 'définitif'}}
|
||||
{{:assign var="input_types." value=$key}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{#foreach from=$movements_new}}
|
||||
{{if $operation|in:$input_types}}
|
||||
{{:assign entree_def=true}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{if ! $entree_def}}
|
||||
{{:assign var="equipment.stock" value=null}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{:save
|
||||
key=$equipment.key
|
||||
validate_schema="../equipment.schema.json"
|
||||
|
@ -12,7 +12,7 @@
|
||||
{{/load}}
|
||||
|
||||
{{* trouver le matériel concerné par ce mouvement *}}
|
||||
{{#load type="equipment" where="key = :key" :key=$mvt_suppr.equipment assign="equipment"}}
|
||||
{{#load type="equipment" where="key = :key" :key=$mvt_suppr.equipment assign="curr_eqpmt"}}
|
||||
{{else}}
|
||||
{{:error message="Aucun matériel avec la clé « %s »"|args:$mvt_suppr.equipment}}
|
||||
{{/load}}
|
||||
@ -66,6 +66,7 @@
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
|
||||
{{* suppression possible *}}
|
||||
{{if $type_operation == 'retour'}}
|
||||
{{#load type="link" where="$$.return = :key" :key=$_GET.key}}
|
||||
@ -98,45 +99,59 @@
|
||||
{{/if}}
|
||||
|
||||
{{* voir s'il reste des mouvements pour le matériel concerné par le mouvement supprimé *}}
|
||||
{{#load type="movement" where="$$.equipment = :eqpmt_key" :eqpmt_key=$equipment.key}}
|
||||
{{:assign mvt_ok=1}}
|
||||
{{#foreach from=$config.input_nature key=key}}
|
||||
{{if $type == 'définitif'}}
|
||||
{{:assign var="input_types." value=$key}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{#load type="movement" where="$$.equipment = :eqpmt_key" :eqpmt_key=$curr_eqpmt.key}}
|
||||
{{:assign mvt_ok=true}}
|
||||
{{if $operation|in:$input_types}}
|
||||
{{:assign entree_def=true}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
|
||||
{{if $mvt_ok}}
|
||||
{{* calculer la nouvelle quantité du matériel *}}
|
||||
{{* calculer et mettre à jour la nouvelle quantité du matériel *}}
|
||||
{{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$mvt_suppr.direction:$mvt_suppr.operation}}
|
||||
{{if $mvt_suppr.direction == 'input'}}
|
||||
{{if $type_mvt == 'définitif'}}
|
||||
{{:assign var="equipment.stock" value="%d-%d"|math:$equipment.stock:$mvt_suppr.amount|intval}}
|
||||
{{:assign var="curr_eqpmt.stock" value="%d-%d"|math:$curr_eqpmt.stock:$mvt_suppr.amount|intval}}
|
||||
{{elseif $type_mvt == 'temporaire'}}
|
||||
{{:assign var="equipment.notowned" value="%d-%d"|math:$equipment.notowned:$mvt_suppr.amount|intval}}
|
||||
{{:assign var="curr_eqpmt.notowned" value="%d-%d"|math:$curr_eqpmt.notowned:$mvt_suppr.amount|intval}}
|
||||
{{elseif $type_mvt == 'retour'}}
|
||||
{{:assign var="equipment.out" value="%d+%d"|math:$equipment.out:$mvt_suppr.amount|intval}}
|
||||
{{:assign var="curr_eqpmt.out" value="%d+%d"|math:$curr_eqpmt.out:$mvt_suppr.amount|intval}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{if $type_mvt == 'définitif'}}
|
||||
{{:assign var="equipment.stock" value="%d+%d"|math:$equipment.stock:$mvt_suppr.amount|intval}}
|
||||
{{:assign var="curr_eqpmt.stock" value="%d+%d"|math:$curr_eqpmt.stock:$mvt_suppr.amount|intval}}
|
||||
{{elseif $type_mvt == 'temporaire'}}
|
||||
{{:assign var="equipment.out" value="%d-%d"|math:$equipment.out:$mvt_suppr.amount|intval}}
|
||||
{{:assign var="curr_eqpmt.out" value="%d-%d"|math:$curr_eqpmt.out:$mvt_suppr.amount|intval}}
|
||||
{{elseif $type_mvt == 'retour'}}
|
||||
{{:assign var="equipment.notowned" value="%d+%d"|math:$equipment.notowned:$mvt_suppr.amount|intval}}
|
||||
{{:assign var="curr_eqpmt.notowned" value="%d+%d"|math:$curr_eqpmt.notowned:$mvt_suppr.amount|intval}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{if $curr_eqpmt.stock == 0 && ! $entree_def}}
|
||||
{{:assign var="curr_eqpmt.stock" value=null}}
|
||||
{{/if}}
|
||||
|
||||
{{:save
|
||||
key=$equipment.key
|
||||
key=$curr_eqpmt.key
|
||||
validate_schema="../equipment.schema.json"
|
||||
type="equipment"
|
||||
category=$equipment.category
|
||||
name=$equipment.name
|
||||
category=$curr_eqpmt.category
|
||||
name=$curr_eqpmt.name
|
||||
status="available"
|
||||
stock=$equipment.stock
|
||||
out=$equipment.out
|
||||
notowned=$equipment.notowned
|
||||
stock=$curr_eqpmt.stock
|
||||
out=$curr_eqpmt.out
|
||||
notowned=$curr_eqpmt.notowned
|
||||
}}
|
||||
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{else}}
|
||||
{{* supprimer le matériel *}}
|
||||
{{:delete key=$equipment.key}}
|
||||
{{:delete key=$curr_eqpmt.key}}
|
||||
{{:redirect force="../index.html?ok=1&msg=supprmvtmat"}}
|
||||
{{/if}}
|
||||
{{/form}}
|
||||
@ -149,7 +164,7 @@
|
||||
|
||||
{{:delete_form
|
||||
legend="Supprimer ?"
|
||||
warning="Supprimer le mouvement « %s de %s (quantité : %d) en date du %s » ?"|args:$mvt_label:$equipment.name:$mvt_suppr.amount:$date_suppr
|
||||
warning="Supprimer le mouvement « %s de %s (quantité : %d) en date du %s » ?"|args:$mvt_label:$curr_eqpmt.name:$mvt_suppr.amount:$date_suppr
|
||||
}}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user