Fix: calcul coût formation quand données manquantes

This commit is contained in:
Emmanuel Viennet 2023-03-16 11:54:14 +01:00
parent c88b6b7759
commit 67058fc25c

View File

@ -34,8 +34,6 @@ from flask import request
from app.models import FormSemestre from app.models import FormSemestre
from app.scodoc.gen_tables import GenTable from app.scodoc.gen_tables import GenTable
from app.scodoc import sco_formsemestre
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_preferences from app.scodoc import sco_preferences
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
import sco_version import sco_version
@ -65,16 +63,18 @@ def formsemestre_table_estim_cost(
{ {
"code": modimpl.module.code or "", "code": modimpl.module.code or "",
"titre": modimpl.module.titre, "titre": modimpl.module.titre,
"heures_cours": modimpl.module.heures_cours, "heures_cours": modimpl.module.heures_cours or 0.0,
"heures_td": modimpl.module.heures_td * n_group_td, "heures_td": (modimpl.module.heures_td or 0.0) * n_group_td,
"heures_tp": modimpl.module.heures_tp * n_group_tp, "heures_tp": (modimpl.module.heures_tp or 0.0) * n_group_tp,
} }
) )
# calcul des heures: # calcul des heures:
for t in rows: for row in rows:
t["HeqTD"] = ( row["HeqTD"] = (
t["heures_td"] + coef_cours * t["heures_cours"] + coef_tp * t["heures_tp"] row["heures_td"]
+ coef_cours * row["heures_cours"]
+ coef_tp * row["heures_tp"]
) )
sum_cours = sum([t["heures_cours"] for t in rows]) sum_cours = sum([t["heures_cours"] for t in rows])
sum_td = sum([t["heures_td"] for t in rows]) sum_td = sum([t["heures_td"] for t in rows])