20/08/2024 - 21h55

master
cherif 2024-08-20 21:44:13 +02:00
parent 03159e0872
commit 133e7f04c3
9 changed files with 2287 additions and 48 deletions

View File

@ -1,10 +1,16 @@
<?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="18/08/2024 - 21h55">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="20/08/2024 - 13h55">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Dashbord_queries/inscription_tdb_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/inscription_tdb_qries.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Dashbord_queries/ressources_humaines_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/ressources_humaines_tbd_qries.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/apprenant_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/apprenant_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_order.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_order.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -74,13 +80,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00327" summary="07/06/2024 - 22h30">
<created>1717791275942</created>
<option name="number" value="00327" />
<option name="presentableId" value="LOCAL-00327" />
<option name="project" value="LOCAL" />
<updated>1717791275945</updated>
</task>
<task id="LOCAL-00328" summary="ssq">
<created>1717867948694</created>
<option name="number" value="00328" />
@ -417,7 +416,14 @@
<option name="project" value="LOCAL" />
<updated>1724096583697</updated>
</task>
<option name="localTasksCounter" value="376" />
<task id="LOCAL-00376" summary="20/08/2024 - 13h55">
<created>1724154821336</created>
<option name="number" value="00376" />
<option name="presentableId" value="LOCAL-00376" />
<option name="project" value="LOCAL" />
<updated>1724154821337</updated>
</task>
<option name="localTasksCounter" value="377" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -459,7 +465,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="17/07/2024 - 11h30" />
<MESSAGE value="17/07/2024 - 11h30sdf" />
<MESSAGE value="21/07/2024 - 12h" />
<MESSAGE value="23/07/2024 - 12h" />
@ -484,6 +489,7 @@
<MESSAGE value="17/08/2024 - 20h55" />
<MESSAGE value="18/08/2024 - 16h55" />
<MESSAGE value="18/08/2024 - 21h55" />
<option name="LAST_COMMIT_MESSAGE" value="18/08/2024 - 21h55" />
<MESSAGE value="20/08/2024 - 13h55" />
<option name="LAST_COMMIT_MESSAGE" value="20/08/2024 - 13h55" />
</component>
</project>

View File

@ -272,7 +272,7 @@ def Get_Qery_Inscription_By_Session_By_Periode_old(diction):
return local_status, local_retval
RetObject = []
cpt = 1
cpt = 0
for val in local_retval:
val['id'] = str(cpt)
RetObject.append(mycommon.JSONEncoder().encode(val))

View File

@ -817,7 +817,7 @@ def Get_Humain_Ressource_With_Planning_And_Cost(diction):
RetObject = []
cpt = 1
cpt = 0
for val in local_retval:
val['id'] = str(cpt)
RetObject.append(mycommon.JSONEncoder().encode(val))

View File

@ -153,7 +153,7 @@ def AddStagiairetoClass(diction):
diction['token'] = my_partner['token']
print(" #### my_partner V2 = ", my_partner)
#print(" #### my_partner V2 = ", my_partner)
mydata = {}
@ -6168,6 +6168,11 @@ def AcceptAttendeeInscription(diction):
if(len(str(local_class[0]['lms_class_code'])) > 2 ):
lms_class_code = str(local_class[0]['lms_class_code'])
session_end_date = ""
if( "date_fin" in local_session.keys() ):
session_end_date = str(local_session['date_fin']).strip()[0:10]
""""
Inscription sur le LMS :
Si la formation associée à la session possede un code de formation lms 'lms_class_code'
@ -6190,6 +6195,7 @@ def AcceptAttendeeInscription(diction):
new_diction['password'] = secrets.token_urlsafe(6)
new_diction['locked'] = "0"
new_diction['username'] = email
new_diction['session_end_date'] = session_end_date
local_status, local_message, local_participant_lms_id = mys_lms.Create_MySy_LMS_Apprenant(new_diction)
if (local_status is False):
@ -6197,7 +6203,10 @@ def AcceptAttendeeInscription(diction):
return_message = return_message + " - Le compte LSM n'a pas été correctement crée. \n"
is_warning_message = 1
else:
# Mettre à jour la collection "inscription" en ajoutant local_participant_lms_id et et le mot de passe
"""
Mettre à jour la collection "inscription" en ajoutant local_participant_lms_id et et le mot de passe
et la date d'expiration du compte LMS
"""
print(" ### Mise à jour 'inscription' pour inscription_line_id = ", str(diction['inscription_id']),
" local_participant_lms_id = ", local_participant_lms_id, " str(new_diction['password'] ",
str(new_diction['password']))
@ -6205,7 +6214,8 @@ def AcceptAttendeeInscription(diction):
{'_id': ObjectId(str(diction['inscription_id'])), 'partner_owner_recid':str(my_partner['recid'])},
{"$set": {'lms_user_id': str(local_participant_lms_id),
'lms_pwd': str(new_diction['password']),
'lms_class_code': str(lms_class_code)}
'lms_class_code': str(lms_class_code),
'lms_account_expiration_date':str(session_end_date)}
},
upsert=False,
return_document=ReturnDocument.AFTER
@ -6217,7 +6227,7 @@ def AcceptAttendeeInscription(diction):
""""
A present, on va proceder à l'inscription à la formation
"""
print(" ### Debut de l'inscription au à la formation dans le LMS ")
print(" ### Debut de l'inscription à la formation dans le LMS ")
new_diction = {}
new_diction['token'] = diction['token']
new_diction['user_lms_id'] = local_participant_lms_id

File diff suppressed because one or more lines are too long

View File

@ -1303,7 +1303,7 @@ def GetAllValideSessionPartner_List(diction):
]
#print("#### query = ", query)
RetObject = []
cpt = 1
cpt = 0
for retVal in MYSY_GV.dbname['session_formation'].aggregate(query):
if ('myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0):
val = {}
@ -1642,7 +1642,7 @@ def GetAllValideSessionPartner_List_filter_like(diction):
#print("#### GetAllValideSessionPartner_List_filter_likequery = ", query)
RetObject = []
cpt = 1
cpt = 0
for retVal in MYSY_GV.dbname['session_formation'].aggregate(query):
if( 'myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0 ):
@ -1976,7 +1976,7 @@ def GetAllValideSessionPartner_List_no_filter(diction):
print("#### GetAllValideSessionPartner_List_filter_likequery = ", query)
RetObject = []
cpt = 1
cpt = 0
for retVal in MYSY_GV.dbname['session_formation'].aggregate(query):
if( 'myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0 ):
val = {}

View File

@ -826,7 +826,7 @@ def Get_Apprenant_List_Partner_with_filter(diction):
]
#print("#### Get_Apprenant_List_Partner_with_filter laa 01 : query = ", query)
RetObject = []
cpt = 1
cpt = 0
for retVal in MYSY_GV.dbname['apprenant'].aggregate(query):
val = retVal
val['id'] = str(cpt)

View File

@ -1438,7 +1438,7 @@ def Get_Active_Ftions_Mysy_and_Lms(diction):
"""
Cette fonction permet d'inscrire un utilisateur à une formation.
cas d'utilisation :
Lorque le formateur valide l'inscription sur Mysy, on va aller inscrire l'utilisateur
Lorsque le formateur valide l'inscription sur Mysy, on va aller inscrire l'utilisateur
à la formation
"""
def Add_User_To_LMS_Class(diction):
@ -1723,7 +1723,7 @@ def Remove_User_From_LMS_Class(diction):
Cette fonction permet de créer un apprenant.
use case :
Lorsqu'une inscription est validée sur mysy, on va créer le user apprenant
:!\ : a ne pas confondre avec la creation d'un utilisateur enseignant """
/!\ : a ne pas confondre avec la creation d'un utilisateur enseignant """
def Create_MySy_LMS_Apprenant(diction):
try:
@ -1733,7 +1733,7 @@ def Create_MySy_LMS_Apprenant(diction):
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
# field_list.
'''
field_list = ['token', 'lastname', 'firstname', 'email', 'password', 'locked', 'username']
field_list = ['token', 'lastname', 'firstname', 'email', 'password', 'locked', 'username', 'session_end_date']
incom_keys = diction.keys()
for val in incom_keys:
@ -1830,9 +1830,17 @@ def Create_MySy_LMS_Apprenant(diction):
registration_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
session_end_date_str = ""
if( "session_end_date" in diction.keys() and diction['session_end_date']):
local_status = mycommon.CheckisDate(str(diction['session_end_date'])[0:10])
if (local_status is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + "La date de fin de session (session_end_date) n'est pas au format jj/mm/aaaa ")
return False, "La date de fin de session (session_end_date) n'est pas au format jj/mm/aaaa "
session_end_date = datetime.strptime(str(diction['session_end_date']), '%d/%m/%Y')
session_end_date_str = str(session_end_date.strftime("%Y-%m-%d %H:%M:%S"))
mypasswd = password.encode('UTF-8')
@ -1915,7 +1923,7 @@ def Create_MySy_LMS_Apprenant(diction):
hashed_pwd) + "', " \
"enabled='1', " \
"expired='0', " \
"locked = '0', " \
"locked = '0', expiration_date = "+str(session_end_date_str)+", " \
"auth_source = 'platform'," \
"roles = 'a:0:{}', " \
"language = 'french'," \
@ -1939,7 +1947,7 @@ def Create_MySy_LMS_Apprenant(diction):
" registration_date = '"+registration_date+"'," \
" credentials_expired='0', " \
"enabled='1', " \
"expired='0', " \
"expired='0', expiration_date = "+str(session_end_date_str)+", " \
"created_at='" + str( registration_date) + "'," \
" updated_at='" + str( registration_date) + "', " \
" status = '5', " \

View File

@ -3710,7 +3710,7 @@ def Get_Given_Partner_Order_Lines_From_order_ref_interne(diction):
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
if ("order_line_session_id" in retval.keys() and retval['order_line_session_id']):
user['order_line_session_id'] = retval['order_line_session_id']
# Recuperation du code de la session
@ -3866,7 +3866,7 @@ def Get_Given_Partner_Order_Lines_From_order_ref_interne(diction):
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
if ("order_line_session_id" in retval.keys() and retval['order_line_session_id']):
user['order_line_session_id'] = retval['order_line_session_id']
# Recuperation du code de la session
@ -4943,7 +4943,7 @@ def Compute_Order_Header(diction):
if( str(header_reduction_type) == "fixe" ):
header_reduction_type_value_total_amount = mycommon.tryFloat(header_reduction_type_value)
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction - mycommon.tryFloat(header_reduction_type_value)
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_before_reduction - header_reduction_type_value_total_amount
"""print(" GRRRR 022 header_reduction_type_value_total_amount = ",
header_reduction_type_value_total_amount)
@ -4959,14 +4959,17 @@ def Compute_Order_Header(diction):
#print(" GRRRR mycommon.tryFloat(header_reduction_type_value)/100 = ",
# (line_sum_order_line_montant_hors_taxes_after_reduction - (line_sum_order_line_montant_hors_taxes_after_reduction*mycommon.tryFloat(header_reduction_type_value)/100)) )
header_reduction_type_value_total_amount = line_sum_order_line_montant_hors_taxes_after_reduction * mycommon.tryFloat(header_reduction_type_value)/100
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction - ((line_sum_order_line_montant_hors_taxes_after_reduction *mycommon.tryFloat(header_reduction_type_value)/100 ))
header_reduction_type_value_total_amount = line_sum_order_line_montant_hors_taxes_before_reduction * mycommon.tryFloat(header_reduction_type_value)/100
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_before_reduction - header_reduction_type_value_total_amount
#print(" GRRRR global_order_amount_ht_after_header_reduction = ",global_order_amount_ht_after_header_reduction)
else:
header_reduction_type_value_total_amount = 0
global_order_amount_ht_before_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction
global_order_amount_ht_before_header_reduction = line_sum_order_line_montant_hors_taxes_before_reduction
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_before_reduction
global_order_amount_ttc = global_order_amount_ht_after_header_reduction + line_sum_order_line_tax_amount
@ -4980,12 +4983,23 @@ def Compute_Order_Header(diction):
"""
Tous les calculs, ok, on met à l'entete de de l'order
"""
"""
/!\ 20/08/204 :
mise à jour des calcul :
dans les lignes, le montant hors taxe, inclus la reduction (vrai HT - montant reduction).
par consequent dans le header :
- total_lines_hors_taxe_before_lines_reduction contient le montant hors taxe incluant la reduction
"""
header_computed_data = {}
header_computed_data['total_lines_montant_reduction'] = str(round(line_sum_order_line_montant_reduction, 2))
header_computed_data['total_lines_hors_taxe_before_lines_reduction'] = str(round(line_sum_order_line_montant_hors_taxes_before_reduction, 2))
header_computed_data['total_lines_hors_taxe_after_lines_reduction'] = str(round(line_sum_order_line_montant_hors_taxes_after_reduction, 2))
header_computed_data['total_lines_hors_taxe_before_lines_reduction'] = str(round((line_sum_order_line_montant_hors_taxes_before_reduction+line_sum_order_line_montant_reduction), 2))
header_computed_data['total_lines_hors_taxe_after_lines_reduction'] = str(round(line_sum_order_line_montant_hors_taxes_before_reduction, 2))
header_computed_data['order_header_montant_reduction'] = str(round(header_reduction_type_value_total_amount, 2))
header_computed_data['total_header_hors_taxe_before_header_reduction'] = str(round(line_sum_order_line_montant_hors_taxes_after_reduction, 2))
header_computed_data['total_header_hors_taxe_before_header_reduction'] = str(round(line_sum_order_line_montant_hors_taxes_before_reduction, 2))
header_computed_data['total_header_hors_taxe_after_header_reduction'] = str(round(global_order_amount_ht_after_header_reduction, 2))
header_computed_data['order_header_tax'] = "TVA "+str(partner_taux_tva)+"%"
header_computed_data['order_header_tax_amount'] = str(round(line_sum_order_line_tax_amount, 2))
@ -4993,8 +5007,7 @@ def Compute_Order_Header(diction):
header_computed_data['date_update'] = str(datetime.now())
print(" ### header_computed_data = ", header_computed_data)
#print(" ### header_computed_data = ", header_computed_data)
local_retval = MYSY_GV.dbname['partner_order_header'].find_one_and_update({'_id':ObjectId(str(diction['_id'])),
'valide':'1', 'locked':'0',
@ -5180,7 +5193,7 @@ def GerneratePDF_Partner_Order(diction):
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
if ("order_line_session_id" in retval.keys() and retval['order_line_session_id'] ):
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'valide': '1',
@ -5342,7 +5355,7 @@ def GerneratePDF_Partner_Order(diction):
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
if ("order_line_session_id" in retval.keys() and retval['order_line_session_id']):
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'valide': '1',
@ -5666,7 +5679,7 @@ def Gernerate_Stock_PDF_Partner_Order(diction):
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
if ("order_line_session_id" in retval.keys() and retval['order_line_session_id']):
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'valide': '1',
@ -5828,7 +5841,7 @@ def Gernerate_Stock_PDF_Partner_Order(diction):
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
if ("order_line_session_id" in retval.keys() and retval['order_line_session_id'] ):
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'valide': '1',
@ -6150,7 +6163,7 @@ def Send_Partner_Order_By_Email(diction):
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
if ("order_line_session_id" in retval.keys() and retval['order_line_session_id']):
local_session_data = MYSY_GV.dbname['session_formation'].find_one({'_id':ObjectId(str(retval['order_line_session_id'])),
'valide':'1',
'partner_owner_recid':my_partner['recid']})
@ -6313,7 +6326,7 @@ def Send_Partner_Order_By_Email(diction):
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
if ("order_line_session_id" in retval.keys() and retval['order_line_session_id']):
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'valide': '1',
@ -8023,7 +8036,7 @@ def Send_Quotation_Remind_Level1(diction):
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
if ("order_line_session_id" in retval.keys() and retval['order_line_session_id']):
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'valide': '1',
@ -8186,7 +8199,7 @@ def Send_Quotation_Remind_Level1(diction):
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
if ("order_line_session_id" in retval.keys() and retval['order_line_session_id']):
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'valide': '1',
@ -8662,6 +8675,8 @@ def Create_Automatic_Quotation(diction):
#print(" ### COMPUTE : le taux de TVA = ", str(partner_taux_tva))
prix_total_ht = mycommon.tryFloat( str(valide_lead_website_data['nb_person_info'])) * mycommon.tryFloat(str(valide_lead_website_data['class_sales_price']))
line_taxe = (prix_total_ht * partner_taux_tva)/100
lines_node = {}