qsdsqsqdsq
parent
3b4a771d8b
commit
946f6e6289
|
@ -3,9 +3,13 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="qsdsq">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/E_Sign_Document.py" beforeDir="false" afterPath="$PROJECT_DIR$/E_Sign_Document.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$/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" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -75,13 +79,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00273" summary="20/04/2024 - 20h44">
|
||||
<created>1713638681958</created>
|
||||
<option name="number" value="00273" />
|
||||
<option name="presentableId" value="LOCAL-00273" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1713638681959</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00274" summary="sss">
|
||||
<created>1713719597944</created>
|
||||
<option name="number" value="00274" />
|
||||
|
@ -418,7 +415,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1717533847419</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="322" />
|
||||
<task id="LOCAL-00322" summary="qsdsq">
|
||||
<created>1717577652189</created>
|
||||
<option name="number" value="00322" />
|
||||
<option name="presentableId" value="LOCAL-00322" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1717577652191</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="323" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
|
|
@ -532,6 +532,8 @@ Signature du document
|
|||
"""
|
||||
def Create_E_Signature_For_E_Document(file_img=None, Folder=None, diction=None):
|
||||
try:
|
||||
|
||||
print(" GRR diction = ", diction)
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
|
@ -840,7 +842,9 @@ def Create_E_Signature_For_E_Document(file_img=None, Folder=None, diction=None):
|
|||
|
||||
"""
|
||||
On envoie le mail avec le document signé
|
||||
|
||||
"""
|
||||
|
||||
# Traitement de l'eventuel fichier joint
|
||||
tab_files_to_attache_to_mail = []
|
||||
|
||||
|
@ -1484,6 +1488,7 @@ def Get_Given_E_Document_Signed_No_Token(diction):
|
|||
'statut': '1',
|
||||
'partner_owner_recid':str(diction['partner_owner_recid']),}
|
||||
|
||||
print(" Get_Given_E_Document_Signed_No_Token qry = ", qry)
|
||||
for New_retVal in MYSY_GV.dbname['e_document_signe'].find(qry, {'_id':1, 'document_data_signed':1}).sort([("_id", pymongo.DESCENDING), ]):
|
||||
user = New_retVal
|
||||
user['id'] = str(val_tmp)
|
||||
|
|
3616
Log/log_file.log
3616
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -18,6 +18,7 @@ from datetime import datetime, date
|
|||
from xhtml2pdf import pisa
|
||||
|
||||
import Contact
|
||||
import E_Sign_Document
|
||||
import Session_Formation_Sequence
|
||||
import attached_file_mgt
|
||||
import module_editique
|
||||
|
@ -9692,7 +9693,7 @@ def Prepare_and_Send_Facture_From_Session_By_Inscription_Id_SAVE_ORIG(tab_files,
|
|||
|
||||
|
||||
"""
|
||||
Creation des factures pour un client avec uniquement la liste des inscriptions concernée.
|
||||
Creation des factures pour un client avec uniquement la liste des inscriptions concernées.
|
||||
|
||||
Ex : je veux facturer que 2 des 5 inscrits d'un client donné.
|
||||
"""
|
||||
|
@ -10064,6 +10065,20 @@ def Invoice_Partner_From_Session_By_Inscription_Id( diction):
|
|||
return False, " Facture : Impossible de créer les lignes de la facture "+str(partner_invoice_header_data['invoice_header_ref_interne']), False
|
||||
|
||||
|
||||
"""
|
||||
05/06/2024 Gestion E-Facture
|
||||
Apres la creation de la facture, on va aller créer le document securisé
|
||||
"""
|
||||
e_Invoice_Diction = {}
|
||||
e_Invoice_Diction['token'] = diction['token']
|
||||
e_Invoice_Diction['invoice_id'] = str(inserted_invoice_id)
|
||||
|
||||
|
||||
local_E_Invoice_status, local_E_Invoice_retval = Invoice_Create_Secure_E_Document(e_Invoice_Diction)
|
||||
if( local_E_Invoice_status is False ):
|
||||
return True, "WARNING : L'email a été correctement envoyé ", str(
|
||||
partner_invoice_header_data['invoice_header_ref_interne']+"; mais impossible de créer la e-Facture Sécurisée.")
|
||||
|
||||
return True, "L'email a été correctement envoyé ", str(partner_invoice_header_data['invoice_header_ref_interne'])
|
||||
|
||||
except Exception as e:
|
||||
|
@ -10073,6 +10088,385 @@ def Invoice_Partner_From_Session_By_Inscription_Id( diction):
|
|||
|
||||
|
||||
|
||||
"""
|
||||
05/06/2024 - Gestion des factures securisée
|
||||
A la creation d'une facture, on va aller créer un document sécurisé dans la collection "e_document_signe"
|
||||
en utilisant le modelè de courrier pdf
|
||||
|
||||
en suite, on ajoute à la collection "invoice_hader", l'_id du document securisé.
|
||||
Par la suite lorsqu'un utisateur imprime ou reimprime une facture, le va aller regarder
|
||||
si il y a un document securisé associé, si oui il recuper ce donc, si non, il imprime la facture comme cela se fait aujourd'hui
|
||||
|
||||
"""
|
||||
def Invoice_Create_Secure_E_Document(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'invoice_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'est pas autorisé")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'invoice_id']
|
||||
|
||||
"""
|
||||
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
|
||||
|
||||
|
||||
"""
|
||||
Verifier que la facture est valide
|
||||
"""
|
||||
is_invoice_valide = MYSY_GV.dbname['partner_invoice_header'].count_documents({'_id':ObjectId(str(diction['invoice_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_invoice_valide != 1):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " L'identifiant de la facture est invalide ")
|
||||
return False, " L'identifiant de la facture est invalide "
|
||||
|
||||
|
||||
Order_header_data = MYSY_GV.dbname['partner_invoice_header'].find_one(
|
||||
{'_id': ObjectId(str(diction['invoice_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
"""
|
||||
Recuperer du modèle de document
|
||||
"""
|
||||
partner_document_PART_INVOICE_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0', 'ref_interne': 'PART_INVOICE',
|
||||
'type_doc': 'pdf'})
|
||||
|
||||
if (partner_document_PART_INVOICE_data is None):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Aucun modèle de courrier 'PART_INVOICE' n'est configuré pour le partenaire ")
|
||||
return False, " Aucun modèle de courrier 'PART_INVOICE' n'est configuré pour le partenaire "
|
||||
|
||||
|
||||
|
||||
e_document_id = ""
|
||||
# Recuperation des données du client
|
||||
if ("order_header_client_id" in Order_header_data.keys()):
|
||||
Order_header_client_data = MYSY_GV.dbname['partner_client'].find_one(
|
||||
{'_id': ObjectId(str(Order_header_data['order_header_client_id'])),
|
||||
'partner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0'})
|
||||
|
||||
if (Order_header_client_data is None):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le client est invalide")
|
||||
return False, " Le client est invalide"
|
||||
|
||||
### Ajout des données du client sur l'entete de la commande, exemple : le nom, email, etc
|
||||
if ("raison_sociale" in Order_header_client_data.keys()):
|
||||
Order_header_data['client_raison_sociale'] = Order_header_client_data['raison_sociale']
|
||||
|
||||
if ("nom" in Order_header_client_data.keys()):
|
||||
Order_header_data['client_nom'] = Order_header_client_data['nom']
|
||||
|
||||
if ("email" in Order_header_client_data.keys()):
|
||||
Order_header_data['client_email'] = Order_header_client_data['email']
|
||||
|
||||
# Ajout d'un parametre pour le data time du jour de l'edition (c'est une data static qui peut servir pour l'horodatage
|
||||
Order_header_data['current_date_time'] = str(datetime.now().strftime("%d/%m/%Y, %H:%M:%S"))
|
||||
|
||||
# Recuperation des details de lignes de : partner_invoice_line
|
||||
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
|
||||
filt_order_header_order_id = {'invoice_header_id': str(diction['invoice_id'])}
|
||||
|
||||
query = [{'$match': {'$and': [filt_order_header_order_id,
|
||||
{'partner_owner_recid': str(my_partner['recid'])}]}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'myclass',
|
||||
'localField': 'order_line_formation',
|
||||
'foreignField': 'internal_url',
|
||||
'pipeline': [{'$match': {'$and': [filt_class_partner_recid]}},
|
||||
{'$project': {'title': 1, 'domaine': 1,
|
||||
'duration': 1,
|
||||
'duration_unit': 1,
|
||||
'external_code': 1}}],
|
||||
'as': 'myclass_collection'
|
||||
}
|
||||
}
|
||||
]
|
||||
# print("#### Get_Given_Partner_Order_Lines_From_order_ref_interne : query pip= ", query)
|
||||
val_tmp = 0
|
||||
Order_header_lines_data = []
|
||||
for retval in MYSY_GV.dbname['partner_invoice_line'].aggregate(query):
|
||||
if ('myclass_collection' in retval.keys() and len(retval['myclass_collection']) > 0):
|
||||
user = {}
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
user['_id'] = retval['_id']
|
||||
user['order_line_formation'] = retval['order_line_formation']
|
||||
user['order_line_qty'] = retval['order_line_qty']
|
||||
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
|
||||
user['order_header_id'] = retval['order_header_id']
|
||||
user['order_header_ref_interne'] = retval['order_header_ref_interne']
|
||||
user['invoice_header_ref_interne'] = retval['invoice_header_ref_interne']
|
||||
user['invoice_line_type'] = retval['invoice_line_type']
|
||||
user['invoice_date'] = retval['invoice_date']
|
||||
|
||||
user['valide'] = retval['valide']
|
||||
user['locked'] = retval['locked']
|
||||
|
||||
if ("order_line_montant_reduction" in retval.keys()):
|
||||
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = "0"
|
||||
|
||||
if ("order_line_montant_toutes_taxes" in retval.keys()):
|
||||
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
|
||||
else:
|
||||
user['order_line_montant_toutes_taxes'] = "0"
|
||||
|
||||
if ("order_line_tax" in retval.keys()):
|
||||
user['order_line_tax'] = retval['order_line_tax']
|
||||
else:
|
||||
user['order_line_tax'] = ""
|
||||
|
||||
if ("order_line_tax_amount" in retval.keys()):
|
||||
user['order_line_tax_amount'] = retval['order_line_tax_amount']
|
||||
else:
|
||||
user['order_line_tax_amount'] = "0"
|
||||
|
||||
if ("order_line_type_reduction" in retval.keys()):
|
||||
user['order_line_type_reduction'] = retval['order_line_type_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = ""
|
||||
|
||||
if ("order_line_type_valeur" in retval.keys()):
|
||||
user['order_line_type_valeur'] = retval['order_line_type_valeur']
|
||||
else:
|
||||
user['order_line_type_valeur'] = "0"
|
||||
|
||||
if ("order_line_montant_hors_taxes" in retval.keys()):
|
||||
user['order_line_montant_hors_taxes'] = retval['order_line_montant_hors_taxes']
|
||||
else:
|
||||
user['order_line_montant_hors_taxes'] = "0"
|
||||
|
||||
user['date_update'] = retval['date_update']
|
||||
user['update_by'] = str(my_partner['_id'])
|
||||
user['partner_owner_recid'] = retval['partner_owner_recid']
|
||||
|
||||
if ("order_line_comment" in retval.keys()):
|
||||
user['order_line_comment'] = retval['order_line_comment']
|
||||
else:
|
||||
user['order_line_comment'] = ""
|
||||
|
||||
user['title'] = retval['myclass_collection'][0]['title']
|
||||
user['order_line_formation_external_code'] = retval['myclass_collection'][0]['external_code']
|
||||
|
||||
if ("domaine" in retval['myclass_collection'][0].keys()):
|
||||
user['domaine'] = retval['myclass_collection'][0]['domaine']
|
||||
else:
|
||||
user['domaine'] = ""
|
||||
|
||||
user['duration'] = retval['myclass_collection'][0]['duration']
|
||||
user['duration_unit'] = retval['myclass_collection'][0]['duration_unit']
|
||||
|
||||
if (str(retval['myclass_collection'][0]['duration_unit']) == "heure"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " h"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "jour"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " j"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "semaine"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " s"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "mois"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " m"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "annee"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " a"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "user_rythme"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " u"
|
||||
|
||||
else:
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " ?"
|
||||
|
||||
Order_header_lines_data.append(user)
|
||||
|
||||
if (len(Order_header_lines_data) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Aucune ligne de détail pour cette facture ")
|
||||
return False, " Aucune ligne de détail pour cette facture "
|
||||
|
||||
# print(" ### Order_header_lines_data = ", Order_header_lines_data)
|
||||
|
||||
contenu_doc_Template = jinja2.Template(str(partner_document_PART_INVOICE_data['contenu_doc']))
|
||||
|
||||
# sourceHtml = contenu_doc_Template.render(params=Order_header_data)
|
||||
|
||||
# print(" ### Order_header_data = ", Order_header_data)
|
||||
# print(" ### Order_header_lines_data = ", Order_header_lines_data)
|
||||
|
||||
"""
|
||||
Recuperation du dictionnaire des info
|
||||
"""
|
||||
tab_client = []
|
||||
tab_client.append(ObjectId(str(Order_header_client_data['_id'])))
|
||||
|
||||
new_diction = {}
|
||||
new_diction['token'] = diction['token']
|
||||
new_diction['list_stagiaire_id'] = []
|
||||
new_diction['list_session_id'] = []
|
||||
new_diction['list_class_id'] = []
|
||||
new_diction['list_client_id'] = tab_client
|
||||
new_diction['list_apprenant_id'] = []
|
||||
|
||||
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
|
||||
|
||||
if (local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
convention_dictionnary_data = local_retval
|
||||
company_data = {
|
||||
"params": convention_dictionnary_data,
|
||||
}
|
||||
|
||||
convention_dictionnary_data['order_header'] = Order_header_data
|
||||
convention_dictionnary_data['order_lines'] = Order_header_lines_data
|
||||
|
||||
# sourceHtml = contenu_doc_Template.render(params=Order_header_data, param_order_lines=Order_header_lines_data, company_data=company_data)
|
||||
|
||||
# sourceHtml = contenu_doc_Template.render(params_order_header=Order_header_data, params_order_lines=Order_header_lines_data, params=company_data['params'])
|
||||
|
||||
sourceHtml = contenu_doc_Template.render(params=company_data['params'])
|
||||
|
||||
orig_file_name = "Partner_Invoice_" + str(Order_header_data['invoice_header_ref_interne']) + ".pdf"
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
|
||||
|
||||
# open output file for writing (truncated binary)
|
||||
resultFile = open(outputFilename, "w+b")
|
||||
|
||||
# convert HTML to PDF
|
||||
pisaStatus = pisa.CreatePDF(
|
||||
src=sourceHtml, # the HTML to convert
|
||||
dest=resultFile) # file handle to receive result
|
||||
|
||||
# close output file
|
||||
resultFile.close()
|
||||
|
||||
|
||||
|
||||
new_model_courrier_with_code_tag = " <div style='width: 100%'> <div style = 'width: 100%; text-align: center;' >" \
|
||||
" <img style = 'height:60px; width:60px;' src = '{{ params.mysy_qrcode_securite }}' > <br/>" \
|
||||
" <nav style = 'font-size: 10px; font-style: italic;' > Sécurisé par MySy Training Technology </nav>" \
|
||||
" <br/> </div> </div>" + \
|
||||
str(sourceHtml)
|
||||
|
||||
|
||||
new_e_document_diction = {}
|
||||
new_e_document_diction['token'] = diction['token']
|
||||
new_e_document_diction['file_name'] = outputFilename
|
||||
toaddrs = "contact@mysy-training.com"
|
||||
new_e_document_diction['email_destinataire'] = str(toaddrs)
|
||||
new_e_document_diction['source_document'] = new_model_courrier_with_code_tag
|
||||
|
||||
new_e_document_diction['type'] = "invoice"
|
||||
new_e_document_diction['related_collection'] = "partner_invoice_header"
|
||||
new_e_document_diction['related_collection_id'] = str(Order_header_data['_id'])
|
||||
|
||||
if ("order_header_ref_interne" in Order_header_data.keys()):
|
||||
new_e_document_diction['file_cononical_name'] = str(Order_header_data['invoice_header_ref_interne'])
|
||||
else:
|
||||
new_e_document_diction['file_cononical_name'] = ""
|
||||
|
||||
local_status_e_doc, local_retval_e_doc = E_Sign_Document.Create_E_Document(new_e_document_diction)
|
||||
|
||||
if (local_status_e_doc is False):
|
||||
return local_status_e_doc, local_retval_e_doc
|
||||
|
||||
e_Invoice_id = str(local_retval_e_doc)
|
||||
|
||||
"""
|
||||
Mettre à jour la facture avec une clé de signature interne car on va pas envoyer
|
||||
une demande pour créer la signature vu qu'on sur un processus interne
|
||||
"""
|
||||
local_signature_key = mycommon.create_user_recid()
|
||||
retval = MYSY_GV.dbname['e_document_signe'].update_one({'_id':ObjectId(str(e_Invoice_id)),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'related_collection':'partner_invoice_header',
|
||||
'related_collection_id':str(Order_header_data['_id'])},
|
||||
{'$set':{'statut':'1',
|
||||
'secret_key_signature':str(local_signature_key)}})
|
||||
|
||||
"""
|
||||
On va auto signer la E-Facture qui a été créée
|
||||
"""
|
||||
new_e_document_diction2 = {}
|
||||
new_e_document_diction2['token'] = str(diction['token'])
|
||||
new_e_document_diction2['e_doc_id'] = str(e_Invoice_id)
|
||||
new_e_document_diction2['secret_key_signature'] = str(local_signature_key)
|
||||
new_e_document_diction2['email_destinataire'] = "contact@mysy-training.com"
|
||||
new_e_document_diction2['user_ip'] = "127.0.0.1"
|
||||
|
||||
print('laaa new_e_document_diction = ', new_e_document_diction2)
|
||||
|
||||
local_status_sign_e_doc, local_retval_sign_e_doc = E_Sign_Document.Create_E_Signature_For_E_Document(None, None, new_e_document_diction2)
|
||||
if( local_status_sign_e_doc is False ):
|
||||
return local_status_sign_e_doc, local_retval_sign_e_doc
|
||||
|
||||
|
||||
"""
|
||||
Mettre à jour la facture pour indiquer 'e_document_signe_id
|
||||
"""
|
||||
|
||||
qry = {'_id':ObjectId(str(diction['invoice_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])}
|
||||
|
||||
update_data = {}
|
||||
update_data['e_document_signe_id'] = str(e_Invoice_id)
|
||||
|
||||
ret_val2 = MYSY_GV.dbname['partner_invoice_header'].find_one_and_update(qry,
|
||||
{"$set": update_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
||||
# zzzzz
|
||||
return True, str(local_retval_e_doc)
|
||||
|
||||
|
||||
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 créer la E-Facture "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Audite action session :
|
||||
Cette fonction permet de lister les inscrits pour qui
|
||||
|
|
16
main.py
16
main.py
|
@ -8468,6 +8468,22 @@ def Audit_Session_Action_Inscrit():
|
|||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de créer un e-Facture securisée
|
||||
"""
|
||||
@app.route('/myclass/api/Invoice_Create_Secure_E_Document/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Invoice_Create_Secure_E_Document():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Invoice_Create_Secure_E_Document : payload = ",str(payload))
|
||||
localStatus, message= SF.Invoice_Create_Secure_E_Document(payload)
|
||||
|
||||
print(" ### ENNN Invoice_Create_Secure_E_Document : localStatus = ", str(localStatus), " message = ", message)
|
||||
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
API qui permet de recuperer la liste des niveaux pour les compétences
|
||||
"""
|
||||
|
|
|
@ -15,6 +15,7 @@ from bson import ObjectId
|
|||
import re
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import Session_Formation
|
||||
import invoice_paiement_mgt
|
||||
import partners
|
||||
import prj_common as mycommon
|
||||
|
@ -41,6 +42,7 @@ from email.mime.text import MIMEText
|
|||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
import partner_order as partner_order
|
||||
import base64
|
||||
|
||||
"""
|
||||
Creation de la facture d'un commande
|
||||
|
@ -365,6 +367,17 @@ def Invoice_Partner_Order(diction):
|
|||
str(inspect.stack()[0][
|
||||
3]) + " WARNING - Impossible de mettre les lignes à facturer pour order_header_id = "+str(str(diction['order_id'])))
|
||||
|
||||
"""
|
||||
05/06/2024 Gestion E-Facture
|
||||
Apres la creation de la facture, on va aller créer le document securisé
|
||||
"""
|
||||
e_Invoice_Diction = {}
|
||||
e_Invoice_Diction['token'] = diction['token']
|
||||
e_Invoice_Diction['invoice_id'] = str(inserted_invoice_id)
|
||||
|
||||
local_E_Invoice_status, local_E_Invoice_retval = Session_Formation.Invoice_Create_Secure_E_Document(e_Invoice_Diction)
|
||||
if (local_E_Invoice_status is False):
|
||||
return True, "WARNING : La facture a été créée avec la réf. "+str(new_invoice_data_header['invoice_header_ref_interne'])+"; mais impossible de créer la e-Facture Sécurisée.", str(new_invoice_data_header['invoice_header_ref_interne'])
|
||||
|
||||
|
||||
return True, " La commande a été correctement facturée", str(new_invoice_data_header['invoice_header_ref_interne'])
|
||||
|
@ -1441,6 +1454,10 @@ def Get_Given_Line_Of_Partner_Invoice_Lines(diction):
|
|||
|
||||
"""
|
||||
Impression PDF d'une facture
|
||||
/!\ : update du 05/06/2024 :
|
||||
Si la facture a un document sécurisée (e_Invoice) associé dans la colonne :
|
||||
'e_document_signe_id', alors on va aller recuperer le document securisé associé
|
||||
|
||||
"""
|
||||
|
||||
def GerneratePDF_Partner_Invoice(diction):
|
||||
|
@ -1494,249 +1511,303 @@ def GerneratePDF_Partner_Invoice(diction):
|
|||
'partner_owner_recid': str(
|
||||
my_partner['recid'])})
|
||||
|
||||
partner_document_INVOICE_data_qry = {'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0', 'ref_interne': 'PART_INVOICE', 'type_doc':'pdf'}
|
||||
|
||||
print(" ### partner_document_INVOICE_data_qry = ", partner_document_INVOICE_data_qry)
|
||||
partner_document_INVOICE_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0', 'ref_interne': 'PART_INVOICE', 'type_doc':'pdf'})
|
||||
if( "e_document_signe_id" in Order_header_data.keys() and Order_header_data['e_document_signe_id'] ):
|
||||
# On retourne la e_Invoice securisée
|
||||
|
||||
if (partner_document_INVOICE_data is None):
|
||||
# Il n'existe pas de personnalisation de la preinscription pour ce partenaire, on va aller récupérer la presinscription pa defaut
|
||||
print(" #### RECUPERATION DU FICHIER SECURISE ")
|
||||
qry = {'_id':ObjectId(str(Order_header_data['e_document_signe_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'statut':'1',
|
||||
'related_collection':'partner_invoice_header',
|
||||
'related_collection_id':str(Order_header_data['_id']),
|
||||
'partner_owner_recid':str(my_partner['recid'])}
|
||||
|
||||
print(" qry = ", qry)
|
||||
e_Invoice_Secure_Data = MYSY_GV.dbname['e_document_signe'].find_one({'_id':ObjectId(str(Order_header_data['e_document_signe_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'statut':'1',
|
||||
'related_collection':'partner_invoice_header',
|
||||
'related_collection_id':str(Order_header_data['_id']),
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if(e_Invoice_Secure_Data is None ):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " Le document sécurisé associé à la facture est invalide 'e_document_signe_id' = ",
|
||||
str(Order_header_data['e_document_signe_id']))
|
||||
|
||||
return False, " Le document sécurisé associé à la facture est invalide "
|
||||
|
||||
orig_file_name = "Partner_Invoice_" + str(Order_header_data['invoice_header_ref_interne']) + ".pdf"
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
|
||||
|
||||
|
||||
# open output file for writing (truncated binary)
|
||||
with open(outputFilename, 'w+b') as resultFile:
|
||||
encoded = base64.b64encode(e_Invoice_Secure_Data['document_data_signed'])
|
||||
decode_data = e_Invoice_Secure_Data['document_data_signed'].decode()
|
||||
bytes = base64.b64decode(decode_data, validate=True)
|
||||
resultFile.write(bytes)
|
||||
|
||||
|
||||
# close output file
|
||||
resultFile.close()
|
||||
|
||||
# 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)
|
||||
|
||||
|
||||
return True, " le fichier securisé recuperé "
|
||||
|
||||
|
||||
else:
|
||||
partner_document_INVOICE_data_qry = {'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0', 'ref_interne': 'PART_INVOICE', 'type_doc':'pdf'}
|
||||
|
||||
print(" ### partner_document_INVOICE_data_qry = ", partner_document_INVOICE_data_qry)
|
||||
partner_document_INVOICE_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'partner_owner_recid': 'default',
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0', 'ref_interne': 'PART_INVOICE', 'type_doc':'pdf'})
|
||||
|
||||
if (partner_document_INVOICE_data is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + "Aucun document parametré ")
|
||||
return False, "Aucun document parametré "
|
||||
if (partner_document_INVOICE_data is None):
|
||||
# Il n'existe pas de personnalisation de la preinscription pour ce partenaire, on va aller récupérer la presinscription pa defaut
|
||||
partner_document_INVOICE_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'partner_owner_recid': 'default',
|
||||
'valide': '1', 'locked': '0', 'ref_interne': 'PART_INVOICE', 'type_doc':'pdf'})
|
||||
|
||||
if ("contenu_doc" not in partner_document_INVOICE_data or len(
|
||||
str(partner_document_INVOICE_data['contenu_doc'])) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le parametrage du document est invalide")
|
||||
return False, " Le parametrage du document est invalide "
|
||||
if (partner_document_INVOICE_data is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + "Aucun document parametré ")
|
||||
return False, "Aucun document parametré "
|
||||
|
||||
# Recuperation des données du client
|
||||
if ("order_header_client_id" in Order_header_data.keys()):
|
||||
Order_header_client_data = MYSY_GV.dbname['partner_client'].find_one(
|
||||
{'_id': ObjectId(str(Order_header_data['order_header_client_id'])),
|
||||
'partner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0'})
|
||||
|
||||
if (Order_header_client_data is None):
|
||||
if ("contenu_doc" not in partner_document_INVOICE_data or len(
|
||||
str(partner_document_INVOICE_data['contenu_doc'])) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le client est invalide")
|
||||
return False, " Le client est invalide"
|
||||
3]) + " - Le parametrage du document est invalide")
|
||||
return False, " Le parametrage du document est invalide "
|
||||
|
||||
### Ajout des données du client sur l'entete de la commande, exemple : le nom, email, etc
|
||||
if("raison_sociale" in Order_header_client_data.keys() ):
|
||||
Order_header_data['client_raison_sociale'] = Order_header_client_data['raison_sociale']
|
||||
# Recuperation des données du client
|
||||
if ("order_header_client_id" in Order_header_data.keys()):
|
||||
Order_header_client_data = MYSY_GV.dbname['partner_client'].find_one(
|
||||
{'_id': ObjectId(str(Order_header_data['order_header_client_id'])),
|
||||
'partner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0'})
|
||||
|
||||
if ("nom" in Order_header_client_data.keys()):
|
||||
Order_header_data['client_nom'] = Order_header_client_data['nom']
|
||||
if (Order_header_client_data is None):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le client est invalide")
|
||||
return False, " Le client est invalide"
|
||||
|
||||
if ("email" in Order_header_client_data.keys()):
|
||||
Order_header_data['client_email'] = Order_header_client_data['email']
|
||||
### Ajout des données du client sur l'entete de la commande, exemple : le nom, email, etc
|
||||
if("raison_sociale" in Order_header_client_data.keys() ):
|
||||
Order_header_data['client_raison_sociale'] = Order_header_client_data['raison_sociale']
|
||||
|
||||
# Ajout d'un parametre pour le data time du jour de l'edition (c'est une data static qui peut servir pour l'horodatage
|
||||
Order_header_data['current_date_time'] = str(datetime.now().strftime("%d/%m/%Y, %H:%M:%S") )
|
||||
if ("nom" in Order_header_client_data.keys()):
|
||||
Order_header_data['client_nom'] = Order_header_client_data['nom']
|
||||
|
||||
if ("email" in Order_header_client_data.keys()):
|
||||
Order_header_data['client_email'] = Order_header_client_data['email']
|
||||
|
||||
# Ajout d'un parametre pour le data time du jour de l'edition (c'est une data static qui peut servir pour l'horodatage
|
||||
Order_header_data['current_date_time'] = str(datetime.now().strftime("%d/%m/%Y, %H:%M:%S") )
|
||||
|
||||
|
||||
# Recuperation des details de lignes de : partner_invoice_line
|
||||
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
|
||||
filt_order_header_order_id = {'invoice_header_id': str(diction['invoice_id'])}
|
||||
# Recuperation des details de lignes de : partner_invoice_line
|
||||
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
|
||||
filt_order_header_order_id = {'invoice_header_id': str(diction['invoice_id'])}
|
||||
|
||||
query = [{'$match': {'$and': [filt_order_header_order_id,
|
||||
{'partner_owner_recid': str(my_partner['recid'])}]}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'myclass',
|
||||
'localField': 'order_line_formation',
|
||||
'foreignField': 'internal_url',
|
||||
'pipeline': [{'$match': {'$and': [filt_class_partner_recid]}},
|
||||
{'$project': {'title': 1, 'domaine': 1,
|
||||
'duration': 1,
|
||||
'duration_unit': 1,
|
||||
'external_code':1}}],
|
||||
'as': 'myclass_collection'
|
||||
query = [{'$match': {'$and': [filt_order_header_order_id,
|
||||
{'partner_owner_recid': str(my_partner['recid'])}]}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'myclass',
|
||||
'localField': 'order_line_formation',
|
||||
'foreignField': 'internal_url',
|
||||
'pipeline': [{'$match': {'$and': [filt_class_partner_recid]}},
|
||||
{'$project': {'title': 1, 'domaine': 1,
|
||||
'duration': 1,
|
||||
'duration_unit': 1,
|
||||
'external_code':1}}],
|
||||
'as': 'myclass_collection'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
#print("#### Get_Given_Partner_Order_Lines_From_order_ref_interne : query pip= ", query)
|
||||
val_tmp = 0
|
||||
Order_header_lines_data = []
|
||||
for retval in MYSY_GV.dbname['partner_invoice_line'].aggregate(query):
|
||||
if ('myclass_collection' in retval.keys() and len(retval['myclass_collection']) > 0):
|
||||
user = {}
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
user['_id'] = retval['_id']
|
||||
user['order_line_formation'] = retval['order_line_formation']
|
||||
user['order_line_qty'] = retval['order_line_qty']
|
||||
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
|
||||
user['order_header_id'] = retval['order_header_id']
|
||||
user['order_header_ref_interne'] = retval['order_header_ref_interne']
|
||||
user['invoice_header_ref_interne'] = retval['invoice_header_ref_interne']
|
||||
user['invoice_line_type'] = retval['invoice_line_type']
|
||||
user['invoice_date'] = retval['invoice_date']
|
||||
]
|
||||
#print("#### Get_Given_Partner_Order_Lines_From_order_ref_interne : query pip= ", query)
|
||||
val_tmp = 0
|
||||
Order_header_lines_data = []
|
||||
for retval in MYSY_GV.dbname['partner_invoice_line'].aggregate(query):
|
||||
if ('myclass_collection' in retval.keys() and len(retval['myclass_collection']) > 0):
|
||||
user = {}
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
user['_id'] = retval['_id']
|
||||
user['order_line_formation'] = retval['order_line_formation']
|
||||
user['order_line_qty'] = retval['order_line_qty']
|
||||
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
|
||||
user['order_header_id'] = retval['order_header_id']
|
||||
user['order_header_ref_interne'] = retval['order_header_ref_interne']
|
||||
user['invoice_header_ref_interne'] = retval['invoice_header_ref_interne']
|
||||
user['invoice_line_type'] = retval['invoice_line_type']
|
||||
user['invoice_date'] = retval['invoice_date']
|
||||
|
||||
user['valide'] = retval['valide']
|
||||
user['locked'] = retval['locked']
|
||||
user['valide'] = retval['valide']
|
||||
user['locked'] = retval['locked']
|
||||
|
||||
if ("order_line_montant_reduction" in retval.keys()):
|
||||
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = "0"
|
||||
if ("order_line_montant_reduction" in retval.keys()):
|
||||
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = "0"
|
||||
|
||||
if ("order_line_montant_toutes_taxes" in retval.keys()):
|
||||
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
|
||||
else:
|
||||
user['order_line_montant_toutes_taxes'] = "0"
|
||||
if ("order_line_montant_toutes_taxes" in retval.keys()):
|
||||
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
|
||||
else:
|
||||
user['order_line_montant_toutes_taxes'] = "0"
|
||||
|
||||
if ("order_line_tax" in retval.keys()):
|
||||
user['order_line_tax'] = retval['order_line_tax']
|
||||
else:
|
||||
user['order_line_tax'] = ""
|
||||
if ("order_line_tax" in retval.keys()):
|
||||
user['order_line_tax'] = retval['order_line_tax']
|
||||
else:
|
||||
user['order_line_tax'] = ""
|
||||
|
||||
if ("order_line_tax_amount" in retval.keys()):
|
||||
user['order_line_tax_amount'] = retval['order_line_tax_amount']
|
||||
else:
|
||||
user['order_line_tax_amount'] = "0"
|
||||
if ("order_line_tax_amount" in retval.keys()):
|
||||
user['order_line_tax_amount'] = retval['order_line_tax_amount']
|
||||
else:
|
||||
user['order_line_tax_amount'] = "0"
|
||||
|
||||
if ("order_line_type_reduction" in retval.keys()):
|
||||
user['order_line_type_reduction'] = retval['order_line_type_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = ""
|
||||
if ("order_line_type_reduction" in retval.keys()):
|
||||
user['order_line_type_reduction'] = retval['order_line_type_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = ""
|
||||
|
||||
if ("order_line_type_valeur" in retval.keys()):
|
||||
user['order_line_type_valeur'] = retval['order_line_type_valeur']
|
||||
else:
|
||||
user['order_line_type_valeur'] = "0"
|
||||
if ("order_line_type_valeur" in retval.keys()):
|
||||
user['order_line_type_valeur'] = retval['order_line_type_valeur']
|
||||
else:
|
||||
user['order_line_type_valeur'] = "0"
|
||||
|
||||
if ("order_line_montant_hors_taxes" in retval.keys()):
|
||||
user['order_line_montant_hors_taxes'] = retval['order_line_montant_hors_taxes']
|
||||
else:
|
||||
user['order_line_montant_hors_taxes'] = "0"
|
||||
if ("order_line_montant_hors_taxes" in retval.keys()):
|
||||
user['order_line_montant_hors_taxes'] = retval['order_line_montant_hors_taxes']
|
||||
else:
|
||||
user['order_line_montant_hors_taxes'] = "0"
|
||||
|
||||
user['date_update'] = retval['date_update']
|
||||
user['update_by'] = str(my_partner['_id'])
|
||||
user['partner_owner_recid'] = retval['partner_owner_recid']
|
||||
user['date_update'] = retval['date_update']
|
||||
user['update_by'] = str(my_partner['_id'])
|
||||
user['partner_owner_recid'] = retval['partner_owner_recid']
|
||||
|
||||
if ("order_line_comment" in retval.keys()):
|
||||
user['order_line_comment'] = retval['order_line_comment']
|
||||
else:
|
||||
user['order_line_comment'] = ""
|
||||
if ("order_line_comment" in retval.keys()):
|
||||
user['order_line_comment'] = retval['order_line_comment']
|
||||
else:
|
||||
user['order_line_comment'] = ""
|
||||
|
||||
user['title'] = retval['myclass_collection'][0]['title']
|
||||
user['order_line_formation_external_code'] = retval['myclass_collection'][0]['external_code']
|
||||
user['title'] = retval['myclass_collection'][0]['title']
|
||||
user['order_line_formation_external_code'] = retval['myclass_collection'][0]['external_code']
|
||||
|
||||
if ("domaine" in retval['myclass_collection'][0].keys()):
|
||||
user['domaine'] = retval['myclass_collection'][0]['domaine']
|
||||
else:
|
||||
user['domaine'] = ""
|
||||
if ("domaine" in retval['myclass_collection'][0].keys()):
|
||||
user['domaine'] = retval['myclass_collection'][0]['domaine']
|
||||
else:
|
||||
user['domaine'] = ""
|
||||
|
||||
user['duration'] = retval['myclass_collection'][0]['duration']
|
||||
user['duration_unit'] = retval['myclass_collection'][0]['duration_unit']
|
||||
user['duration'] = retval['myclass_collection'][0]['duration']
|
||||
user['duration_unit'] = retval['myclass_collection'][0]['duration_unit']
|
||||
|
||||
if (str(retval['myclass_collection'][0]['duration_unit']) == "heure"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " h"
|
||||
if (str(retval['myclass_collection'][0]['duration_unit']) == "heure"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " h"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "jour"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " j"
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "jour"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " j"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "semaine"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " s"
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "semaine"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " s"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "mois"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " m"
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "mois"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " m"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "annee"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " a"
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "annee"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " a"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "user_rythme"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " u"
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "user_rythme"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " u"
|
||||
|
||||
else:
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " ?"
|
||||
else:
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " ?"
|
||||
|
||||
Order_header_lines_data.append(user)
|
||||
Order_header_lines_data.append(user)
|
||||
|
||||
if (len(Order_header_lines_data) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Aucune ligne de détail pour cette facture ")
|
||||
return False, " Aucune ligne de détail pour cette facture "
|
||||
if (len(Order_header_lines_data) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Aucune ligne de détail pour cette facture ")
|
||||
return False, " Aucune ligne de détail pour cette facture "
|
||||
|
||||
#print(" ### Order_header_lines_data = ", Order_header_lines_data)
|
||||
#print(" ### Order_header_lines_data = ", Order_header_lines_data)
|
||||
|
||||
|
||||
contenu_doc_Template = jinja2.Template(str(partner_document_INVOICE_data['contenu_doc']))
|
||||
contenu_doc_Template = jinja2.Template(str(partner_document_INVOICE_data['contenu_doc']))
|
||||
|
||||
print(" #### partner_document_INVOICE_data = ", str(partner_document_INVOICE_data['contenu_doc']))
|
||||
#sourceHtml = contenu_doc_Template.render(params=Order_header_data)
|
||||
print(" #### partner_document_INVOICE_data = ", str(partner_document_INVOICE_data['contenu_doc']))
|
||||
#sourceHtml = contenu_doc_Template.render(params=Order_header_data)
|
||||
|
||||
#print(" ### Order_header_data = ", Order_header_data)
|
||||
#print(" ### Order_header_lines_data = ", Order_header_lines_data)
|
||||
#print(" ### Order_header_data = ", Order_header_data)
|
||||
#print(" ### Order_header_lines_data = ", Order_header_lines_data)
|
||||
|
||||
|
||||
"""
|
||||
Recuperation du dictionnaire des info
|
||||
"""
|
||||
tab_client = []
|
||||
tab_client.append(ObjectId(str(Order_header_client_data['_id'])))
|
||||
"""
|
||||
Recuperation du dictionnaire des info
|
||||
"""
|
||||
tab_client = []
|
||||
tab_client.append(ObjectId(str(Order_header_client_data['_id'])))
|
||||
|
||||
new_diction = {}
|
||||
new_diction['token'] = diction['token']
|
||||
new_diction['list_stagiaire_id'] = []
|
||||
new_diction['list_session_id'] = []
|
||||
new_diction['list_class_id'] = []
|
||||
new_diction['list_client_id'] = tab_client
|
||||
new_diction['list_apprenant_id'] = []
|
||||
new_diction = {}
|
||||
new_diction['token'] = diction['token']
|
||||
new_diction['list_stagiaire_id'] = []
|
||||
new_diction['list_session_id'] = []
|
||||
new_diction['list_class_id'] = []
|
||||
new_diction['list_client_id'] = tab_client
|
||||
new_diction['list_apprenant_id'] = []
|
||||
|
||||
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
|
||||
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
|
||||
|
||||
if (local_status is False):
|
||||
return local_status, local_retval
|
||||
if (local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
convention_dictionnary_data = local_retval
|
||||
company_data = {
|
||||
"params": convention_dictionnary_data,
|
||||
}
|
||||
convention_dictionnary_data = local_retval
|
||||
company_data = {
|
||||
"params": convention_dictionnary_data,
|
||||
}
|
||||
|
||||
convention_dictionnary_data['order_header'] = Order_header_data
|
||||
convention_dictionnary_data['order_lines'] = Order_header_lines_data
|
||||
convention_dictionnary_data['order_header'] = Order_header_data
|
||||
convention_dictionnary_data['order_lines'] = Order_header_lines_data
|
||||
|
||||
#sourceHtml = contenu_doc_Template.render(params=Order_header_data, param_order_lines=Order_header_lines_data, company_data=company_data)
|
||||
#sourceHtml = contenu_doc_Template.render(params=Order_header_data, param_order_lines=Order_header_lines_data, company_data=company_data)
|
||||
|
||||
#sourceHtml = contenu_doc_Template.render(params_order_header=Order_header_data, params_order_lines=Order_header_lines_data, params=company_data['params'])
|
||||
#sourceHtml = contenu_doc_Template.render(params_order_header=Order_header_data, params_order_lines=Order_header_lines_data, params=company_data['params'])
|
||||
|
||||
sourceHtml = contenu_doc_Template.render(params=company_data['params'])
|
||||
sourceHtml = contenu_doc_Template.render(params=company_data['params'])
|
||||
|
||||
orig_file_name = "Partner_Invoice_"+str(Order_header_data['invoice_header_ref_interne'])+".pdf"
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) +"/"+ str(orig_file_name)
|
||||
orig_file_name = "Partner_Invoice_"+str(Order_header_data['invoice_header_ref_interne'])+".pdf"
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) +"/"+ str(orig_file_name)
|
||||
|
||||
# open output file for writing (truncated binary)
|
||||
resultFile = open(outputFilename, "w+b")
|
||||
# open output file for writing (truncated binary)
|
||||
resultFile = open(outputFilename, "w+b")
|
||||
|
||||
# convert HTML to PDF
|
||||
pisaStatus = pisa.CreatePDF(
|
||||
src=sourceHtml, # the HTML to convert
|
||||
dest=resultFile) # file handle to receive result
|
||||
# convert HTML to PDF
|
||||
pisaStatus = pisa.CreatePDF(
|
||||
src=sourceHtml, # the HTML to convert
|
||||
dest=resultFile) # file handle to receive result
|
||||
|
||||
# close output file
|
||||
resultFile.close()
|
||||
# close output file
|
||||
resultFile.close()
|
||||
|
||||
# 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)
|
||||
# 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)
|
||||
|
||||
# return True on success and False on errors
|
||||
print(pisaStatus.err, type(pisaStatus.err))
|
||||
# return True on success and False on errors
|
||||
print(pisaStatus.err, type(pisaStatus.err))
|
||||
|
||||
return True, " le fichier generé "
|
||||
return True, " le fichier generé "
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
|
|
|
@ -5453,17 +5453,9 @@ def Send_Partner_Order_By_Email(diction):
|
|||
resultFile.close()
|
||||
|
||||
else:
|
||||
# Il s'agit d'une simple email
|
||||
|
||||
## Creation du mail au format email
|
||||
contenu_doc_Template = jinja2.Template(str(partner_document_CONF_ORDER_data['contenu_doc']))
|
||||
|
||||
sourceHtml = contenu_doc_Template.render(params=body["params"])
|
||||
|
||||
html_mime = MIMEText(sourceHtml, 'html')
|
||||
|
||||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " Le paramétrage du modèle de courrier 'PART_ORDER' ne comporte pas de 'joint_pdf' ")
|
||||
return False, " Le paramétrage du modèle de courrier 'PART_ORDER' ne comporte pas de 'joint_pdf' "
|
||||
|
||||
|
||||
"""
|
||||
|
|
110
prj_common.py
110
prj_common.py
|
@ -5965,4 +5965,112 @@ def Compute_Monthly_Price_From_Dates(diction):
|
|||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de calculer le prix mensuel "
|
||||
return False, " Impossible de calculer le prix mensuel "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction prend une session_id et verifie si les parametre
|
||||
d'alerte de la session sont actifs pr le partenaire
|
||||
|
||||
et si c'est le cas, la fonction verifie si on a depassé le seuil d'alert
|
||||
et qu'il reste des action à mener
|
||||
|
||||
use case :
|
||||
si le partenaire souhaite etre alerté 5 jours avant le debut de chaque session, s'il manque des actions
|
||||
(convocation, convention, etc)
|
||||
|
||||
"""
|
||||
def Check_Partner_Session_Alert(diction):
|
||||
try:
|
||||
diction = strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'session_id',]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'session_id',]
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
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 = Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
"""
|
||||
Recuperer les paramettres de controle du partenaire
|
||||
"""
|
||||
session_warning = ""
|
||||
tmp_val = MYSY_GV.dbname["base_partner_setup"].find({'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'config_name': 'session_warning'
|
||||
})
|
||||
if (tmp_val and "config_value" in tmp_val.keys()):
|
||||
session_warning = str(tmp_val['config_value'])
|
||||
|
||||
|
||||
session_warning_lead_time = ""
|
||||
session_warning_lead_time_INT = 0
|
||||
tmp_val = MYSY_GV.dbname["base_partner_setup"].find({'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'config_name':'session_warning_lead_time'
|
||||
})
|
||||
if( tmp_val and "config_value" in tmp_val.keys()):
|
||||
session_warning_lead_time = str(tmp_val['config_value'])
|
||||
session_warning_lead_time_INT = tryInt(session_warning_lead_time)
|
||||
|
||||
make_ctl = 0
|
||||
if(session_warning == "1" and session_warning_lead_time_INT > 0 ):
|
||||
make_ctl = 1
|
||||
|
||||
if( make_ctl == 0 ):
|
||||
return True, "OK"
|
||||
|
||||
is_warning = 0
|
||||
warning_message = ""
|
||||
"""
|
||||
La liste des action à controler :
|
||||
- Au moins une inscription valide
|
||||
- S'il a des preinscription, il faut qu'il les traite
|
||||
- Si une conventon n'a pas été envoyée
|
||||
- Si une convocation n'a pas été envoyée
|
||||
- si les questionnaire de positionnement n'ont pas été envoyés
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return True, "OK"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de verifier si la session est ok "
|
||||
|
|
Loading…
Reference in New Issue