27/04/2024 - 22h

master
cherif 2024-04-27 22:02:54 +02:00
parent d4761b48cb
commit 70f097d1c2
7 changed files with 5427 additions and 17 deletions

View File

@ -3,8 +3,12 @@
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="25/04/2024 - 19h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Dashbord_queries/factures_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/factures_tbd_qries.py" 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$/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$/partner_invoice.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_invoice.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 +78,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00229" summary="26/02/2024 - 16h30">
<created>1708961961750</created>
<option name="number" value="00229" />
<option name="presentableId" value="LOCAL-00229" />
<option name="project" value="LOCAL" />
<updated>1708961961751</updated>
</task>
<task id="LOCAL-00230" summary="28/02/2024 - 21h30">
<created>1709152509358</created>
<option name="number" value="00230" />
@ -417,7 +414,14 @@
<option name="project" value="LOCAL" />
<updated>1714064812226</updated>
</task>
<option name="localTasksCounter" value="278" />
<task id="LOCAL-00278" summary="25/04/2024 - 19h">
<created>1714065354319</created>
<option name="number" value="00278" />
<option name="presentableId" value="LOCAL-00278" />
<option name="project" value="LOCAL" />
<updated>1714065354319</updated>
</task>
<option name="localTasksCounter" value="279" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">

View File

@ -34,7 +34,7 @@ from operator import itemgetter
"""
Recuperation du nombre d'inscrit par par session sur une période
"""
def Get_Qery_Inscription_By_Session_By_Periode(diction):
def Get_Qery_Inscription_By_Session_By_Periode_old(diction):
try:
diction = mycommon.strip_dictionary(diction)
@ -290,6 +290,855 @@ def Get_Qery_Inscription_By_Session_By_Periode(diction):
return False, " Impossible de récupérer les données "
def Get_Qery_Inscription_By_Session_By_Periode(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'session_start_date', 'session_end_date', 'filter_value', ]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
return False, " Les informations fournies sont incorrectes",
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'session_start_date', 'session_end_date']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes",
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
filt_session_start_date = ""
if ("session_start_date" in diction.keys() and diction['session_start_date']):
filt_session_start_date = str(diction['session_start_date'])[0:10]
local_status = mycommon.CheckisDate(filt_session_start_date)
if (local_status is False):
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le filtre : 'date de debut de session' n'est pas au format jj/mm/aaaa.")
return False, " Le filtre : 'date de debut de session' n'est pas au format jj/mm/aaaa."
filt_session_end_date = ""
if ("session_end_date" in diction.keys() and diction['session_end_date']):
filt_session_end_date = str(diction['session_end_date'])[0:10]
local_status = mycommon.CheckisDate(filt_session_end_date)
if (local_status is False):
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le filtre : 'date de fin de session' n'est pas au format jj/mm/aaaa.")
return False, " Le filtre : 'date de fin de session' n'est pas au format jj/mm/aaaa."
"""
Si la valeur de 'filter_value' est m0 ou m1, on va aller recuperer les date du mois correspondant.
On ecrase les valeur de filt_session_start_date et filt_session_end_date
"""
if ('filter_value' in diction.keys()):
if (str(diction['filter_value']) == "m0"):
# On recupere les date du mois en cours
local_status, start_current_month_date, end_current_month_date = mycommon.Get_Current_Month_Start_End_Date()
if (local_status is False):
return local_status, start_current_month_date
filt_session_start_date = start_current_month_date
filt_session_end_date = end_current_month_date
elif (str(diction['filter_value']) == "m1"):
# On recupere les date du mois en cours
local_status, start_current_month_date, end_current_month_date = mycommon.Get_Previous_Month_Start_End_Date()
if (local_status is False):
return local_status, start_current_month_date
filt_session_start_date = start_current_month_date
filt_session_end_date = end_current_month_date
RetObject = []
val_tmp = 1
filt_session_start_date_ISODATE = datetime.strptime(str(filt_session_start_date), '%d/%m/%Y')
filt_session_end_date_ISODATE = datetime.strptime(str(filt_session_end_date), '%d/%m/%Y')
"""
Creation de la range des mois entre filt_periode_start_date_ISODATE et
filt_periode_end_date_ISODATE
"""
range_date_month = []
start = filt_session_start_date_ISODATE
end = filt_session_end_date_ISODATE
while start <= end:
node = {}
node['month_year'] = '{:02d}'.format(start.month) + "_" + str(start.year)
node['label'] = '{:02d}'.format(start.month) + "_" + str(start.year)
node['TotalAmount'] = 0
node['value'] = 0
node['count'] = 0
range_date_month.append(node)
start += relativedelta(months=1)
filt_session_start_date_ISODATE_work = filt_session_start_date_ISODATE
filt_session_end_date_ISODATE_work = filt_session_end_date_ISODATE
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])}, {"valide": '1'},
{"apprenant_id": {"$exists": True}},
{"inscription_validation_date": {"$exists": True}},
{"status": "1"},
{'mysy_inscription_validation_date': {'$gte': filt_session_start_date_ISODATE,
'$lte': filt_session_end_date_ISODATE}},
]}
"""
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])}, {"valide": '1'},
{"apprenant_id": {"$exists": True}},
]}
"""
# print(" ### qery_match = ", qery_match)
pipe_qry = ([
{"$addFields": {
"mysy_inscription_validation_date": {
'$dateFromString': {
'dateString': { "$substr": [ "$inscription_validation_date", 0, 10 ] },
'format': "%d/%m/%Y"
}
}
}
},
{'$match': qery_match},
# ----
{'$lookup': {
'from': 'session_formation',
'let': {'session_id': "$session_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$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']}
]
}
}
},
],
'as': '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}}
],
"as": "myclass_collection"
}
},
# --
# ---
{'$lookup': {
'from': 'apprenant',
"let": {'apprenant_id': "$apprenant_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$_id", {'$convert': {
'input': "$$apprenant_id",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$valide", "1"]},
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']}
]
}
}
},
],
'as': 'apprenant_collection'
}
},
{'$group': {
'_id': {
"mois_annee_inscription": {
"$concat": [{'$substr': ["$inscription_validation_date", 3, 2]}, "_", {'$substr': ["$inscription_validation_date", 6, 4]}]},
"annee_inscription": {'$substr': ["$inscription_validation_date", 6, 4]},
"mois_inscription": {'$substr': ["$inscription_validation_date", 3, 2]},
},
"count": {"$sum": 1}
}
},
{
'$sort': {'count': -1}
},
])
"""
Cette requete donne le tableau complete des apprenants avec les sessions
si on veut faire des group by, on ajoute ceci :
{'$group': {
'_id': {
"apprenant_collection_nom":"$apprenant_collection.nom",
"apprenant_collection_prenom":"$apprenant_collection.prenom",
"apprenant_collection_session":"$session_formation_collection.code_session",
},
'count': {'$count': {}
}
}
},
"""
print(" ### Get_Qery_Inscription_By_Session_By_Periode ici pipe_qry = ", pipe_qry)
axis_data = []
cpt = 0
tab_lines_inscription_data = []
for retval in MYSY_GV.dbname['inscription'].aggregate(pipe_qry):
cpt = cpt + 1
for tmp in range_date_month:
axis_data.append(str(tmp['month_year']))
if( str(retval['_id']['mois_annee_inscription']) == str(tmp['month_year']) ):
tmp['count'] = mycommon.tryFloat(str(retval['count']))
RetObject = []
json_retval = {}
json_retval['data'] = range_date_month
json_retval['axis_data'] = axis_data
print(" ### json_retval = ", json_retval)
RetObject.append(mycommon.JSONEncoder().encode(json_retval))
print(" ### RetObject = ", RetObject)
return True, RetObject
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer les données "
"""
TBD inscription groupé par Formation
"""
def Get_Qery_Inscription_Group_By_Class(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'session_start_date', 'session_end_date', 'filter_value', ]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
return False, " Les informations fournies sont incorrectes",
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'session_start_date', 'session_end_date']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes",
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
filt_session_start_date = ""
if ("session_start_date" in diction.keys() and diction['session_start_date']):
filt_session_start_date = str(diction['session_start_date'])[0:10]
local_status = mycommon.CheckisDate(filt_session_start_date)
if (local_status is False):
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le filtre : 'date de debut de session' n'est pas au format jj/mm/aaaa.")
return False, " Le filtre : 'date de debut de session' n'est pas au format jj/mm/aaaa."
filt_session_end_date = ""
if ("session_end_date" in diction.keys() and diction['session_end_date']):
filt_session_end_date = str(diction['session_end_date'])[0:10]
local_status = mycommon.CheckisDate(filt_session_end_date)
if (local_status is False):
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le filtre : 'date de fin de session' n'est pas au format jj/mm/aaaa.")
return False, " Le filtre : 'date de fin de session' n'est pas au format jj/mm/aaaa."
"""
Si la valeur de 'filter_value' est m0 ou m1, on va aller recuperer les date du mois correspondant.
On ecrase les valeur de filt_session_start_date et filt_session_end_date
"""
if ('filter_value' in diction.keys()):
if (str(diction['filter_value']) == "m0"):
# On recupere les date du mois en cours
local_status, start_current_month_date, end_current_month_date = mycommon.Get_Current_Month_Start_End_Date()
if (local_status is False):
return local_status, start_current_month_date
filt_session_start_date = start_current_month_date
filt_session_end_date = end_current_month_date
elif (str(diction['filter_value']) == "m1"):
# On recupere les date du mois en cours
local_status, start_current_month_date, end_current_month_date = mycommon.Get_Previous_Month_Start_End_Date()
if (local_status is False):
return local_status, start_current_month_date
filt_session_start_date = start_current_month_date
filt_session_end_date = end_current_month_date
RetObject = []
val_tmp = 1
filt_session_start_date_ISODATE = datetime.strptime(str(filt_session_start_date), '%d/%m/%Y')
filt_session_end_date_ISODATE = datetime.strptime(str(filt_session_end_date), '%d/%m/%Y')
"""
Creation de la range des mois entre filt_periode_start_date_ISODATE et
filt_periode_end_date_ISODATE
"""
range_date_month = []
start = filt_session_start_date_ISODATE
end = filt_session_end_date_ISODATE
while start <= end:
node = {}
node['month_year'] = '{:02d}'.format(start.month) + "_" + str(start.year)
node['label'] = '{:02d}'.format(start.month) + "_" + str(start.year)
node['TotalAmount'] = 0
node['value'] = 0
node['count'] = 0
range_date_month.append(node)
start += relativedelta(months=1)
filt_session_start_date_ISODATE_work = filt_session_start_date_ISODATE
filt_session_end_date_ISODATE_work = filt_session_end_date_ISODATE
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])}, {"valide": '1'},
{"apprenant_id": {"$exists": True}},
{"inscription_validation_date": {"$exists": True}},
{"status": "1"},
{'mysy_inscription_validation_date': {'$gte': filt_session_start_date_ISODATE,
'$lte': filt_session_end_date_ISODATE}},
]}
"""
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])}, {"valide": '1'},
{"apprenant_id": {"$exists": True}},
]}
"""
# print(" ### qery_match = ", qery_match)
pipe_qry = ([
{"$addFields": {
"mysy_inscription_validation_date": {
'$dateFromString': {
'dateString': { "$substr": [ "$inscription_validation_date", 0, 10 ] },
'format': "%d/%m/%Y"
}
}
}
},
{'$match': qery_match},
# ----
{'$lookup': {
'from': 'session_formation',
'let': {'session_id': "$session_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$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']}
]
}
}
},
],
'as': '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}}
],
"as": "myclass_collection"
}
},
# --
# ---
{'$lookup': {
'from': 'apprenant',
"let": {'apprenant_id': "$apprenant_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$_id", {'$convert': {
'input': "$$apprenant_id",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$valide", "1"]},
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']}
]
}
}
},
],
'as': 'apprenant_collection'
}
},
{
"$group": {
"_id": {
"class_id": "$myclass_collection._id",
"class_code": "$myclass_collection.external_code",
"class_title": "$myclass_collection.title",
},
"count": {
"$sum": 1
}
}
},
{
'$sort': {'count': -1}
},
])
"""
Cette requete donne le tableau complete des apprenants avec les sessions
si on veut faire des group by, on ajoute ceci :
{'$group': {
'_id': {
"apprenant_collection_nom":"$apprenant_collection.nom",
"apprenant_collection_prenom":"$apprenant_collection.prenom",
"apprenant_collection_session":"$session_formation_collection.code_session",
},
'count': {'$count': {}
}
}
},
"""
print(" ### Get_Qery_Inscription_By_Session_By_Periode ici pipe_qry = ", pipe_qry)
axis_data = []
my_data = []
cpt = 0
tab_lines_inscription_data = []
for retval in MYSY_GV.dbname['inscription'].aggregate(pipe_qry):
cpt = cpt + 1
axis_data.append(str(retval['_id']['class_code'][0]))
node = {}
node['class_code'] = str(retval['_id']['class_code'][0])
node['class_title'] = str(retval['_id']['class_title'][0])
node['label'] = str(retval['_id']['class_code'][0])
node['value'] = mycommon.tryFloat(str(retval['count']))
node['count'] = mycommon.tryFloat(str(retval['count']))
my_data.append(node)
RetObject = []
json_retval = {}
json_retval['data'] = my_data
json_retval['axis_data'] = axis_data
print(" ### json_retval Groupe by class = ", json_retval)
RetObject.append(mycommon.JSONEncoder().encode(json_retval))
print(" ### json_retval Groupe by class = ", RetObject)
return True, RetObject
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer les données "
"""
TBD inscription groupé par session
"""
def Get_Qery_Inscription_Group_By_Session(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'session_start_date', 'session_end_date', 'filter_value', ]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
return False, " Les informations fournies sont incorrectes",
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'session_start_date', 'session_end_date']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes",
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
filt_session_start_date = ""
if ("session_start_date" in diction.keys() and diction['session_start_date']):
filt_session_start_date = str(diction['session_start_date'])[0:10]
local_status = mycommon.CheckisDate(filt_session_start_date)
if (local_status is False):
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le filtre : 'date de debut de session' n'est pas au format jj/mm/aaaa.")
return False, " Le filtre : 'date de debut de session' n'est pas au format jj/mm/aaaa."
filt_session_end_date = ""
if ("session_end_date" in diction.keys() and diction['session_end_date']):
filt_session_end_date = str(diction['session_end_date'])[0:10]
local_status = mycommon.CheckisDate(filt_session_end_date)
if (local_status is False):
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le filtre : 'date de fin de session' n'est pas au format jj/mm/aaaa.")
return False, " Le filtre : 'date de fin de session' n'est pas au format jj/mm/aaaa."
"""
Si la valeur de 'filter_value' est m0 ou m1, on va aller recuperer les date du mois correspondant.
On ecrase les valeur de filt_session_start_date et filt_session_end_date
"""
if ('filter_value' in diction.keys()):
if (str(diction['filter_value']) == "m0"):
# On recupere les date du mois en cours
local_status, start_current_month_date, end_current_month_date = mycommon.Get_Current_Month_Start_End_Date()
if (local_status is False):
return local_status, start_current_month_date
filt_session_start_date = start_current_month_date
filt_session_end_date = end_current_month_date
elif (str(diction['filter_value']) == "m1"):
# On recupere les date du mois en cours
local_status, start_current_month_date, end_current_month_date = mycommon.Get_Previous_Month_Start_End_Date()
if (local_status is False):
return local_status, start_current_month_date
filt_session_start_date = start_current_month_date
filt_session_end_date = end_current_month_date
RetObject = []
val_tmp = 1
filt_session_start_date_ISODATE = datetime.strptime(str(filt_session_start_date), '%d/%m/%Y')
filt_session_end_date_ISODATE = datetime.strptime(str(filt_session_end_date), '%d/%m/%Y')
"""
Creation de la range des mois entre filt_periode_start_date_ISODATE et
filt_periode_end_date_ISODATE
"""
range_date_month = []
start = filt_session_start_date_ISODATE
end = filt_session_end_date_ISODATE
while start <= end:
node = {}
node['month_year'] = '{:02d}'.format(start.month) + "_" + str(start.year)
node['label'] = '{:02d}'.format(start.month) + "_" + str(start.year)
node['TotalAmount'] = 0
node['value'] = 0
node['count'] = 0
range_date_month.append(node)
start += relativedelta(months=1)
filt_session_start_date_ISODATE_work = filt_session_start_date_ISODATE
filt_session_end_date_ISODATE_work = filt_session_end_date_ISODATE
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])}, {"valide": '1'},
{"apprenant_id": {"$exists": True}},
{"inscription_validation_date": {"$exists": True}},
{"status": "1"},
{'mysy_inscription_validation_date': {'$gte': filt_session_start_date_ISODATE,
'$lte': filt_session_end_date_ISODATE}},
]}
"""
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])}, {"valide": '1'},
{"apprenant_id": {"$exists": True}},
]}
"""
# print(" ### qery_match = ", qery_match)
pipe_qry = ([
{"$addFields": {
"mysy_inscription_validation_date": {
'$dateFromString': {
'dateString': { "$substr": [ "$inscription_validation_date", 0, 10 ] },
'format': "%d/%m/%Y"
}
}
}
},
{'$match': qery_match},
# ----
{'$lookup': {
'from': 'session_formation',
'let': {'session_id': "$session_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$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']}
]
}
}
},
],
'as': '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}}
],
"as": "myclass_collection"
}
},
# --
# ---
{'$lookup': {
'from': 'apprenant',
"let": {'apprenant_id': "$apprenant_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$_id", {'$convert': {
'input': "$$apprenant_id",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$valide", "1"]},
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']}
]
}
}
},
],
'as': 'apprenant_collection'
}
},
{
"$group": {
"_id": {
"session_id": "$session_formation_collection._id",
"session_code": "$session_formation_collection.code_session",
"session_title": "$session_formation_collection.titre",
},
"count": {
"$sum": 1
}
}
},
{
'$sort': {'count': -1}
},
])
"""
Cette requete donne le tableau complete des apprenants avec les sessions
si on veut faire des group by, on ajoute ceci :
{'$group': {
'_id': {
"apprenant_collection_nom":"$apprenant_collection.nom",
"apprenant_collection_prenom":"$apprenant_collection.prenom",
"apprenant_collection_session":"$session_formation_collection.code_session",
},
'count': {'$count': {}
}
}
},
"""
print(" ### Get_Qery_Inscription_By_Session_By_Session ici pipe_qry = ", pipe_qry)
axis_data = []
my_data = []
cpt = 0
tab_lines_inscription_data = []
for retval in MYSY_GV.dbname['inscription'].aggregate(pipe_qry):
cpt = cpt + 1
axis_data.append(str(retval['_id']['session_code'][0]))
node = {}
node['session_code'] = str(retval['_id']['session_code'][0])
node['session_title'] = str(retval['_id']['session_title'][0])
node['label'] = str(retval['_id']['session_code'][0])
node['value'] = mycommon.tryFloat(str(retval['count']))
node['count'] = mycommon.tryFloat(str(retval['count']))
my_data.append(node)
RetObject = []
json_retval = {}
json_retval['data'] = my_data
json_retval['axis_data'] = axis_data
#print(" ### json_retval Groupe by session = ", json_retval)
RetObject.append(mycommon.JSONEncoder().encode(json_retval))
#print(" ### json_retval Groupe by session = ", RetObject)
return True, RetObject
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer les données "
"""
Cette fonction permet de formatter le tableau des apprenants
sous forme de tableau plus exploitable

View File

@ -205,12 +205,13 @@ def Get_Humain_Ressource_With_Planning(diction):
new_retval_titles = []
new_retval_data = []
local_id = 0
total_duration = 0
for retval in MYSY_GV.dbname['ressource_humaine'].aggregate(pipe_qry):
## Recuperation des agenda
if( "collection_agenda" in retval.keys() and len(retval['collection_agenda']) > 0 ):
for agenda_retval in retval['collection_agenda'] :
local_id = local_id + 1
new_node = {}
@ -292,12 +293,19 @@ def Get_Humain_Ressource_With_Planning(diction):
event_duration_hour = round(divmod(event_duration_second, 3600)[0]+divmod(event_duration_second, 3600)[1]/3600, 2)
total_duration = total_duration + event_duration_hour
new_node['event_duration_second'] = str(event_duration_second)
new_node['event_duration_hour'] = str(event_duration_hour)
#print(" ### new_node = ", new_node)
RetObject.append(mycommon.JSONEncoder().encode(new_node))
node_duration = {"total_duration":str(total_duration)}
#print(' ### node_duration = ', node_duration)
RetObject.append(mycommon.JSONEncoder().encode(node_duration))
return True, RetObject
@ -626,7 +634,7 @@ def Get_Humain_Ressource_With_Planning_And_Cost(diction):
"""
Etape 1: Récuperation des donnée employé avec les contrat associés
"""
print(" #### tab_rh_object_id = ", tab_rh_object_id)
#print(" #### tab_rh_object_id = ", tab_rh_object_id)
# { "$match": {'_id':{'$in':tab_rh_object_id} }},
# {'$match': {'_id': ObjectId('6509a1adaca6e5023d7af487')}},
@ -820,7 +828,7 @@ def Get_Humain_Ressource_With_Planning_And_Cost(diction):
#print(" ### Final Line " + str(cpt) + " : ", tab_lines_employe_by_contract_json_formatted_str)
#print(" RetObject = ", RetObject)
print(' on a ' + str(cpt) + ' lignes ')
#print(' on a ' + str(cpt) + ' lignes ')
return True, RetObject
@ -841,6 +849,10 @@ def Format_employee_contrat_agenda_events(tab_diction):
try:
return_tab = []
total_duration = 0
total_cost = 0
for val in tab_diction:
#print(" #### Debut traitement de la ligne " + str(val))
@ -961,6 +973,9 @@ def Format_employee_contrat_agenda_events(tab_diction):
new_node['rh_event_planning_event_end'] = str(datetime.strptime(str(event_data['event_end'] )[0:16], '%Y-%m-%dT%H:%M').strftime("%d/%m/%Y %H:%M"))
new_node['rh_event_planning_agenda_date_jour'] = event_data['agenda_date_jour']
new_node['rh_event_planning_event_duration_hour'] = event_data['event_duration_hour']
total_duration = total_duration + mycommon.tryFloat(str(event_data['event_duration_hour']))
new_node['rh_event_planning_event_duration_second'] = event_data['event_duration_second']
if ("comment" in event_data.keys()):
new_node['rh_event_planning_even_comment'] = event_data['comment']
@ -984,11 +999,12 @@ def Format_employee_contrat_agenda_events(tab_diction):
'rh_contrat_groupe_prix_achat_cout']):
if (str(new_node['rh_contrat_groupe_prix_achat_periodicite']) == "heure"):
new_node['rh_event_planning_event_cost'] = str(
mycommon.tryFloat(new_node['rh_contrat_groupe_prix_achat_cout']) * mycommon.tryFloat(
new_node['rh_event_planning_event_duration_hour']))
new_node['rh_event_planning_event_cost'] = str( mycommon.tryFloat(new_node['rh_contrat_groupe_prix_achat_cout']) * mycommon.tryFloat( new_node['rh_event_planning_event_duration_hour']))
total_cost = total_cost + mycommon.tryFloat((str(new_node['rh_event_planning_event_cost'])))
elif (str(new_node['rh_contrat_groupe_prix_achat_periodicite']) == "fixe"):
new_node['rh_event_planning_event_cost'] = str((new_node['rh_contrat_groupe_prix_achat_cout']))
total_cost = total_cost + mycommon.tryFloat((str(new_node['rh_event_planning_event_cost'])))
elif ("rh_contrat_groupe_prix_achat_id" in new_node.keys() and str(
@ -1002,10 +1018,11 @@ def Format_employee_contrat_agenda_events(tab_diction):
new_node['rh_event_planning_event_cost'] = str(
mycommon.tryFloat(new_node['rh_contrat_cout']) * mycommon.tryFloat(
new_node['rh_event_planning_event_duration_hour']))
total_cost = total_cost + mycommon.tryFloat((str(new_node['rh_event_planning_event_cost'])))
elif (str(new_node['rh_contrat_periodicite']) == "fixe"):
new_node['rh_event_planning_event_cost'] = str((new_node['rh_contrat_cout']))
total_cost = total_cost + mycommon.tryFloat((str(new_node['rh_event_planning_event_cost'])))
else:
@ -1014,6 +1031,16 @@ def Format_employee_contrat_agenda_events(tab_diction):
return_tab.append(new_node)
node_total_duration = {'total_duration':str(total_duration)}
return_tab.append(node_total_duration)
node_total_cost = {'total_cost':str(total_cost)}
return_tab.append(node_total_cost)
#print(" #### total_duration = ", total_duration)
#print(" #### total_cost = ", total_cost)
return True, return_tab
except Exception as e:

File diff suppressed because it is too large Load Diff

38
main.py
View File

@ -7436,6 +7436,32 @@ def Get_Qery_Inscription_By_Session_By_Periode():
status, retval = inscription_tdb_qries.Get_Qery_Inscription_By_Session_By_Periode(payload)
return jsonify(status=status, message=retval)
"""
API / TBD / QRY : Recuperation des données des inscriptions groupé par formation
"""
@app.route('/myclass/api/Get_Qery_Inscription_Group_By_Class/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Qery_Inscription_Group_By_Class():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_Qery_Inscription_Group_By_Class payload = ",payload)
status, retval = inscription_tdb_qries.Get_Qery_Inscription_Group_By_Class(payload)
return jsonify(status=status, message=retval)
"""
API / TBD / QRY : Recuperation des données des inscriptions groupé par Session
"""
@app.route('/myclass/api/Get_Qery_Inscription_Group_By_Session/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Qery_Inscription_Group_By_Session():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_Qery_Inscription_Group_By_Session payload = ",payload)
status, retval = inscription_tdb_qries.Get_Qery_Inscription_Group_By_Session(payload)
return jsonify(status=status, message=retval)
"""
@ -8564,6 +8590,18 @@ def TBD_FACTURE_01_Export_Dashbord_To_Excel(token, user_dashbord_id, date_from,
return False
"""
API pour recalculer les totaux d'une facture
"""
@app.route('/myclass/api/Compute_Invoice_Order_Data/', methods=['POST','GET'])
@crossdomain(origin='*')
def Compute_Invoice_Order_Data():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Compute_Invoice_Order_Data payload = ",payload)
status, retval = partner_invoice.Compute_Invoice_Order_Data(payload)
return jsonify(status=status, message=retval)
if __name__ == '__main__':

View File

@ -2128,3 +2128,268 @@ def Send_Partner_Invoice_By_Email(diction):
"""
/!\ 26/04/2024
La fonction de creation d'une facture va computer la commande associée, puis copier les ligne
or quand on fait une facturation a partir d'une session, il n'y pas de 'commande', donc pas de computation.
Il faut donc créer une fonction de computation de la factures apres sa creation
"""
def Compute_Invoice_Order_Data(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', '_id']
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
return False, " Les informations fournies sont incorrectes",
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', '_id']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes",
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
# Recuperation de la valeur de la TVA (taux tva)
partner_taux_tva = 20
if ("invoice_taux_vat" in my_partner.keys()):
IsInt_status, IsInt_retval = mycommon.IsInt(str(my_partner['invoice_taux_vat']))
if (IsInt_status is False):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + str(
my_partner['invoice_taux_vat']) + "' n'est pas un taux de TVA correcte ")
return False, " La valeur '" + str(
my_partner['invoice_taux_vat']) + "' n'est pas un taux de TVA correcte ",
partner_taux_tva = IsInt_retval
print(" ### COMPUTE : le taux de TVA = ", str(partner_taux_tva))
# Verification de la validité de la facture
qry = {'_id': ObjectId(str(diction['_id'])), 'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])}
print(" ### qry = ", qry)
is_Invoice_Existe_Count = MYSY_GV.dbname['partner_invoice_header'].count_documents(
{'_id': ObjectId(str(diction['_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_Invoice_Existe_Count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de la facture n'est pas valide ")
return False, " L'identifiant de la facture n'est pas valide ",
Invoice_Data = MYSY_GV.dbname['partner_invoice_header'].find_one({'_id': ObjectId(str(diction['_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid':str(my_partner['recid'])})
"""
Verifier que la facture a des lignes valides, si non refuser
"""
is_Invoice_Line_Existe_Count = MYSY_GV.dbname['partner_invoice_line'].count_documents(
{'invoice_header_id': (str(diction['_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_Invoice_Line_Existe_Count <= 0):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Il n'existe aucune ligne de facture pour cette facture_id : "+str(diction['_id']))
return False, " Il n'existe aucune ligne de facture pour cette facture_id : "+str(diction['_id'])
"""
Algo :
1 - récupérer toutes les lignes valides, créer des sous totaux
2 - Appliquer les eventuels reductions d'entete
"""
nb_line = 0
line_sum_invoice_line_tax_amount = 0
line_sum_invoice_line_montant_reduction = 0
line_sum_invoice_line_montant_hors_taxes_before_reduction = 0
line_sum_invoice_line_montant_hors_taxes_after_reduction = 0
line_sum_invoice_line_montant_toutes_taxes = 0
for local_retval in MYSY_GV.dbname['partner_invoice_line'].find( {'invoice_header_id': (str(diction['_id'])), 'valide': '1', 'locked': '0','partner_owner_recid': str(my_partner['recid'])}):
print(" ------------------- Pour la ligne numero : ", nb_line)
ligne_montant_reduction = 0
if ("order_line_montant_reduction" in local_retval.keys()):
line_sum_invoice_line_montant_reduction = line_sum_invoice_line_montant_reduction + mycommon.tryFloat(
local_retval['order_line_montant_reduction'])
ligne_montant_reduction = mycommon.tryFloat(local_retval['order_line_montant_reduction'])
print(" #### invoice_line_montant_reduction = ",
str(mycommon.tryFloat(local_retval['order_line_montant_reduction'])))
if ("order_line_tax_amount" in local_retval.keys()):
line_sum_invoice_line_tax_amount = line_sum_invoice_line_tax_amount + mycommon.tryFloat(
local_retval['order_line_tax_amount'])
print(" #### invoice_line_tax_amount = ", str(mycommon.tryFloat(local_retval['order_line_tax_amount'])))
if ("order_line_montant_hors_taxes" in local_retval.keys()):
line_sum_invoice_line_montant_hors_taxes_before_reduction = line_sum_invoice_line_montant_hors_taxes_before_reduction + mycommon.tryFloat(
local_retval['order_line_montant_hors_taxes'])
print(" #### invoice_line_montant_hors_taxes = ",
str(mycommon.tryFloat(local_retval['order_line_montant_hors_taxes'])))
invoice_line_montant_hors_taxes_APRES_REDUCTION = mycommon.tryFloat(
local_retval['order_line_montant_hors_taxes']) - ligne_montant_reduction
print(" #### invoice_line_montant_hors_taxes_APRES_REDUCTION = ", str(invoice_line_montant_hors_taxes_APRES_REDUCTION))
if ("order_line_montant_toutes_taxes" in local_retval.keys()):
line_sum_invoice_line_montant_toutes_taxes = line_sum_invoice_line_montant_toutes_taxes + mycommon.tryFloat(local_retval['order_line_montant_toutes_taxes'])
print(" #### invoice_line_montant_toutes_taxes = ", str(mycommon.tryFloat(local_retval['order_line_montant_toutes_taxes'])))
print(" ----------- FIN DES LIGNES ")
nb_line = nb_line + 1
line_sum_invoice_line_montant_hors_taxes_after_reduction = line_sum_invoice_line_montant_hors_taxes_before_reduction - line_sum_invoice_line_montant_reduction
"""print(" ###### Apres compute des lignes : NB_LINE = ", nb_line)
print(" ###### line_sum_order_line_montant_reduction = ", line_sum_order_line_montant_reduction)
print(" ###### line_sum_order_line_tax_amount = ", line_sum_order_line_tax_amount)
print(" ###### line_sum_order_line_montant_hors_taxes_before_reduction = ", line_sum_order_line_montant_hors_taxes_before_reduction)
print(" ###### line_sum_order_line_montant_hors_taxes_after_reduction = ", line_sum_order_line_montant_hors_taxes_after_reduction)
print(" ###### line_sum_order_line_montant_toutes_taxes = ", line_sum_order_line_montant_toutes_taxes)
"""
header_reduction_type = ""
header_reduction_type_value = ""
if ("order_header_type_reduction" in Invoice_Data.keys()):
header_reduction_type = Invoice_Data['order_header_type_reduction']
if ("order_header_type_reduction_valeur" in Invoice_Data.keys()):
header_reduction_type_value = Invoice_Data['order_header_type_reduction_valeur']
"""print(" ### les reduction d'entete ")
print(" ###### header_reduction_type = ", header_reduction_type)
print(" ###### header_reduction_type_value = ", header_reduction_type_value)
"""
global_invoice_taxe_amount = 0
global_invoice_amount_ht_before_header_reduction = line_sum_invoice_line_montant_hors_taxes_after_reduction
global_invoice_amount_ht_after_header_reduction = 0
header_reduction_type_value_total_amount = 0
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_invoice_line_montant_hors_taxes_after_reduction - mycommon.tryFloat(
header_reduction_type_value)
"""print(" GRRRR 022 header_reduction_type_value_total_amount = ",
header_reduction_type_value_total_amount)
print(" GRRRR 022 global_order_amount_ht_after_header_reduction = ",
global_order_amount_ht_after_header_reduction)
"""
elif (str(header_reduction_type) == "percent"):
print(" GRRRR line_sum_order_line_montant_hors_taxes_after_reduction = ",
line_sum_invoice_line_montant_hors_taxes_after_reduction)
print(" GRRRR mycommon.tryFloat(header_reduction_type_value)/100 = ",
line_sum_invoice_line_montant_hors_taxes_after_reduction * mycommon.tryFloat(
header_reduction_type_value) / 100)
print(" GRRRR mycommon.tryFloat(header_reduction_type_value)/100 = ",
(line_sum_invoice_line_montant_hors_taxes_after_reduction - (
line_sum_invoice_line_montant_hors_taxes_after_reduction * mycommon.tryFloat(
header_reduction_type_value) / 100)))
header_reduction_type_value_total_amount = line_sum_invoice_line_montant_hors_taxes_after_reduction * mycommon.tryFloat(
header_reduction_type_value) / 100
global_order_amount_ht_after_header_reduction = line_sum_invoice_line_montant_hors_taxes_after_reduction - ((
line_sum_invoice_line_montant_hors_taxes_after_reduction * mycommon.tryFloat(
header_reduction_type_value) / 100))
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_invoice_line_montant_hors_taxes_after_reduction
global_order_amount_ht_after_header_reduction = line_sum_invoice_line_montant_hors_taxes_after_reduction
global_order_amount_ttc = global_order_amount_ht_after_header_reduction * 1.2
"""print(" ###### header_reduction_type_value_total_amount = ", header_reduction_type_value_total_amount)
print(" ###### global_order_amount_ht_before_header_reduction = ", line_sum_order_line_montant_hors_taxes_after_reduction)
print(" ###### global_order_amount_ht_after_header_reduction = ", global_order_amount_ht_after_header_reduction)
print(" ###### global_order_amount_ttc = ", global_order_amount_ttc)
"""
"""
Tous les calculs, ok, on met à l'entete de de l'order
"""
header_computed_data = {}
header_computed_data['total_lines_montant_reduction'] = str(round(line_sum_invoice_line_montant_reduction, 3))
header_computed_data['total_lines_hors_taxe_before_lines_reduction'] = str(
round(line_sum_invoice_line_montant_hors_taxes_before_reduction, 3))
header_computed_data['total_lines_hors_taxe_after_lines_reduction'] = str(
round(line_sum_invoice_line_montant_hors_taxes_after_reduction, 3))
header_computed_data['order_header_montant_reduction'] = str(round(header_reduction_type_value_total_amount, 3))
header_computed_data['total_header_hors_taxe_before_header_reduction'] = str(
round(line_sum_invoice_line_montant_hors_taxes_after_reduction, 3))
header_computed_data['total_header_hors_taxe_after_header_reduction'] = str(
round(global_order_amount_ht_after_header_reduction, 3))
header_computed_data['order_header_tax'] = "TVA " + str(partner_taux_tva) + "%"
header_computed_data['order_header_tax_amount'] = str(round(line_sum_invoice_line_tax_amount, 3))
header_computed_data['total_header_toutes_taxes'] = str(round(global_order_amount_ttc, 3))
header_computed_data['date_update'] = str(datetime.now())
header_computed_data['update_by'] = str(my_partner['recid'])
print(" ### header_computed_data = ", header_computed_data)
local_retval = MYSY_GV.dbname['partner_invoice_header'].find_one_and_update({'_id': ObjectId(str(diction['_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(
my_partner['recid'])},
{"$set": header_computed_data
},
upsert=False,
return_document=ReturnDocument.AFTER
)
if (local_retval is None):
mycommon.myprint(str(inspect.stack()[0][3]) + " Impossible de finaliser la mise à jour")
return False, " Impossible de finaliser la mise à jour "
return True, 'La facture a été correctement recalculée.'
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de recalculer les totaux de la facture "

View File

@ -1011,6 +1011,8 @@ def Add_Partner_Quotation(diction):
data['valide'] = '1'
data['locked'] = '0'
data['date_update'] = str(datetime.now())
data['is_validated'] = '0'
data['update_by'] = str(my_partner['recid'])
#print(" ### add_partner_order data = ", data)
inserted_id = ""
@ -1047,6 +1049,7 @@ def Add_Partner_Quotation(diction):
order_line['partner_owner_recid'] = my_partner['recid']
order_line['order_line_type'] = "devis"
order_line['order_line_status'] = data['order_header_status']
order_line['update_by'] = str(my_partner['recid'])
inserted_line_id = ""
inserted_line_id = MYSY_GV.dbname['partner_order_line'].insert_one(order_line).inserted_id
@ -1467,6 +1470,7 @@ def Update_Partner_Order_Header(diction):
### 1 - Mise à jour de l'entete
data['date_update'] = str(datetime.now())
data['update_by'] = str(my_partner['_id'])
print(" ### Update_partner_order data = ", data)
@ -1933,6 +1937,7 @@ def Update_Partner_Quotation_Header(diction):
### 1 - Mise à jour de l'entete
data['date_update'] = str(datetime.now())
data['update_by'] = str(my_partner['_id'])
print(" ### Update_partner_order data = ", data)
@ -2209,6 +2214,8 @@ def Add_Update_Partner_Order_Line(diction):
return False, "La ligne à mettre à jour est invalide",
data['date_update'] = str(datetime.now())
data['update_by'] = str(my_partner['_id'])
inserted_data = MYSY_GV.dbname['partner_order_line'].find_one_and_update(
{'_id': ObjectId(str(order_line_id)), 'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])},
@ -2229,6 +2236,7 @@ def Add_Update_Partner_Order_Line(diction):
data['locked'] = '0'
data['date_update'] = str(datetime.now())
data['partner_owner_recid'] = my_partner['recid']
data['update_by'] = str(my_partner['_id'])
inserted_line_id = ""
@ -2348,6 +2356,7 @@ def Confirm_Partner_Order_Header_And_Lines(diction):
data = {}
data['date_update'] = str(datetime.now())
data['order_header_status'] = "1"
data['update_by'] = str(my_partner['_id'])
print(" ### Update_partner_order data = ", data)
@ -5403,6 +5412,14 @@ def Convert_Quotation_to_Order(diction):
New_Order_Header['order_header_status'] = "0"
New_Order_Header['token'] = mytoken
"""
Supprimer les data qui ne concernent pas la commande
comme la date de validation du devis, la date reservation, etc
"""
for val in ['is_validated', 'date_reservation', 'mode_reservation', 'validation_by', 'reservation_by', 'date_validation', 'update_by'] :
if( val in New_Order_Header.keys() ):
del New_Order_Header[val]
local_status, local_message, local_retval = Add_Partner_Order(New_Order_Header)
if( local_status is False ):