05/06/23 - 15h

master
cherif 2023-06-05 14:57:19 +02:00
parent e87572aa8d
commit 40ccd19f0a
9 changed files with 2228 additions and 85 deletions

View File

@ -3,11 +3,13 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="02/06/23 - 22h"> <list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="02/06/23 - 22h">
<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$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.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$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Template/MySy_Invoice_tpl.html" beforeDir="false" afterPath="$PROJECT_DIR$/Template/MySy_Invoice_tpl.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Template/MySy_Sales_Order_tpl.html" beforeDir="false" afterPath="$PROJECT_DIR$/Template/MySy_Sales_Order_tpl.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Template/invoice.html" beforeDir="false" afterPath="$PROJECT_DIR$/Template/invoice.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/code_promo_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/code_promo_mgt.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/code_promo_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/code_promo_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/ela_factures_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_factures_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/strype_payement.py" beforeDir="false" afterPath="$PROJECT_DIR$/strype_payement.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/strype_payement.py" beforeDir="false" afterPath="$PROJECT_DIR$/strype_payement.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />

File diff suppressed because one or more lines are too long

View File

@ -179,12 +179,24 @@
<table style="font-size:smaller; margin-left: auto;"> <table style="font-size:smaller; margin-left: auto;">
<tbody> <tbody>
{% if params.discount_code is defined and
params.discount_code|length > 2 %}
<tr>
<td>Remise </td>
<td>{{params.discount_display_text}}</td>
</tr>
<tr>
<td>Montant Remise </td>
<td>{{params.discount_montant_remise}}</td>
</tr>
{% endif %}
<tr> <tr>
<td>Total HT</td> <td>Total HT</td>
<td>{{params.total_ht}}</td> <td>{{params.total_ht}}</td>
</tr> </tr>
<tr> <tr>
<td>TVA</td> <td>TVA</td>
<td>{{params.tva}} € </td> <td>{{params.tva}} € </td>
@ -201,57 +213,57 @@
<p> &nbsp;</p> <p> &nbsp;</p>
<p <p
style="font-size: 13px;margin-top: 1rem; line-height: normal; margin-bottom: 1rem; text-align: left;line-height: 1.6rem;"> style="font-size: 13px;margin-top: 1rem; line-height: normal; margin-bottom: 1rem; text-align: left;line-height: 1.6rem;">
Cordialement<br /> <br/> Cordialement<br /> <br />
<b>MySy Training Technology</b><br /> <b>MySy Training Technology</b><br />
Téléphone : +331 77 00 38 57<br /> Téléphone : +331 77 00 38 57<br />
Email : contact@mysy-training.com<br /> Email : contact@mysy-training.com<br />
Site : https://www.mysy-training.com/ Site : https://www.mysy-training.com/
</p> </p>
</div>
</div> </div>
</div> </div>
</div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</td> </td>
</tr> </tr>
<tr> <tr>
<td bgcolor="#F9F9FF" style="height:30px;" width="600"> <td bgcolor="#F9F9FF" style="height:30px;" width="600">
</td> </td>
</tr> </tr>
<tr> <tr>
<td bgcolor="#104277" width="600"> <td bgcolor="#104277" width="600">
<table border="0" cellpadding="0" cellspacing="0"> <table border="0" cellpadding="0" cellspacing="0">
<tbody> <tbody>
<tr> <tr>
<td align="center" valign="middle" width="600"> <td align="center" valign="middle" width="600">
<div style=" <div style="
padding: 10px 20px; padding: 10px 20px;
margin-bottom: 1rem; margin-bottom: 1rem;
color: #F9F9FF; color: #F9F9FF;
"><br /> &nbsp; "><br /> &nbsp;
<br /> &nbsp; <br /> &nbsp;
</div> </div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</body> </body>
</html> </html>

View File

@ -15,7 +15,7 @@
<style> <style>
html, html,
body { body {
font-family: 'Helvetica','sans-serif'; font-family: 'Helvetica', 'sans-serif';
} }
</style> </style>
@ -171,12 +171,24 @@
<table style="font-size:smaller; margin-left: auto;"> <table style="font-size:smaller; margin-left: auto;">
<tbody> <tbody>
{% if params.discount_code is defined and
params.discount_code|length > 2 %}
<tr>
<td>Remise </td>
<td>{{params.discount_display_text}}</td>
</tr>
<tr>
<td>Montant Remise </td>
<td>{{params.discount_montant_remise}}</td>
</tr>
{% endif %}
<tr> <tr>
<td>Total HT</td> <td>Total HT</td>
<td>{{params.total_ht}}</td> <td>{{params.total_ht}}</td>
</tr> </tr>
<tr> <tr>
<td>TVA</td> <td>TVA</td>
<td>{{params.tva}} € </td> <td>{{params.tva}} € </td>
@ -195,7 +207,7 @@
<p <p
style="font-size: 13px;margin-top: 1rem; line-height: normal; margin-bottom: 1rem; text-align: left;line-height: 1.6rem;"> style="font-size: 13px;margin-top: 1rem; line-height: normal; margin-bottom: 1rem; text-align: left;line-height: 1.6rem;">
Cordialement<br /> <br/> Cordialement<br /> <br />
<b>MySy Training Technology</b><br /> <b>MySy Training Technology</b><br />
Téléphone : +331 77 00 38 57<br /> Téléphone : +331 77 00 38 57<br />
Email : contact@mysy-training.com<br /> Email : contact@mysy-training.com<br />

View File

@ -75,12 +75,31 @@
</div> </div>
<table style="width:100%;padding: 5px;float:right;padding:0px;"> <table style="width:100%;padding: 5px;float:right;padding:0px;">
<tr style="padding: 0px; padding-top:5px;font-size:0.9rem;">
<td style="text-align:left;">&nbsp; </td>
<td style="text-align:left;">&nbsp; </td> {% if json_data.discount_code is defined and json_data.discount_code|length > 2 %}
<td style="text-align:center;">Montant HT: </td>
<td style="text-align:center;">{{json_data.total_ht}}</td> <tr style="padding:0px; padding-top:5px;font-size:0.9rem;">
</tr> <td style="text-align:left;">&nbsp; </td>
<td style="text-align:left;">&nbsp; </td>
<td style="text-align:center;">Remise : </td>
<td style="text-align:center;">{{json_data.discount_display_text}}</td>
</tr>
<tr style="padding:0px; padding-top:5px;font-size:0.9rem;">
<td style="text-align:left;">&nbsp; </td>
<td style="text-align:left;">&nbsp; </td>
<td style="text-align:center;">Montant Remise : </td>
<td style="text-align:center;">{{json_data.discount_montant_remise}}</td>
</tr>
{% endif %}
<tr style="padding: 0px; padding-top:5px;font-size:0.9rem;">
<td style="text-align:left;">&nbsp; </td>
<td style="text-align:left;">&nbsp; </td>
<td style="text-align:center;">Montant HT: </td>
<td style="text-align:center;">{{json_data.total_ht}}</td>
</tr>
<tr style="padding:0px; padding-top:5px;font-size:0.9rem;"> <tr style="padding:0px; padding-top:5px;font-size:0.9rem;">
<td style="text-align:left;">&nbsp; </td> <td style="text-align:left;">&nbsp; </td>

View File

@ -22,6 +22,7 @@ import ela_index_bdd_classes as eibdd
import email_mgt as email import email_mgt as email
""" """
Cette fonction créer un code promo Cette fonction créer un code promo
Elle verifie que ce code n'existe pas deja Elle verifie que ce code n'existe pas deja
@ -526,3 +527,74 @@ def Get_Given_Code_Promo(diction):
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno)) mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de recuperer le code promo" return False, "Impossible de recuperer le code promo"
"""
Cette fonction verifie si un code promo est valide
"""
def Is_Valide_Code_Promo(diction):
try:
diction = mycommon.strip_dictionary(diction)
field_list = ['token','code_promo']
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list:
mycommon.myprint(str(inspect.stack()[0][
3]) + " - Le champ '" + val + "' n'est pas autorisé, Creation partenaire annulée")
return False, "Toutes les informations fournies ne sont pas valables"
"""
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['token','code_promo']
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, "Toutes les informations necessaires n'ont pas été fournies"
# Recuperation du recid du partner
mydata = {}
mytoken = ""
if ("token" in diction.keys()):
if diction['token']:
mytoken = diction['token']
code_promo = ""
if ("code_promo" in diction.keys()):
if diction['code_promo']:
code_promo = diction['code_promo']
partner_recid = mycommon.get_parnter_recid_from_token(mytoken)
if (partner_recid is False):
mycommon.myprint(str(inspect.stack()[0][3]) + " - partner_recid est KO. Les données de connexion sont incorrectes ")
return False, " Les données de connexion sont incorrectes "
coll_session = MYSY_GV.dbname['code_promo']
myquery = {}
myquery['valide'] = "1"
myquery['locked'] = "0"
myquery['code'] = code_promo
RetObject = []
nb_val = 0
for retval in coll_session.find(myquery):
debut_debut = datetime.strptime(str(retval['date_debut']).strip(), '%d/%m/%Y')
date_fin = datetime.strptime(str(retval['date_fin']).strip(), '%d/%m/%Y')
if (debut_debut <= datetime.now() and date_fin >= datetime.now() and retval['type'] in ['fix', 'percent'] ):
RetObject.append(mycommon.JSONEncoder().encode(retval))
nb_val = nb_val + 1
# Si aucun code valide trouvé, on retourne false aussi.
if( nb_val == 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Le code promo '"+str(code_promo)+"' n'est pas valide ")
return False, " - Le code promo '"+str(code_promo)+"' n'est pas valide "
return True, "- Le code promo '"+str(code_promo)+"' est valide "
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de verifier la validité du code le code promo"

View File

@ -28,7 +28,7 @@ from flask import send_file
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
import class_mgt as class_mgt import class_mgt as class_mgt
import strype_payement as Stripe import strype_payement as Stripe
import code_promo_mgt as code_promo_mgt
class JSONEncoder(json.JSONEncoder): class JSONEncoder(json.JSONEncoder):
def default(self, o): def default(self, o):
@ -453,14 +453,15 @@ def createOrder(diction):
nb_line = 0 nb_line = 0
num_facture = "" num_facture = ""
'''field_list = ['token', 'nb_product'] '''
field_list = ['token', 'nb_product', 'periodicite', 'discount_code', 'discount_type', 'discount_valeur', 'discount_qty']
incom_keys = diction.keys() incom_keys = diction.keys()
for val in incom_keys: for val in incom_keys:
if val not in field_list: if val not in field_list:
mycommon.myprint(str(inspect.stack()[0][ mycommon.myprint(str(inspect.stack()[0][
3]) + " - Le champ '" + val + "' n'existe pas, Creation formation annulée") 3]) + " - Le champ '" + val + "' n'est pas autorisé, Creation partenaire annulée")
return False, " Impossible de créer la facture" return False, "Toutes les informations fournies ne sont pas valables", False
''' '''
''' '''
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente, Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
@ -482,6 +483,26 @@ def createOrder(diction):
if diction['token']: if diction['token']:
my_token = diction['token'] my_token = diction['token']
discount_code = ""
if ("discount_code" in diction.keys()):
if diction['discount_code']:
discount_code = diction['discount_code']
discount_type = ""
if ("discount_type" in diction.keys()):
if diction['discount_type']:
discount_type = diction['discount_type']
discount_valeur = ""
if ("discount_valeur" in diction.keys()):
if diction['discount_valeur']:
discount_valeur = diction['discount_valeur']
discount_qty = ""
if ("discount_qty" in diction.keys()):
if diction['discount_qty']:
discount_qty = diction['discount_qty']
user_recid = "None" user_recid = "None"
# Verification de la validité du token/mail dans le cas des user en mode connecté # Verification de la validité du token/mail dans le cas des user en mode connecté
if (len(str(my_token)) > 0): if (len(str(my_token)) > 0):
@ -556,11 +577,68 @@ def createOrder(diction):
row = "item_"+str(i) row = "item_"+str(i)
new_data[str(row)] = new_data_item new_data[str(row)] = new_data_item
i = i + 1 i = i + 1
"""
Recalcul du HT en incluant les remise, si remise
"""
montant_remise = 0
if( discount_code ) :
local_status, local_discount_valeur = mycommon.IsFloat(discount_valeur)
if( local_status is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " la valeur du remise n'est pas correcte ")
return False, "la valeur du remise n'est pas correcte ", None
local_status, local_discount_qty = mycommon.IsInt(discount_qty)
if (local_status is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " la valeur de 'discount_qty' n'est pas correcte ")
return False, "la valeur de 'discount_qty' n'est pas correcte ", None
local_my_data = {}
local_my_data['token'] = my_token
local_my_data['code_promo'] = discount_code
local_status, isValide_code_promo = code_promo_mgt.Is_Valide_Code_Promo(local_my_data)
if (local_status is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " Le code remise est invalide ")
return False, " Le code remise est invalide ", None
# Si le type de promo est 'percent'
if( discount_type == 'percent'):
tmp_val1 = mycommon.tryFloat(str(discount_valeur))/100
montant_remise = mycommon.tryFloat(str(total_ht)) * mycommon.tryFloat(tmp_val1)
total_ht = str(mycommon.tryFloat(str(total_ht)) - mycommon.tryFloat(str(montant_remise)))
#print(" #### percent : montant_remise = ", montant_remise)
#print(" #### percent : total_ht = ", total_ht)
elif( discount_type == "fix"):
montant_remise = mycommon.tryFloat(str(discount_valeur))
total_ht = str(mycommon.tryFloat(str(total_ht)) - mycommon.tryFloat(str(montant_remise)))
#print(" #### fix : montant_remise = ", montant_remise)
#print(" #### fix : total_ht = ", total_ht)
if(mycommon.tryFloat(str(total_ht)) <= 0 ):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La remise est supérieure au montant HT. ")
return False, " La remise est supérieure au montant HT ", None
new_data['discount_code'] = str(discount_code)
new_data['discount_type'] = str(discount_type)
new_data['discount_valeur'] = str(discount_valeur)
new_data['discount_montant_remise'] = str(montant_remise)
new_data['total_ht'] = total_ht new_data['total_ht'] = total_ht
new_data['total_tva'] = mycommon.tryFloat(str(total_ht)) * MYSY_GV.TVA_TAUX new_data['total_tva'] = mycommon.tryFloat(str(total_ht)) * MYSY_GV.TVA_TAUX
new_data['total_ttc'] = mycommon.tryFloat(str(total_ht)) + mycommon.tryFloat(str(new_data['total_tva'])) new_data['total_ttc'] = mycommon.tryFloat(str(total_ht)) + mycommon.tryFloat(str(new_data['total_tva']))
@ -730,7 +808,7 @@ def createOrder(diction):
new_data['order_id'] = "MySy_00"+str(mycommon.create_order_id()) new_data['order_id'] = "MySy_00"+str(mycommon.create_order_id())
#print(" la line à facturer est ::::: "+str(new_data)) print(" ### la line à facturer est ::::: "+str(new_data))
# Enregistrement de la commande dans la systeme # Enregistrement de la commande dans la systeme
@ -759,7 +837,7 @@ def createOrder(diction):
return_document=ReturnDocument.AFTER return_document=ReturnDocument.AFTER
) )
# Apres la creation du nouvelle abonnement, il faut aller cloturer l'ancien abonnement actif # Apres la creation du nouvel abonnement, il faut aller cloturer l'ancien abonnement actif
today_tmp = datetime.today().date() today_tmp = datetime.today().date()
ret_val_cloture = coll_order.update_many({'order_id': {'$ne' : str(new_data['order_id'])}, 'valide': '1', ret_val_cloture = coll_order.update_many({'order_id': {'$ne' : str(new_data['order_id'])}, 'valide': '1',
'client_recid':str(user_recid)}, 'client_recid':str(user_recid)},
@ -768,7 +846,7 @@ def createOrder(diction):
# Facturation de la commande # Facturation de la commande
#print(" ######## lancement de la facturation total_ttc_float = " + str(total_ttc_float)) print(" ######## lancement de la facturation total_ttc_float = " + str(total_ttc_float))
if (total_ttc_float > 0): if (total_ttc_float > 0):
CreateInvoice(new_data) CreateInvoice(new_data)
@ -948,7 +1026,8 @@ def PrintAndSendInvoices(invoice_id=None):
def convertHtmlToPdf(diction): def convertHtmlToPdf(diction):
try: try:
field_list_obligatoire =['invoice_nom', 'invoice_adr_street', 'invoice_adr_zip', 'invoice_adr_city', field_list_obligatoire =['invoice_nom', 'invoice_adr_street', 'invoice_adr_zip', 'invoice_adr_city',
'invoice_adr_country', 'invoice_id', 'invoice_date', 'due_date', 'order_id', 'item_0', 'total_ht', 'total_tva', 'total_ttc',] 'invoice_adr_country', 'invoice_id', 'invoice_date', 'due_date', 'order_id', 'item_0',
'total_ht', 'total_tva', 'total_ttc',]
for val in field_list_obligatoire: for val in field_list_obligatoire:
if val not in diction: if val not in diction:
@ -956,6 +1035,33 @@ def convertHtmlToPdf(diction):
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ") str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Impossible d'imprimer les factures" return False, " Impossible d'imprimer les factures"
#print(" ### convertHtmlToPdf diction =", diction)
discount_code = ""
if ("discount_code" in diction.keys()):
if diction['discount_code']:
discount_code = diction['discount_code']
discount_type = ""
if ("discount_type" in diction.keys()):
if diction['discount_type']:
discount_type = diction['discount_type']
discount_valeur = ""
if ("discount_valeur" in diction.keys()):
if diction['discount_valeur']:
discount_valeur = diction['discount_valeur']
discount_montant_remise = ""
if ("discount_montant_remise" in diction.keys()):
if diction['discount_montant_remise']:
discount_montant_remise = diction['discount_montant_remise']
discount_display_text = ""
if (discount_type == "fix"):
discount_display_text = " -" + str(discount_valeur) + ""
elif (discount_type == "percent"):
discount_display_text = " -" + str(discount_valeur) + " %"
templateLoader = jinja2.FileSystemLoader(searchpath="./") templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader) templateEnv = jinja2.Environment(loader=templateLoader)
@ -979,9 +1085,15 @@ def convertHtmlToPdf(diction):
"total_ht": str(diction['total_ht']), "total_ht": str(diction['total_ht']),
"tva": str(diction['total_tva']), "tva": str(diction['total_tva']),
"total_ttc": str(diction['total_ttc']), "total_ttc": str(diction['total_ttc']),
"discount_montant_remise": discount_montant_remise,
"discount_code": discount_code,
"discount_type": discount_type,
"discount_valeur": discount_valeur,
"discount_display_text": discount_display_text,
} }
} }
#print(" ### body = ", body)
sourceHtml = template.render(json_data=body["data"]) sourceHtml = template.render(json_data=body["data"])
orig_file_name = "invoice_"+str(diction['invoice_id'])+".pdf" orig_file_name = "invoice_"+str(diction['invoice_id'])+".pdf"
outputFilename = str(MYSY_GV.INVOICE_DIRECTORY)+str(orig_file_name) outputFilename = str(MYSY_GV.INVOICE_DIRECTORY)+str(orig_file_name)
@ -1030,6 +1142,9 @@ def convertHtmlToPdf(diction):
except Exception as e: except Exception as e:
mycommon.myprint( mycommon.myprint(
str(inspect.stack()[0][3]) +"Exception when calling SMTPApi->send_transac_email: %s\n" % e) str(inspect.stack()[0][3]) +"Exception when calling SMTPApi->send_transac_email: %s\n" % e)
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False return False

View File

@ -955,6 +955,14 @@ Cette fonction envoie l'email de confirmation de la commande de vente
''' '''
def SalesOrderConfirmationEmail(account_mail, diction): def SalesOrderConfirmationEmail(account_mail, diction):
try: try:
"""
Liste des champs autorisés
"""
field_list= ['invoice_nom', 'periodicite', 'total_ht', 'total_tva', 'total_ttc',
'order_id', 'date_update', 'nb_product', 'order_date',
'discount_code', 'discount_type', 'discount_valeur', 'discount_montant_remise']
''' '''
Verification des données obligatoires Verification des données obligatoires
''' '''
@ -984,6 +992,28 @@ def SalesOrderConfirmationEmail(account_mail, diction):
client_pays = diction['invoice_adr_country'] client_pays = diction['invoice_adr_country']
order_id = diction['order_id'] order_id = diction['order_id']
date_order = diction['order_date'] date_order = diction['order_date']
discount_code = ""
if ("discount_code" in diction.keys()):
if diction['discount_code']:
discount_code = diction['discount_code']
discount_type = ""
if ("discount_type" in diction.keys()):
if diction['discount_type']:
discount_type = diction['discount_type']
discount_valeur = ""
if ("discount_valeur" in diction.keys()):
if diction['discount_valeur']:
discount_valeur = diction['discount_valeur']
discount_montant_remise = ""
if ("discount_montant_remise" in diction.keys()):
if diction['discount_montant_remise']:
discount_montant_remise = diction['discount_montant_remise']
my_end_date = "" my_end_date = ""
if ("end_date" in diction.keys()): if ("end_date" in diction.keys()):
@ -1047,6 +1077,12 @@ def SalesOrderConfirmationEmail(account_mail, diction):
print("debut envoi mail de test ") print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur # on rentre les renseignements pris sur le site du fournisseur
discount_display_text = ""
if( discount_type == "fix"):
discount_display_text = " -"+str(discount_valeur)+""
elif( discount_type == "percent"):
discount_display_text = " -"+str(discount_valeur)+" %"
# msg = MIMEMultipart("alternative") # msg = MIMEMultipart("alternative")
msg = EmailMessage() msg = EmailMessage()
@ -1073,6 +1109,12 @@ def SalesOrderConfirmationEmail(account_mail, diction):
"unit_price": unit_price, "unit_price": unit_price,
"montant": montant, "montant": montant,
"end_date": my_end_date, "end_date": my_end_date,
"discount_montant_remise": discount_montant_remise,
"discount_code": discount_code,
"discount_type": discount_type,
"discount_valeur": discount_valeur,
"discount_display_text": discount_display_text,
}, },
} }
@ -1545,12 +1587,33 @@ def SendInvoiceEmail(account_mail, diction):
tva = str(diction['total_tva']) tva = str(diction['total_tva'])
total_ttc = str(diction['total_ttc']) total_ttc = str(diction['total_ttc'])
my_end_date = ""
my_end_date = ""
if ("end_date" in diction.keys()): if ("end_date" in diction.keys()):
if diction.keys(): if diction.keys():
my_end_date = "*Offre valable jusqu'au "+str(diction['end_date']) my_end_date = "*Offre valable jusqu'au "+str(diction['end_date'])
discount_code = ""
if ("discount_code" in diction.keys()):
if diction['discount_code']:
discount_code = diction['discount_code']
discount_type = ""
if ("discount_type" in diction.keys()):
if diction['discount_type']:
discount_type = diction['discount_type']
discount_valeur = ""
if ("discount_valeur" in diction.keys()):
if diction['discount_valeur']:
discount_valeur = diction['discount_valeur']
discount_montant_remise = ""
if ("discount_montant_remise" in diction.keys()):
if diction['discount_montant_remise']:
discount_montant_remise = diction['discount_montant_remise']
nb_line = mycommon.tryInt(diction['nb_product']) nb_line = mycommon.tryInt(diction['nb_product'])
if( nb_line == 0 ): if( nb_line == 0 ):
@ -1622,6 +1685,12 @@ def SendInvoiceEmail(account_mail, diction):
# msg = MIMEMultipart("alternative") # msg = MIMEMultipart("alternative")
msg = EmailMessage() msg = EmailMessage()
discount_display_text = ""
if( discount_type == "fix"):
discount_display_text = " -"+str(discount_valeur)+""
elif( discount_type == "percent"):
discount_display_text = " -"+str(discount_valeur)+" %"
# JINJA2 # JINJA2
templateLoader = jinja2.FileSystemLoader(searchpath="./") templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader) templateEnv = jinja2.Environment(loader=templateLoader)
@ -1647,6 +1716,11 @@ def SendInvoiceEmail(account_mail, diction):
"invoice_date": invoice_date, "invoice_date": invoice_date,
"due_date": due_date, "due_date": due_date,
"orign_order": orign_order, "orign_order": orign_order,
"discount_montant_remise": discount_montant_remise,
"discount_code": discount_code,
"discount_type": discount_type,
"discount_valeur": discount_valeur,
"discount_display_text": discount_display_text,
} }
} }
sourceHtml = template.render(params=body["params"]) sourceHtml = template.render(params=body["params"])

View File

@ -883,27 +883,37 @@ def strip_update_subscription_qty(diction):
if local_ret_val['pack_service']: if local_ret_val['pack_service']:
pack = local_ret_val['pack_service'] pack = local_ret_val['pack_service']
discount = "" discount_code = ""
if ("discount" in diction.keys()): if ("discount_code" in diction.keys()):
if diction['discount']: if diction['discount_code']:
discount = diction['discount'] discount_code = diction['discount_code']
discount_type = ""
if ("discount_type" in diction.keys()):
if diction['discount_type']:
discount_type = diction['discount_type']
discount_valeur = ""
if ("discount_valeur" in diction.keys()):
if diction['discount_valeur']:
discount_valeur = diction['discount_valeur']
price_id = "" price_id = ""
if (str(pack).lower() == "gold"): if (str(pack).lower() == "gold"):
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID
# On ecrase la valeur celle du discount si il existe une discount # On ecrase la valeur celle du discount si il existe une discount
if (str(discount) == "50"): if (str(discount_valeur) == "50" and str(discount_type) == "percent"):
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_50_OFF price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_50_OFF
elif (str(discount) == "100"): elif (str(discount_valeur) == "100" and str(discount_type) == "percent"):
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_100_OFF price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_100_OFF
elif (str(pack).lower() == "standard"): elif (str(pack).lower() == "standard" and str(discount_type) == "percent"):
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID
# On ecrase la valeur celle du discount si il existe une discount # On ecrase la valeur celle du discount si il existe une discount
if (str(discount) == "50"): if (str(discount_valeur) == "50" and str(discount_type) == "percent"):
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_50_OFF price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_50_OFF
elif (str(discount) == "100"): elif (str(discount_valeur) == "100" and str(discount_type) == "percent"):
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_100_OFF price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_100_OFF
elif (str(pack).lower() == "test"): elif (str(pack).lower() == "test"):
@ -1038,34 +1048,44 @@ def strip_update_subscription_plan(diction):
qty = local_ret_val['nb_formation'] qty = local_ret_val['nb_formation']
""" """
discount = "" discount_code = ""
if ("discount" in diction.keys()): if ("discount_code" in diction.keys()):
if diction['discount']: if diction['discount_code']:
discount = diction['discount'] discount_code = diction['discount_code']
discount_type = ""
if ("discount_type" in diction.keys()):
if diction['discount_type']:
discount_type = diction['discount_type']
discount_valeur = ""
if ("discount_valeur" in diction.keys()):
if diction['discount_valeur']:
discount_valeur = diction['discount_valeur']
price_id = "" price_id = ""
if (str(pack).lower() == "gold"): if (str(pack).lower() == "gold"):
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID
# On ecrase la valeur celle du discount si il existe une discount # On ecrase la valeur celle du discount si il existe une discount
if (str(discount) == "50"): if (str(discount_valeur) == "50" and str(discount_type) == "percent"):
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_50_OFF price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_50_OFF
elif (str(discount) == "100"): elif (str(discount_valeur) == "100" and str(discount_type) == "percent"):
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_100_OFF price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_100_OFF
elif (str(pack).lower() == "standard"): elif (str(pack).lower() == "standard"):
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID
# On ecrase la valeur celle du discount si il existe une discount # On ecrase la valeur celle du discount si il existe une discount
if (str(discount) == "50"): if (str(discount_valeur) == "50" and str(discount_type) == "percent"):
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_50_OFF price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_50_OFF
elif (str(discount) == "100"): elif (str(discount_valeur) == "100" and str(discount_type) == "percent"):
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_100_OFF price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_100_OFF
elif (str(pack).lower() == "test"): elif (str(pack).lower() == "test"):
price_id = MYSY_GV.STRIPE_TEST_PRICE_ID price_id = MYSY_GV.STRIPE_TEST_PRICE_ID
print(" ### pack = ", pack, " ## price_id = ", price_id) #print(" ### pack = ", pack, " ## price_id = ", price_id)
print(" #### str(local_ret_val['stripe_subscription_id']) = ", str(local_ret_val['stripe_subscription_id'])) #print(" #### str(local_ret_val['stripe_subscription_id']) = ", str(local_ret_val['stripe_subscription_id']))
current_subscription = stripe.Subscription.retrieve(str(local_ret_val['stripe_subscription_id'])) current_subscription = stripe.Subscription.retrieve(str(local_ret_val['stripe_subscription_id']))