Enregistrement initial

This commit is contained in:
Jean-Christophe Engel 2025-10-27 21:20:12 +01:00
commit 6581b4afb7
5 changed files with 223 additions and 0 deletions

8
_nav.html Normal file
View file

@ -0,0 +1,8 @@
{{* -*- brindille -*- *}}
<nav class="tabs">
<ul>
<li {{if $current == 'conversion'}} class="current"{{/if}}><a href="{{$module.url}}convert.html">Conversion poids - volume</a></li>
<li {{if $current == 'prix_vente'}} class="current"{{/if}}><a href="{{$module.url}}prix_vente.html">Prix de vente</a></li>
</ul>
</nav>

102
convert.html Normal file
View file

@ -0,0 +1,102 @@
{{* -*- brindille -*- *}}
{{:admin_header title="Conversion poids - volume" custom_css="./style.css" current="module_epicier"}}
{{:include file="./_nav.html" current="conversion"}}
{{:assign var="noms." value="vinaigre"}}
{{:assign var="coefficients." value=1.01}}
{{:assign var="noms." value="huile"}}
{{:assign var="coefficients." value=0.92}}
{{:assign var="noms." value="lait"}}
{{:assign var="coefficients." value=1.03}}
{{:assign var="noms." value="alcool"}}
{{:assign var="coefficients." value=0.78}}
{{:assign ind=0}}
{{#foreach from=$noms key="key" item="elem"}}
{{:assign var="produit.name" value=$elem}}
{{:assign var="produit.coeff" from="coefficients.%d"|args:$ind}}
{{:assign var="liste_produits." value=$produit}}
{{:assign var="produits.%s"|args:$ind value=$elem}}
{{:assign ind="%d+1"|math:$ind}}
{{/foreach}}
<form method="post" action="">
<fieldset class="saisie">
<legend>Saisie</legend>
<dl>
{{:input type="select" name="produit" label="Produit" required=true default_empty="— Choisir —" options=$produits|sort}}
{{:input type="text" pattern="[0-9]+\.[0-9]+" name="poids" label="Poids en kg" required=true title="Saisir le poids en kg" size="10"}}
{{:input type="text" name="coeff" label="Coefficient" required=false readonly=true size="10"}}
{{:input type="text" name="volume" label="Volume en litres" required=false readonly=true size="10"}}
<div id="donnees" class="hidden">
{{:input type="select" name="coefficients" options=$coefficients}}
</div>
</dl>
</fieldset>
</form>
<script type="text/javascript">
// effacer le contenu de divers champs
function raz(field_list)
{
for (const elem of field_list) {
document.getElementById(elem).value = '';
}
}
function modifProduit(evt,
id_produit = 'f_produit',
id_poids = 'f_poids',
id_coeff = 'f_coeff',
id_volume = 'f_volume',
id_liste_coeff = 'f_coefficients'
)
{
const selected_prod = document.getElementById(id_produit);
const ind_sel = selected_prod.selectedIndex;
if (ind_sel > 0) {
const ind_coeff = parseInt(selected_prod.options[ind_sel].value) + 1;
const sel_coeff = document.getElementById(id_liste_coeff);
const coefficient = sel_coeff.options[ind_coeff].label;
// Afficher le coefficient
document.getElementById(id_coeff).value = coefficient;
const val_poids = document.getElementById(id_poids).value;
if (val_poids != '') {
computeVolume(evt, id_produit, id_poids, id_coeff, id_volume);
} else {
document.getElementById(id_poids).focus();
}
} else {
raz([id_poids, id_coeff, id_volume]);
}
}
function computeVolume(evt,
id_produit = 'f_produit',
id_poids = 'f_poids',
id_coeff = 'f_coeff',
id_volume = 'f_volume'
)
{
const val_coeff = document.getElementById(id_coeff).value;
if (val_coeff != '') {
const coeff = parseFloat(val_coeff);
const poids = parseFloat(document.getElementById(id_poids).value);
const volume = poids * coeff;
document.getElementById(id_volume).value = volume.toFixed(2);
} else {
document.getElementById(id_produit).focus();
}
}
(function () {
document.getElementById('f_produit').onchange = modifProduit;
document.getElementById('f_poids').onchange = computeVolume;
})();
</script>

6
index.html Normal file
View file

@ -0,0 +1,6 @@
{{* -*- brindille -*- *}}
{{:admin_header title="Outils pour l'épicier" custom_css="./style.css" current="module_epicier"}}
{{:include file="_nav.html" current="index"}}

7
module.ini Normal file
View file

@ -0,0 +1,7 @@
name="Outils pour l'épicier"
author="Jean-Christophe Engel"
author_url="https://gitea.zaclys.com/lesanges"
home_button=false
menu=true
restrict_section="accounting"
restrict_level="write"

100
prix_vente.html Normal file
View file

@ -0,0 +1,100 @@
{{* -*- brindille -*- *}}
{{:admin_header title="Calcul prix de vente" custom_css="./style.css" current="module_epicier"}}
{{:include file="./_nav.html" current="prix_vente"}}
{{:assign var="taux_tva." value="0.021"}}
{{:assign var="taux_tva." value="0.055"}}
{{:assign var="taux_tva." value="0.1"}}
{{:assign var="taux_tva." value="0.2"}}
{{:assign ind=0}}
{{#foreach from=$taux_tva item="taux"}}
{{:assign taux="%f*100"|math:$taux}}
{{:assign var="options.%s"|args:$ind value=$taux|cat:"%"}}
{{:assign ind="%d+1"|math:$ind}}
{{/foreach}}
<form method="post" action="" data-focus="1">
<fieldset class="saisie">
<legend>Saisie</legend>
<dl>
{{:input type="text" pattern="[0-9]+\.[0-9]+" name="prix_ht" label="Prix HT" required=true title="Saisir un nombre décimal ; ex : 1.78" size="10"}}
{{:input type="select" name="taux_tva" label="Taux TVA" required=true default_empty="— Choisir —" options=$options}}
{{:input type="text" pattern="[0-9]+\.[0-9]+" name="prix_ttc" label="Prix TTC" required=false size="10" readonly=true}}
{{:input type="text" pattern="[0-9]+\.[0-9]+" name="paff" label="Taux PAFF" required=true title="Saisir un nombre décimal ; ex : 3.5" size="10"}}
{{:input type="text" name="prix_vente" label="Prix de vente" required=false size="10" readonly=true}}
</dl>
</fieldset>
</form>
<script type="text/javascript">
function raz(field_list)
{
for (const elem of field_list) {
document.getElementById(elem).value = '';
}
}
function displayPrixTTC(evt,
id_taux_tva = 'f_taux_tva',
id_prix_ht = 'f_prix_ht',
id_prix_ttc = 'f_prix_ttc',
id_paff = 'f_paff',
id_prix_vente = 'f_prix_vente'
)
{
const select_tva = document.getElementById(id_taux_tva);
const ind_tva = select_tva.selectedIndex;
if (ind_tva > 0) {
// taux TVA choisi
const val_tva = parseFloat(select_tva.options[ind_tva].label.replace(/ *%.*/, ""));
const prix_ttc = parseFloat(document.getElementById(id_prix_ht).value) * ( 1 + val_tva / 100.);
document.getElementById(id_prix_ttc).value = prix_ttc.toFixed(2);
const val_paff = document.getElementById(id_paff).value.replace(/ *%.*/, "");
if (val_paff != '') {
computePrixVente(evt, id_taux_tva, id_prix_ht, id_prix_ttc, id_paff, id_prix_vente);
} else {
document.getElementById(id_paff).focus();
}
} else {
// pas de taux de tva choisi
raz([id_prix_ttc, id_prix_vente]);
select_tva.focus();
}
}
function computePrixVente(evt,
id_taux_tva = 'f_taux_tva',
id_prix_ht = 'f_prix_ht',
id_prix_ttc = 'f_prix_ttc',
id_paff = 'f_paff',
id_prix_vente = 'f_prix_vente'
)
{
const val_pht = document.getElementById(id_prix_ht).value;
if (val_pht === "") {
document.getElementById(id_prix_ht).focus();
return;
}
const val_pttc = document.getElementById(id_prix_ttc).value;
if (val_pttc === "") {
document.getElementById(id_taux_tva).focus();
return;
}
const val_paff = document.getElementById(id_paff).value.replace(/ *%.*/, "");
if (val_paff != "") {
const prix_vente = parseFloat(val_pttc) * (1 + parseFloat(val_paff)/100.);
document.getElementById(id_prix_vente).value = prix_vente.toFixed(2);
document.getElementById(id_prix_ht).focus();
}
}
(function () {
document.getElementById('f_prix_ht').onchange = displayPrixTTC;
document.getElementById('f_taux_tva').onchange = displayPrixTTC;
document.getElementById('f_paff').onchange = computePrixVente;
})();
</script>