14/06/2026 - 12h

Signed-off-by: Cherif <cbalde@mysy-training.com>
master_Elyos_FI
Cherif 2026-06-14 11:55:40 +02:00
parent 83e4eee6f2
commit d5700dc6d7
3 changed files with 3029 additions and 79 deletions

View File

@ -4,11 +4,10 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="06/06/2026 - 21h">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="08/06/2026 - 21h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/agenda.py" beforeDir="false" afterPath="$PROJECT_DIR$/agenda.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ent_student_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/ent_student_common.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Relance_client_facture.py" beforeDir="false" afterPath="$PROJECT_DIR$/Relance_client_facture.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -452,7 +451,7 @@
<option name="project" value="LOCAL" />
<updated>1747251650255</updated>
</task>
<option name="localTasksCounter" value="597" />
<option name="localTasksCounter" value="598" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -494,7 +493,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="04/05/2026 - 19h" />
<MESSAGE value="05/05/2026 - 19h" />
<MESSAGE value="07/05/2026 - 17h" />
<MESSAGE value="08/05/2026 - 17h" />
@ -519,6 +517,7 @@
<MESSAGE value="31/05/2026 - 17h00" />
<MESSAGE value="01/06/2026 - 22h00" />
<MESSAGE value="06/06/2026 - 21h" />
<option name="LAST_COMMIT_MESSAGE" value="06/06/2026 - 21h" />
<MESSAGE value="08/06/2026 - 21h" />
<option name="LAST_COMMIT_MESSAGE" value="08/06/2026 - 21h" />
</component>
</project>

File diff suppressed because one or more lines are too long

View File

@ -22,6 +22,7 @@ from datetime import datetime, timezone, date
from xhtml2pdf import pisa
import attached_file_mgt
import prj_common as mycommon
import secrets
import inspect
@ -334,34 +335,12 @@ def Create_Relance_Client_Facture_Given_Client_PDF(diction):
# close output file
resultFile.close()
"""
Mettre à jour la relance des factures
"""
todays_date_heure = datetime.now().strftime("%d/%m/%Y %H:%M")
for fact in tab_invoice_a_relancer:
new_data = {}
new_data['date_relance'] = str(todays_date_heure)
new_data['relance_id'] = "xxx"
create = MYSY_GV.dbname['partner_invoice_header'].update_one({
'_id': ObjectId(str(fact['invoice_id'])),
'partner_owner_recid': str(my_partner['recid']),
},
{
'$push': {
"tab_relance": {
'$each': [new_data]
}
}
},
)
"""
Inserter la relantion dans la collection : 'relance_client_invoice'
Inserter la relance dans la collection : 'relance_client_invoice'
"""
new_relance_data = {}
new_relance_data['clien_id'] = diction['client_id']
new_relance_data['client_id'] = diction['client_id']
new_relance_data['tab_invoice'] = tab_invoice_a_relancer
new_relance_data['relance_date'] = str(datetime.now().strftime("%d/%m/%Y %H:%M"))
new_relance_data['relance_level'] = str(new_relance_level)
@ -373,32 +352,95 @@ def Create_Relance_Client_Facture_Given_Client_PDF(diction):
new_relance_data['update_by'] = str(my_partner['_id'])
new_relance_data['valide'] = "1"
new_relance_data['locked'] = "0"
new_relance_data['mode_envoi'] = "pdf"
MYSY_GV.dbname['relance_client_invoice'].insert_one(new_relance_data)
relance_insert = MYSY_GV.dbname['relance_client_invoice'].insert_one(new_relance_data)
if( relance_insert and relance_insert.inserted_id):
"""
Mettre à jour la relance des factures
"""
todays_date_heure = datetime.now().strftime("%d/%m/%Y %H:%M")
for fact in tab_invoice_a_relancer:
new_data = {}
new_data['date_relance'] = str(todays_date_heure)
new_data['relance_id'] = str(relance_insert.inserted_id)
create = MYSY_GV.dbname['partner_invoice_header'].update_one({
'_id': ObjectId(str(fact['invoice_id'])),
'partner_owner_recid': str(my_partner['recid']),
},
{
'$push': {
"tab_relance": {
'$each': [new_data]
}
}
},
)
"""
Aller stocker le document PDF de relance et le rattacher a la relance
"""
saved_outputFilename = outputFilename
if (orig_file_name and outputFilename):
new_file = {}
new_file['token'] = diction['token']
type_document = "relance_facture"
new_file['file_business_object'] = str(orig_file_name)
new_file['file_name'] = str(orig_file_name)
new_file['status'] = "1"
new_file['type_document'] = str(type_document)
new_file['object_owner_collection'] = "partner_client"
new_file['object_owner_id'] = str(diction['client_id'])
new_file['file_name_to_store'] = outputFilename
tab_key_word = ""
new_file['tab_key_word'] = tab_key_word
tab_related_collection = []
node_class = {}
node_class['related_collection'] = 'relance_client_invoice'
node_class['related_collection_id'] = str(relance_insert.inserted_id)
tab_related_collection.append(node_class)
"""
# Ajout de l'evenement sur la fiche client
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
history_event_dict = {}
history_event_dict['token'] = diction['token']
history_event_dict['related_collection'] = "partnair_account"
history_event_dict['related_collection_recid'] = str(diction['client_id'])
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Relance facture client "
print(" ### new_file new_file = ", new_file)
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
local_status, local_retval = attached_file_mgt.Internal_Usage_Store_User_Downloaded_File(
MYSY_GV.upload_folder, new_file, tab_related_collection)
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
if (local_status is False):
print(" ## WARINNGGG Impossible de stocker le fichier de Convocation ")
if(local_retval ):
saved_outputFilename = local_retval
"""
# Ajout de l'evenement sur la fiche client
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
history_event_dict = {}
history_event_dict['token'] = diction['token']
history_event_dict['related_collection'] = "partnair_account"
history_event_dict['related_collection_recid'] = str(diction['client_id'])
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Relance facture client _id = "+str(str(relance_insert.inserted_id))
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
# print(" ### outputFilename = "+str(outputFilename))
if os.path.exists(outputFilename):
print(" ### ok os.path.exists(outputFilename) "+str(outputFilename))
return True, send_file(outputFilename, as_attachment=True)
if os.path.exists(saved_outputFilename):
print(" ### ok os.path.exists(outputFilename) "+str(saved_outputFilename))
return True, send_file(saved_outputFilename, as_attachment=True)
# return True on success and False on errors
print(pisaStatus.err, type(pisaStatus.err))
@ -862,35 +904,11 @@ def Create_Relance_Client_Facture_Given_Client_Email(tab_files, Folder, diction)
################################
"""
Mettre à jour la relance des factures
"""
todays_date_heure = datetime.now().strftime("%d/%m/%Y %H:%M")
for fact in tab_invoice_a_relancer:
new_data = {}
new_data['date_relance'] = str(todays_date_heure)
new_data['relance_id'] = "xxx"
create = MYSY_GV.dbname['partner_invoice_header'].update_one({
'_id': ObjectId(str(fact['invoice_id'])),
'partner_owner_recid': str(my_partner['recid']),
},
{
'$push': {
"tab_relance": {
'$each': [new_data]
}
}
},
)
"""
Inserter la relantion dans la collection : 'relance_client_invoice'
"""
new_relance_data = {}
new_relance_data['clien_id'] = diction['client_id']
new_relance_data['client_id'] = diction['client_id']
new_relance_data['tab_invoice'] = tab_invoice_a_relancer
new_relance_data['relance_date'] = str(datetime.now().strftime("%d/%m/%Y %H:%M"))
new_relance_data['relance_level'] = str(new_relance_level)
@ -902,8 +920,73 @@ def Create_Relance_Client_Facture_Given_Client_Email(tab_files, Folder, diction)
new_relance_data['update_by'] = str(my_partner['_id'])
new_relance_data['valide'] = "1"
new_relance_data['locked'] = "0"
new_relance_data['mode_envoi'] = "email"
relance_insert = MYSY_GV.dbname['relance_client_invoice'].insert_one(new_relance_data)
if (relance_insert and relance_insert.inserted_id):
"""
Mettre à jour la relance des factures
"""
todays_date_heure = datetime.now().strftime("%d/%m/%Y %H:%M")
for fact in tab_invoice_a_relancer:
new_data = {}
new_data['date_relance'] = str(todays_date_heure)
new_data['relance_id'] = str(relance_insert.inserted_id)
create = MYSY_GV.dbname['partner_invoice_header'].update_one({
'_id': ObjectId(str(fact['invoice_id'])),
'partner_owner_recid': str(my_partner['recid']),
},
{
'$push': {
"tab_relance": {
'$each': [new_data]
}
}
},
)
"""
Aller stocker le document PDF de relance et le rattacher a la relance
"""
saved_outputFilename = outputFilename
if (orig_file_name and outputFilename):
new_file = {}
new_file['token'] = diction['token']
type_document = "relance_facture"
new_file['file_business_object'] = str(orig_file_name)
new_file['file_name'] = str(orig_file_name)
new_file['status'] = "1"
new_file['type_document'] = str(type_document)
new_file['object_owner_collection'] = "partner_client"
new_file['object_owner_id'] = str(diction['client_id'])
new_file['file_name_to_store'] = outputFilename
tab_key_word = ""
new_file['tab_key_word'] = tab_key_word
tab_related_collection = []
node_class = {}
node_class['related_collection'] = 'relance_client_invoice'
node_class['related_collection_id'] = str(relance_insert.inserted_id)
tab_related_collection.append(node_class)
#print(" ### new_file new_file = ", new_file)
local_status, local_retval = attached_file_mgt.Internal_Usage_Store_User_Downloaded_File(
MYSY_GV.upload_folder, new_file, tab_related_collection)
if (local_status is False):
print(" ## WARINNGGG Impossible de stocker le fichier de Convocation ")
if (local_retval):
saved_outputFilename = local_retval
MYSY_GV.dbname['relance_client_invoice'].insert_one(new_relance_data)
"""
@ -1003,11 +1086,13 @@ def Get_List_Relance_with_filter(diction):
for tmp in MYSY_GV.dbname['partner_client'].find(local_myquery_gle):
tab_client_id.append(str(tmp['_id']))
if ("client_id" in diction.keys() and diction['client_id']):
if (diction['client_id'] not in tab_client_id):
tab_client_id.append(str(diction['client_id']))
filt_gle_client = {'client_id': {'$in': tab_client_id}}
if ("client_id" in diction.keys() and diction['client_id']):
if (diction['client_id'] not in tab_client_id):
tab_client_id.append(str(diction['client_id']))
filt_gle_client = {'client_id': {'$in': tab_client_id}}
filter_invoice_id = {}
if ("invoice_id" in diction.keys() and diction['invoice_id']):
@ -1021,13 +1106,55 @@ def Get_List_Relance_with_filter(diction):
'locked': '0'},
filter_invoice_id, filter_invoice_ref, filt_gle_client]}
print(" ### relance list : qery_match = ", qery_match)
#print(" ### relance list : qery_match = ", qery_match)
RetObject = []
val_tmp = 0
for New_retVal in MYSY_GV.dbname['relance_client_invoice'].find(qery_match).sort([("_id", pymongo.DESCENDING), ]):
user = New_retVal
user['id'] = str(val_tmp)
if( "mode_envoi" not in user.keys() ):
user['mode_envoi'] = ""
strored_document_id = ""
strored_document_file_extention = ""
strored_document_file_business_object = ""
"""
Aller recuperer l'_id du document de relance associé
"""
qry_get_document = {}
qry_get_document['type_document'] = "relance_facture"
qry_get_document['partner_owner_recid'] = str(my_partner['recid'])
qry_get_document['valide'] = "1"
qry_get_document['locked'] = "0"
qry_get_document['tab_related_collection'] = {
'$elemMatch': {
'related_collection': "relance_client_invoice",
'related_collection_id': str(user['_id'])
}
}
#print(" QRY gry download_files_relance = ", qry_get_document)
download_files_relance = MYSY_GV.dbname['download_files'].find_one(qry_get_document, {'_id':1, 'file_extention':1, 'file_business_object':1})
if( download_files_relance and '_id' in download_files_relance.keys()):
strored_document_id = str(download_files_relance['_id'])
if (download_files_relance and 'file_extention' in download_files_relance.keys()):
strored_document_file_extention = str(download_files_relance['file_extention'])
if (download_files_relance and 'file_business_object' in download_files_relance.keys()):
strored_document_file_business_object = str(download_files_relance['file_business_object'])
user['stored_document_id'] = str(strored_document_id)
user['strored_document_file_extention'] = str(strored_document_file_extention)
user['strored_document_file_business_object'] = str(strored_document_file_business_object)
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))