12/09/2023 - 18h

master
cherif 2023-09-12 17:48:30 +02:00
parent 1c0d157468
commit 3ab74ee2fe
4 changed files with 3269 additions and 54 deletions

View File

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="11/09/23 - 12h30"> <list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="11/09/23 - 19h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <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$/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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_order.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_order.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> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -70,13 +69,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1680804787304</updated> <updated>1680804787304</updated>
</task> </task>
<task id="LOCAL-00053" summary="27/07/23 - 23h">
<created>1690491310678</created>
<option name="number" value="00053" />
<option name="presentableId" value="LOCAL-00053" />
<option name="project" value="LOCAL" />
<updated>1690491310679</updated>
</task>
<task id="LOCAL-00054" summary="28/07/23 - 19h"> <task id="LOCAL-00054" summary="28/07/23 - 19h">
<created>1690566255685</created> <created>1690566255685</created>
<option name="number" value="00054" /> <option name="number" value="00054" />
@ -413,7 +405,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1694428238750</updated> <updated>1694428238750</updated>
</task> </task>
<option name="localTasksCounter" value="102" /> <task id="LOCAL-00102" summary="11/09/23 - 19h">
<created>1694451732112</created>
<option name="number" value="00102" />
<option name="presentableId" value="LOCAL-00102" />
<option name="project" value="LOCAL" />
<updated>1694451732113</updated>
</task>
<option name="localTasksCounter" value="103" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
@ -428,7 +427,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="21/08/23 - 15h" />
<MESSAGE value="21/08/23 - 21h" /> <MESSAGE value="21/08/23 - 21h" />
<MESSAGE value="22/08/23 - 13h" /> <MESSAGE value="22/08/23 - 13h" />
<MESSAGE value="22/08/23 - 20h" /> <MESSAGE value="22/08/23 - 20h" />
@ -453,6 +451,7 @@
<MESSAGE value="07/09/2023 - 14h" /> <MESSAGE value="07/09/2023 - 14h" />
<MESSAGE value="08/09/2023 - 18h30" /> <MESSAGE value="08/09/2023 - 18h30" />
<MESSAGE value="11/09/23 - 12h30" /> <MESSAGE value="11/09/23 - 12h30" />
<option name="LAST_COMMIT_MESSAGE" value="11/09/23 - 12h30" /> <MESSAGE value="11/09/23 - 19h" />
<option name="LAST_COMMIT_MESSAGE" value="11/09/23 - 19h" />
</component> </component>
</project> </project>

File diff suppressed because one or more lines are too long

27
main.py
View File

@ -2369,9 +2369,7 @@ def GetSpecificPartnerAttestation_Certificat():
return jsonify(status=localStatus, message=message ) return jsonify(status=localStatus, message=message )
"""
Cette API genere la fiche de presence d'un stagaire
"""
""" """
API de generation de liste PDF des liste d'emargement API de generation de liste PDF des liste d'emargement
""" """
@ -4501,6 +4499,29 @@ def Get_List_Partner_Document_no_filter():
return jsonify(status=status, message=retval) return jsonify(status=status, message=retval)
"""
API d'impression pdf d'un commande / devis
"""
@app.route('/myclass/api/GerneratePDF_Partner_Order/<token>/<order_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def GerneratePDF_Partner_Order(token, order_id):
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
payload = {}
payload['token'] = str(token)
payload['order_id'] = str(order_id)
print(" ### GerneratePDF_Partner_Order : payload = ",str(payload))
localStatus, response= partner_order.GerneratePDF_Partner_Order(payload)
if(localStatus ):
return response
else:
return False
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -30,6 +30,9 @@ from math import isnan
import GlobalVariable as MYSY_GV import GlobalVariable as MYSY_GV
import ela_index_bdd_classes as eibdd import ela_index_bdd_classes as eibdd
import email_mgt as email import email_mgt as email
import jinja2
from flask import send_file
from xhtml2pdf import pisa
""" """
Creation d'un commande client d'un partenaire Creation d'un commande client d'un partenaire
@ -1137,7 +1140,7 @@ def Update_Partner_Order_Header(diction):
order_header_type_reduction = "" order_header_type_reduction = ""
if ("order_header_type_reduction" in diction.keys()): if ("order_header_type_reduction" in diction.keys()):
order_header_type_reduction = diction['order_header_type_reduction'] order_header_type_reduction = diction['order_header_type_reduction']
if ( order_header_type_reduction not in ['fixe', 'percent']): if ( order_header_type_reduction not in ['fixe', 'percent','']):
mycommon.myprint( mycommon.myprint(
str(inspect.stack()[0][ str(inspect.stack()[0][
3]) + " - Le champ 'type de reduction ' n'est pas valide ") 3]) + " - Le champ 'type de reduction ' n'est pas valide ")
@ -1145,17 +1148,19 @@ def Update_Partner_Order_Header(diction):
return False, " - Le champ 'type de reduction ' n'est pas valide " return False, " - Le champ 'type de reduction ' n'est pas valide "
data['order_header_type_reduction'] = diction['order_header_type_reduction'] data['order_header_type_reduction'] = diction['order_header_type_reduction']
order_header_type_reduction_valeur = "" # On ne prend en charge la valeur de la reduction que si le type de reduction est 'fixe' ou 'percent'
if ("order_header_type_reduction_valeur" in diction.keys()): if ( order_header_type_reduction in ['fixe', 'percent']):
order_header_type_reduction_valeur = diction['order_header_type_reduction_valeur'] order_header_type_reduction_valeur = ""
local_status, local_retval = mycommon.IsFloat(order_header_type_reduction_valeur) if ("order_header_type_reduction_valeur" in diction.keys()):
if (local_status is False): order_header_type_reduction_valeur = diction['order_header_type_reduction_valeur']
mycommon.myprint( local_status, local_retval = mycommon.IsFloat(order_header_type_reduction_valeur)
str(inspect.stack()[0][ if (local_status is False):
3]) + " - Le champ 'valeur de reduction ' n'est pas valide ") mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Le champ 'valeur de reduction ' n'est pas valide ")
return False, " - Le champ 'valeur de reduction ' n'est pas valide " return False, " - Le champ 'valeur de reduction ' n'est pas valide "
data['order_header_type_reduction_valeur'] = local_retval data['order_header_type_reduction_valeur'] = str(local_retval)
@ -1579,7 +1584,7 @@ def Update_Partner_Quotation_Header(diction):
order_header_type_reduction = "" order_header_type_reduction = ""
if ("order_header_type_reduction" in diction.keys()): if ("order_header_type_reduction" in diction.keys()):
order_header_type_reduction = diction['order_header_type_reduction'] order_header_type_reduction = diction['order_header_type_reduction']
if (order_header_type_reduction not in ['fixe', 'percent']): if (order_header_type_reduction not in ['fixe', 'percent', '']):
mycommon.myprint( mycommon.myprint(
str(inspect.stack()[0][ str(inspect.stack()[0][
3]) + " - Le champ 'type de reduction ' n'est pas valide ") 3]) + " - Le champ 'type de reduction ' n'est pas valide ")
@ -1587,17 +1592,19 @@ def Update_Partner_Quotation_Header(diction):
return False, " - Le champ 'type de reduction ' n'est pas valide " return False, " - Le champ 'type de reduction ' n'est pas valide "
data['order_header_type_reduction'] = diction['order_header_type_reduction'] data['order_header_type_reduction'] = diction['order_header_type_reduction']
order_header_type_reduction_valeur = "" # On ne prend en charge la valeur de la reduction que si le type de reduction est 'fixe' ou 'percent'
if ("order_header_type_reduction_valeur" in diction.keys()): if (order_header_type_reduction in ['fixe', 'percent']):
order_header_type_reduction_valeur = diction['order_header_type_reduction_valeur'] order_header_type_reduction_valeur = ""
local_status, local_retval = mycommon.IsFloat(order_header_type_reduction_valeur) if ("order_header_type_reduction_valeur" in diction.keys()):
if (local_status is False): order_header_type_reduction_valeur = diction['order_header_type_reduction_valeur']
mycommon.myprint( local_status, local_retval = mycommon.IsFloat(order_header_type_reduction_valeur)
str(inspect.stack()[0][ if (local_status is False):
3]) + " - Le champ 'valeur de reduction ' n'est pas valide ") mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Le champ 'valeur de reduction ' n'est pas valide ")
return False, " - Le champ 'valeur de reduction ' n'est pas valide " return False, " - Le champ 'valeur de reduction ' n'est pas valide "
data['order_header_type_reduction_valeur'] = local_retval data['order_header_type_reduction_valeur'] = str(local_retval)
@ -3440,7 +3447,7 @@ def Compute_Order_Header(diction):
nb_line = 0 nb_line = 0
line_sum_order_line_tax_amount = 0 line_sum_order_line_tax_amount = 0
line_sum_order_line_montant_reduction = 0 line_sum_order_line_montant_reduction = 0
line_sum_order_line_montant_hors_taxes = 0 line_sum_order_line_montant_hors_taxes_before_reduction = 0
line_sum_order_line_montant_hors_taxes_after_reduction = 0 line_sum_order_line_montant_hors_taxes_after_reduction = 0
line_sum_order_line_montant_toutes_taxes = 0 line_sum_order_line_montant_toutes_taxes = 0
@ -3449,30 +3456,52 @@ def Compute_Order_Header(diction):
for local_retval in MYSY_GV.dbname['partner_order_line'].find({'order_header_id':str(diction['_id']), 'valide':'1', 'locked':'0', for local_retval in MYSY_GV.dbname['partner_order_line'].find({'order_header_id':str(diction['_id']), 'valide':'1', 'locked':'0',
'partner_owner_recid':str(my_partner['recid']) }): 'partner_owner_recid':str(my_partner['recid']) }):
if( "order_line_tax_amount" in local_retval.keys()): print(" ------------------- Pour la ligne numero : ", nb_line)
line_sum_order_line_tax_amount = line_sum_order_line_tax_amount + mycommon.tryFloat(local_retval['order_line_tax_amount']) ligne_montant_reduction = 0
if ("order_line_montant_reduction" in local_retval.keys()): if ("order_line_montant_reduction" in local_retval.keys()):
line_sum_order_line_montant_reduction = line_sum_order_line_montant_reduction + mycommon.tryFloat( line_sum_order_line_montant_reduction = line_sum_order_line_montant_reduction + mycommon.tryFloat(
local_retval['order_line_montant_reduction']) local_retval['order_line_montant_reduction'])
ligne_montant_reduction = mycommon.tryFloat(local_retval['order_line_montant_reduction'])
print(" #### order_line_montant_reduction = ",
str(mycommon.tryFloat(local_retval['order_line_montant_reduction'])))
if( "order_line_tax_amount" in local_retval.keys()):
line_sum_order_line_tax_amount = line_sum_order_line_tax_amount + mycommon.tryFloat(local_retval['order_line_tax_amount'])
print(" #### order_line_tax_amount = ", str(mycommon.tryFloat(local_retval['order_line_tax_amount'])))
if ("order_line_montant_hors_taxes" in local_retval.keys()): if ("order_line_montant_hors_taxes" in local_retval.keys()):
line_sum_order_line_montant_hors_taxes = line_sum_order_line_montant_hors_taxes + mycommon.tryFloat( line_sum_order_line_montant_hors_taxes_before_reduction = line_sum_order_line_montant_hors_taxes_before_reduction + mycommon.tryFloat(
local_retval['order_line_montant_hors_taxes']) local_retval['order_line_montant_hors_taxes'])
print(" #### order_line_montant_hors_taxes = ", str(mycommon.tryFloat(local_retval['order_line_montant_hors_taxes'])))
order_line_montant_hors_taxes_APRES_REDUCTION = mycommon.tryFloat(local_retval['order_line_montant_hors_taxes']) - ligne_montant_reduction
print(" #### order_line_montant_hors_taxes_APRES_REDUCTION = ", str(order_line_montant_hors_taxes_APRES_REDUCTION))
if ("order_line_montant_toutes_taxes" in local_retval.keys()): if ("order_line_montant_toutes_taxes" in local_retval.keys()):
line_sum_order_line_montant_toutes_taxes = line_sum_order_line_montant_toutes_taxes + mycommon.tryFloat( line_sum_order_line_montant_toutes_taxes = line_sum_order_line_montant_toutes_taxes + mycommon.tryFloat(
local_retval['order_line_montant_toutes_taxes']) local_retval['order_line_montant_toutes_taxes'])
print(" #### order_line_montant_toutes_taxes = ",
str(mycommon.tryFloat(local_retval['order_line_montant_toutes_taxes'])))
print(" ----------- FIN DES LIGNES ")
nb_line = nb_line + 1 nb_line = nb_line + 1
line_sum_order_line_montant_hors_taxes_after_reduction = mycommon.tryFloat(line_sum_order_line_montant_hors_taxes - line_sum_order_line_montant_reduction) line_sum_order_line_montant_hors_taxes_after_reduction = line_sum_order_line_montant_hors_taxes_before_reduction - line_sum_order_line_montant_reduction
print(" ###### Apres compute des lignes : NB_LINE = ", nb_line) """print(" ###### Apres compute des lignes : NB_LINE = ", nb_line)
print(" ###### line_sum_order_line_tax_amount = ", line_sum_order_line_tax_amount)
print(" ###### line_sum_order_line_montant_reduction = ", line_sum_order_line_montant_reduction) print(" ###### line_sum_order_line_montant_reduction = ", line_sum_order_line_montant_reduction)
print(" ###### line_sum_order_line_montant_hors_taxes = ", line_sum_order_line_montant_hors_taxes) 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_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) print(" ###### line_sum_order_line_montant_toutes_taxes = ", line_sum_order_line_montant_toutes_taxes)
"""
header_reduction_type = "" header_reduction_type = ""
header_reduction_type_value = "" header_reduction_type_value = ""
@ -3482,13 +3511,13 @@ def Compute_Order_Header(diction):
if ("order_header_type_reduction_valeur" in Order_header_data.keys()): if ("order_header_type_reduction_valeur" in Order_header_data.keys()):
header_reduction_type_value = Order_header_data['order_header_type_reduction_valeur'] header_reduction_type_value = Order_header_data['order_header_type_reduction_valeur']
print(" ### les reduction d'entete ") """print(" ### les reduction d'entete ")
print(" ###### header_reduction_type = ", header_reduction_type) print(" ###### header_reduction_type = ", header_reduction_type)
print(" ###### header_reduction_type_value = ", header_reduction_type_value) print(" ###### header_reduction_type_value = ", header_reduction_type_value)
"""
global_order_taxe_amount = 0 global_order_taxe_amount = 0
global_order_amount_ht_before_header_reduction = line_sum_order_line_montant_hors_taxes global_order_amount_ht_before_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction
global_order_amount_ht_after_header_reduction = 0 global_order_amount_ht_after_header_reduction = 0
header_reduction_type_value_total_amount = 0 header_reduction_type_value_total_amount = 0
@ -3497,24 +3526,187 @@ def Compute_Order_Header(diction):
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction - mycommon.tryFloat(header_reduction_type_value) global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction - mycommon.tryFloat(header_reduction_type_value)
elif( str(header_reduction_type) == "percent" ): elif( str(header_reduction_type) == "percent" ):
header_reduction_type_value_total_amount = line_sum_order_line_montant_hors_taxes_after_reduction *mycommon.tryFloat(header_reduction_type_value)/100 print(" GRRRR line_sum_order_line_montant_hors_taxes_after_reduction = ", line_sum_order_line_montant_hors_taxes_after_reduction)
print(" GRRRR mycommon.tryFloat(header_reduction_type_value)/100 = ",
line_sum_order_line_montant_hors_taxes_after_reduction*mycommon.tryFloat(header_reduction_type_value)/100)
print(" GRRRR mycommon.tryFloat(header_reduction_type_value)/100 = ",
(line_sum_order_line_montant_hors_taxes_after_reduction - (line_sum_order_line_montant_hors_taxes_after_reduction*mycommon.tryFloat(header_reduction_type_value)/100)) )
header_reduction_type_value_total_amount = line_sum_order_line_montant_hors_taxes_after_reduction * mycommon.tryFloat(header_reduction_type_value)/100
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction - ((line_sum_order_line_montant_hors_taxes_after_reduction *mycommon.tryFloat(header_reduction_type_value)/100 )) global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction - ((line_sum_order_line_montant_hors_taxes_after_reduction *mycommon.tryFloat(header_reduction_type_value)/100 ))
print(" GRRRR global_order_amount_ht_after_header_reduction = ",global_order_amount_ht_after_header_reduction)
else: else:
header_reduction_type_value_total_amount = 0 header_reduction_type_value_total_amount = 0
global_order_amount_ht_before_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction global_order_amount_ht_before_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction
global_order_amount_ttc = global_order_amount_ht_after_header_reduction * 1.2 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(" ###### 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_ht_after_header_reduction = ", global_order_amount_ht_after_header_reduction)
print(" ###### global_order_amount_ttc = ", global_order_amount_ttc)
return True, 'ok' 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_order_line_montant_reduction, 3))
header_computed_data['total_lines_hors_taxe_before_lines_reduction'] = str(round(line_sum_order_line_montant_hors_taxes_before_reduction, 3))
header_computed_data['total_lines_hors_taxe_after_lines_reduction'] = str(round(line_sum_order_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_order_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 20%"
header_computed_data['order_header_tax_amount'] = str(round(line_sum_order_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())
print(" ### header_computed_data = ", header_computed_data)
local_retval = MYSY_GV.dbname['partner_order_header'].find_one_and_update({'_id':ObjectId(str(diction['_id'])),
'valide':'1', 'locked':'0',
'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 mise à jour a été correctement faite.'
except Exception as e: except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info() exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno)) mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de recuperer les lignes de commande " return False, " Impossible de generer les calculs de mise à jour "
"""
Impression PDF d'une commande / devis
"""
def GerneratePDF_Partner_Order(diction):
try:
field_list = ['order_id', 'token', ]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Impossible d'imprimer la liste d'emargement"
"""
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['order_id', 'token', ]
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, " Impossible d'imprimer la liste d'emargement"
query_get_data = {}
mytoken = ""
if ("token" in diction.keys()):
if diction['token']:
mytoken = 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
# Verification de la validité de l'order
qry = {'_id': ObjectId(str(diction['order_id'])), 'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])}
print(" ### qry = ", qry)
is_Order_Existe_Count = MYSY_GV.dbname['partner_order_header'].count_documents(
{'_id': ObjectId(str(diction['order_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_Order_Existe_Count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La commande n'est pas valide ")
return False, " La commande n'est pas valide",
Order_header_data = MYSY_GV.dbname['partner_order_header'].find_one({'_id': ObjectId(str(diction['order_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(
my_partner['recid'])})
partner_document_CONF_ORDER_data_qry = {'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0', 'ref_interne': 'PART_ORDER'}
print(" ### partner_document_CONF_ORDER_data_qry = ", partner_document_CONF_ORDER_data_qry)
partner_document_CONF_ORDER_data = MYSY_GV.dbname['courrier_template'].find_one(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0', 'ref_interne': 'PART_ORDER'})
if (partner_document_CONF_ORDER_data is None):
# Il n'existe pas de personnalisation de la preinscription pour ce partenaire, on va aller recuperer la presinscription pa defaut
partner_document_CONF_ORDER_data = MYSY_GV.dbname['courrier_template'].find_one(
{'partner_owner_recid': 'default',
'valide': '1', 'locked': '0', 'ref_interne': 'PART_ORDER'})
if (partner_document_CONF_ORDER_data is None):
mycommon.myprint(
str(inspect.stack()[0][
3]) + "Aucun document parametré ")
return False, "Aucun document parametré "
if ("contenu_doc" not in partner_document_CONF_ORDER_data or len(
str(partner_document_CONF_ORDER_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 "
contenu_doc_Template = jinja2.Template(str(partner_document_CONF_ORDER_data['contenu_doc']))
print(" #### Order_header_data = ", Order_header_data)
sourceHtml = contenu_doc_Template.render(params=Order_header_data)
orig_file_name = "Part_Order_"+str(Order_header_data['order_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()
# 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, " 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))
return False, False