01/09/2024 - 14:00

master
cherif 2024-09-01 13:59:37 +02:00
parent c5e4a4c57b
commit 5affdf6998
4 changed files with 1060 additions and 25 deletions

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="31082024">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="31/08/2024 - 18h50">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Dashbord_queries/BPF.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/BPF.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -75,13 +75,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00337" summary="22/06/24 - 17h30">
<created>1719069758164</created>
<option name="number" value="00337" />
<option name="presentableId" value="LOCAL-00337" />
<option name="project" value="LOCAL" />
<updated>1719069758165</updated>
</task>
<task id="LOCAL-00338" summary="qsds">
<created>1719094222659</created>
<option name="number" value="00338" />
@ -418,7 +411,14 @@
<option name="project" value="LOCAL" />
<updated>1725106474933</updated>
</task>
<option name="localTasksCounter" value="386" />
<task id="LOCAL-00386" summary="31/08/2024 - 18h50">
<created>1725123044361</created>
<option name="number" value="00386" />
<option name="presentableId" value="LOCAL-00386" />
<option name="project" value="LOCAL" />
<updated>1725123044363</updated>
</task>
<option name="localTasksCounter" value="387" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -460,7 +460,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="01/08/2024 - 17h30" />
<MESSAGE value="02/08/2024 - 12h" />
<MESSAGE value="02/08/2024 - 17h" />
<MESSAGE value="03/08/2024 - 18h30" />
@ -485,6 +484,7 @@
<MESSAGE value="dddqsdddd" />
<MESSAGE value="dddqsddddss" />
<MESSAGE value="31082024" />
<option name="LAST_COMMIT_MESSAGE" value="31082024" />
<MESSAGE value="31/08/2024 - 18h50" />
<option name="LAST_COMMIT_MESSAGE" value="31/08/2024 - 18h50" />
</component>
</project>

View File

@ -147,6 +147,7 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header(diction):
TRAITEMENT DU PAVE CCCC
"""
total_c1_C9 = 0
bpf_c1_entreprise = []
@ -175,6 +176,7 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header(diction):
{'$expr':
{'$and':
[
{'$eq': ["order_line_is_include_bpf", "1"]},
{'$eq': ["$valide", "1"]},
{'$eq': ["$invoice_header_ref_interne",
'$$partner_invoice_line_invoice_header_ref_interne']},
@ -207,6 +209,11 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header(diction):
},
])
print(
" ### C1_pipe_qry_invoice_header_partner__invoice_line_detail__is_client_1_is_financeur_0_is_company_1 = ",
C1_pipe_qry_invoice_header_partner__invoice_line_detail__is_client_1_is_financeur_0_is_company_1)
for retval in MYSY_GV.dbname['partner_invoice_header'].aggregate(
C1_pipe_qry_invoice_header_partner__invoice_line_detail__is_client_1_is_financeur_0_is_company_1):
print(" ### retval bpf_c1_entreprise = ", retval)
@ -253,6 +260,7 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header(diction):
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$order_line_is_include_bpf", "1"]},
{'$eq': ["$invoice_header_ref_interne",
'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},
@ -400,6 +408,7 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header(diction):
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$order_line_is_include_bpf", "1"]},
{'$eq': ["$invoice_header_ref_interne",
'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},
@ -517,6 +526,7 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header(diction):
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$order_line_is_include_bpf", "1"]},
{'$eq': ["$invoice_header_ref_interne",
'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},
@ -769,14 +779,23 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header(diction):
RetObject['bpf_e2_nb_formateurs_externes'] = str(len(tab_formateur_rh_id_sous_traitant))
RetObject['bpf_e2_nb_heures_formateurs_externes'] = tab_formateur_rh_sous_traitant_total_heure
F1_qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])}, {"valide": '1', 'status':'1'},
"""
FIN TRAITEMENT DU PAVE EEEE
"""
"""
TRAITEMENT DU PAVE FFFF
"""
F3_qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])}, {"valide": '1', 'status':'1'},
]}
F1_pipe_qry_stagiaire_par_class_level = ([
F3_pipe_qry_stagiaire_par_class_level = ([
{'$project': {'_id': 1, 'email': 1, 'session_id': 1, 'nom': 1, 'prenom': 1, 'partner_owner_recid': 1,
'valide': 1, 'type_apprenant': 1, 'status':1}},
{'$match': F1_qery_match},
{'$match': F3_qery_match},
{'$lookup': {
'from': 'session_formation',
'let': {'session_id': "$session_id", 'partner_owner_recid': '$partner_owner_recid'},
@ -887,10 +906,10 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header(diction):
])
print(" ### F1_pipe_qry_stagiaire_par_class_level = ", F1_pipe_qry_stagiaire_par_class_level)
print(" ### F3_pipe_qry_stagiaire_par_class_level = ", F3_pipe_qry_stagiaire_par_class_level)
bpf_f_class_niveau_formation = []
total_bpf_f_class_niveau_formation = 0
bpf_f3_class_niveau_formation = []
total_bpf_f3_class_niveau_formation = 0
"""
Recuperer la configuration de conversion des semaines, mois, années en nombre d'heures
@ -898,7 +917,7 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header(diction):
local_conversion_heure_status, local_nb_heure_par_jour, local_nb_heure_par_sem, local_nb_heure_par_mois, local_nb_heure_par_annee = mycommon.Get_Config_Conversion_Heures(str(my_partner['recid']))
for retval in MYSY_GV.dbname['inscription'].aggregate(F1_pipe_qry_stagiaire_par_class_level):
for retval in MYSY_GV.dbname['inscription'].aggregate(F3_pipe_qry_stagiaire_par_class_level):
#print(" ### retval = ", retval)
node = {}
@ -912,7 +931,7 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header(diction):
{'$project': {'_id': 1, 'email': 1, 'session_id': 1, 'nom': 1, 'prenom': 1, 'partner_owner_recid': 1,
'valide': 1, 'type_apprenant': 1, 'status':1}},
{'$match': F1_qery_match},
{'$match': F3_qery_match},
{'$lookup': {
'from': 'session_formation',
'let': {'session_id': "$session_id", 'partner_owner_recid': '$partner_owner_recid'},
@ -1041,11 +1060,183 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header(diction):
total_bpf_f_class_niveau_formation = total_bpf_f_class_niveau_formation + mycommon.tryFloat(retval['count'])
bpf_f_class_niveau_formation.append(node)
total_bpf_f3_class_niveau_formation = total_bpf_f3_class_niveau_formation + mycommon.tryFloat(retval['count'])
bpf_f3_class_niveau_formation.append(node)
RetObject['bpf_f3_class_niveau_formation'] = bpf_f3_class_niveau_formation
RetObject['total_bpf_f3_class_niveau_formation'] = round(total_bpf_f3_class_niveau_formation, 2)
""""
F1 Les différents types de stagiaires au sein de votre organisme
"""
"""
Recuperation des types d'apprenant
"""
bpf_f1_type_apprenant = []
nb_personne_a_distance = 0
nb_personne = 0
nb_heure_formation = 0
for type_apprenant_data in MYSY_GV.dbname['type_apprenant'].find({'valide':'1', 'locked':'0'}):
F1_qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])}, {"valide": '1', 'status': '1',
'type_apprenant':str(type_apprenant_data['code'])},
]}
F1_pipe_qry_stagiaire_type = ([
{'$project': {'_id': 1, 'email': 1, 'session_id': 1, 'nom': 1, 'prenom': 1, 'partner_owner_recid': 1,
'valide': 1, 'type_apprenant': 1, 'status': 1, }},
{'$match': F1_qery_match},
{'$lookup': {
'from': 'session_formation',
'let': {'session_id': "$session_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{
"$addFields": {
"mysy_date_debut_session": {
"$dateFromString": {
"dateString": "$date_debut",
"format": "%d/%m/%Y"
}
}
}
},
{'$project': {'_id': 1, 'code_session': 1, 'class_internal_url': 1, 'date_debut': 1, 'date_fin': 1,
'nb_participant': 1, 'partner_owner_recid': 1, 'valide': 1,
'mysy_date_debut_session': 1, 'distantiel':1}},
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$_id", {'$convert': {
'input': "$$session_id",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$valide", "1"]},
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']},
{'$gte': [{'$toDate': "$mysy_date_debut_session"},
filt_periode_start_date_ISODATE]},
{'$lt': [{'$toDate': "$mysy_date_debut_session"}, filt_periode_end_date_ISODATE]},
]
}
}
},
],
'as': 'session_formation_collection'
}
},
{
'$unwind': '$session_formation_collection'
},
{
"$lookup": {
'from': 'myclass',
'localField': 'session_formation_collection.class_internal_url',
'foreignField': 'internal_url',
"pipeline": [
{'$project': {'title': 1, 'internal_url': 1, 'external_code': 1, 'published': 1,
'duration': 1, 'duration_unit': 1, 'class_level': 1, 'partner_owner_recid': 1}},
{'$match': {'partner_owner_recid': str(my_partner['recid'])}},
],
"as": "myclass_collection"
}
},
{
'$unwind': '$myclass_collection'
},
{
"$group": {
"_id": {
"class_id": "$myclass_collection._id",
"class_external_code": "$myclass_collection.external_code",
"class_duration": "$myclass_collection.duration",
"class_duration_unit": "$myclass_collection.duration_unit",
"session_distance": "$session_formation_collection.distantiel"
},
"count": {
"$sum": 1
}
}
},
])
print(" ### F1_pipe_qry_stagiaire_type pour : "+str(type_apprenant_data['description'])+" = ", F1_pipe_qry_stagiaire_type)
total_bpf_f1_type_apprenant = 0
total_bpf_f1_nb_heure_formation = 0
node = {}
node['Type_Apprenant'] = str(type_apprenant_data['code'])
node['Type_Apprenant_Desc'] = str(type_apprenant_data['description'])
local_f1_nb_distance = 0
for f1_local_retval in MYSY_GV.dbname['inscription'].aggregate(F1_pipe_qry_stagiaire_type):
#print(" ### retval F1_pipe_qry_stagiaire_type = ", f1_local_retval)
total_bpf_f1_type_apprenant = total_bpf_f1_type_apprenant + mycommon.tryFloat( f1_local_retval['count'])
nb_personne = nb_personne + + mycommon.tryFloat( f1_local_retval['count'])
if( str(f1_local_retval['_id']['session_distance']) == "1"):
nb_personne_a_distance = nb_personne_a_distance + mycommon.tryFloat( f1_local_retval['count'])
local_f1_nb_distance = local_f1_nb_distance + mycommon.tryFloat( f1_local_retval['count'])
print(" ### nb_personne_a_distance= ", str(nb_personne_a_distance))
print(" ### local_f1_nb_distance= ", str(local_f1_nb_distance))
"""
traitement du nombre d'heure de formation
"""
local_duration = mycommon.tryFloat(str(f1_local_retval['_id']['class_duration']))
local_duration_unit = str(f1_local_retval['_id']['class_duration_unit'])
if (str(local_duration_unit) == "heure"):
total_bpf_f1_nb_heure_formation = total_bpf_f1_nb_heure_formation + local_duration
elif (str(local_duration_unit) == "jour"):
total_bpf_f1_nb_heure_formation = total_bpf_f1_nb_heure_formation + (
local_duration * local_nb_heure_par_jour)
elif (str(local_duration_unit) == "semaine"):
total_bpf_f1_nb_heure_formation = total_bpf_f1_nb_heure_formation + (
local_duration * local_nb_heure_par_sem)
elif (str(local_duration_unit) == "mois"):
total_bpf_f1_nb_heure_formation = total_bpf_f1_nb_heure_formation + (
local_duration * local_nb_heure_par_mois)
elif (str(local_duration_unit) == "annee"):
total_bpf_f1_nb_heure_formation = total_bpf_f1_nb_heure_formation + (
local_duration * local_nb_heure_par_annee)
node['total_bpf_f1_type_apprenant'] = str(total_bpf_f1_type_apprenant)
node['total_bpf_f1_type_apprenant_distance'] = str(local_f1_nb_distance)
node['total_bpf_f1_nb_heure_formation'] = str(total_bpf_f1_nb_heure_formation)
nb_heure_formation = nb_heure_formation + mycommon.tryFloat( total_bpf_f1_nb_heure_formation)
bpf_f1_type_apprenant.append(node)
RetObject['total_f1_apprenant_a_distance'] = str(nb_personne_a_distance)
RetObject['total_f1_apprenant'] = str(nb_personne)
RetObject['total_f1_nb_heure'] = str(nb_heure_formation)
RetObject['bpf_f1_type_apprenant'] = bpf_f1_type_apprenant
RetObject['bpf_f_class_niveau_formation'] = bpf_f_class_niveau_formation
RetObject['total_bpf_f_class_niveau_formation'] = round(total_bpf_f_class_niveau_formation, 2)
print(" ### RetObject BPF = ", RetObject)
@ -1208,6 +1399,7 @@ def Prepare_and_Print_BPF_PDF(diction):
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$order_line_is_include_bpf", "1"]},
{'$eq': ["$invoice_header_ref_interne",
'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},
@ -1282,6 +1474,7 @@ def Prepare_and_Print_BPF_PDF(diction):
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$order_line_is_include_bpf", "1"]},
{'$eq': ["$invoice_header_ref_interne",
'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},
@ -1428,6 +1621,7 @@ def Prepare_and_Print_BPF_PDF(diction):
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$order_line_is_include_bpf", "1"]},
{'$eq': ["$invoice_header_ref_interne",
'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},
@ -1546,6 +1740,7 @@ def Prepare_and_Print_BPF_PDF(diction):
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$order_line_is_include_bpf", "1"]},
{'$eq': ["$invoice_header_ref_interne",
'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},
@ -2451,6 +2646,7 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header_work(diction):
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$order_line_is_include_bpf", "1"]},
{'$eq': ["$invoice_header_ref_interne",'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},
@ -2571,6 +2767,7 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header_work(diction):
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$order_line_is_include_bpf", "1"]},
{'$eq': ["$invoice_header_ref_interne",'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},
@ -2666,6 +2863,7 @@ def Get_Qery_Generate_BPF_From_partner_invoice_header_work(diction):
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$order_line_is_include_bpf", "1"]},
{'$eq': ["$invoice_header_ref_interne",'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},

File diff suppressed because one or more lines are too long

View File

@ -10777,11 +10777,17 @@ def Invoice_Partner_From_Session_By_Inscription_Id( diction):
order_header_is_company = partner_client_id_data['is_company']
partner_invoice_header_data['order_header_is_company'] = order_header_is_company
order_header_type_pouvoir_public_id = ""
if ("type_pouvoir_public_id" in partner_client_id_data.keys()):
order_header_type_pouvoir_public_id = partner_client_id_data['type_pouvoir_public_id']
partner_invoice_header_data['order_header_type_pouvoir_public_id'] = order_header_type_pouvoir_public_id
order_header_is_include_bpf = ""
if ("is_bpf" in session_data.keys()):
order_header_is_include_bpf = partner_client_id_data['is_bpf']
partner_invoice_header_data['order_header_is_include_bpf'] = order_header_is_include_bpf
# Calcul du Totol HT sans reduction
total_ht = 0
prix_session = 0
@ -10897,7 +10903,7 @@ def Invoice_Partner_From_Session_By_Inscription_Id( diction):
list_partner_invoice_line_champ = ['order_line_formation', 'order_line_qty', 'order_line_prix_unitaire', 'order_line_tax', 'order_line_tax_amount', 'order_line_montant_toutes_taxes',
'order_line_montant_hors_taxes', 'order_line_type_reduction', 'order_line_type_valeur', 'order_line_montant_reduction', 'order_header_ref_interne',
'order_line_comment', 'order_header_id', 'valide', 'locked', 'date_update', 'partner_owner_recid', 'invoice_header_ref_interne', 'invoice_line_type',
'invoice_date', 'invoice_header_id']
'invoice_date', 'invoice_header_id', 'order_line_is_include_bpf']
# PreRemplir les champs
@ -10938,6 +10944,12 @@ def Invoice_Partner_From_Session_By_Inscription_Id( diction):
partner_invoice_line_data['locked'] = "0"
partner_invoice_line_data['partner_owner_recid'] = str(my_partner['recid'])
order_line_is_include_bpf = ""
if ("is_bpf" in session_data.keys()):
order_line_is_include_bpf = session_data['is_bpf']
partner_invoice_line_data['order_line_is_include_bpf'] = order_line_is_include_bpf
print(" #### partner_invoice_line_data = ", partner_invoice_line_data)
inserted_invoice_id = MYSY_GV.dbname['partner_invoice_line'].insert_one(
partner_invoice_line_data).inserted_id
@ -10977,6 +10989,12 @@ def Invoice_Partner_From_Session_By_Inscription_Id( diction):
partner_invoice_line_data_detail['invoice_line_type'] = "facture"
partner_invoice_line_data_detail['invoice_header_ref_interne'] = partner_invoice_header_data[
'invoice_header_ref_interne']
order_line_is_include_bpf = ""
if ("is_bpf" in session_data.keys()):
order_line_is_include_bpf = session_data['is_bpf']
partner_invoice_line_data_detail['order_line_is_include_bpf'] = order_line_is_include_bpf
partner_invoice_line_data_detail['update_by'] = str(my_partner['_id'])
partner_invoice_line_data_detail['valide'] = "1"
partner_invoice_line_data_detail['locked'] = "0"
@ -11499,6 +11517,12 @@ def Invoice_Splited_Partner_From_Session_By_Inscription_Id( diction):
partner_invoice_line_data['invoice_header_id'] = str(inserted_invoice_id)
partner_invoice_line_data['invoice_line_type'] = "facture"
partner_invoice_line_data['invoice_header_ref_interne'] = partner_invoice_header_data['invoice_header_ref_interne']
order_line_is_include_bpf = ""
if ("is_bpf" in session_data.keys()):
order_line_is_include_bpf = session_data['is_bpf']
partner_invoice_line_data['order_line_is_include_bpf'] = order_line_is_include_bpf
partner_invoice_line_data['update_by'] = str(my_partner['_id'])
partner_invoice_line_data['valide'] = "1"
partner_invoice_line_data['locked'] = "0"
@ -11545,6 +11569,12 @@ def Invoice_Splited_Partner_From_Session_By_Inscription_Id( diction):
partner_invoice_line_data_detail['invoice_line_type'] = "facture"
partner_invoice_line_data_detail['invoice_header_ref_interne'] = partner_invoice_header_data[
'invoice_header_ref_interne']
order_line_is_include_bpf = ""
if ("is_bpf" in session_data.keys()):
order_line_is_include_bpf = session_data['is_bpf']
partner_invoice_line_data_detail['order_line_is_include_bpf'] = order_line_is_include_bpf
partner_invoice_line_data_detail['update_by'] = str(my_partner['_id'])
partner_invoice_line_data_detail['valide'] = "1"
partner_invoice_line_data_detail['locked'] = "0"