07/11/22 - 11h
parent
20c85ad917
commit
363fcfcc1f
|
@ -73,19 +73,19 @@
|
|||
font-size: small; line-height: 1.4rem;color: #3b3e40;">
|
||||
|
||||
<p style="font-size:small; font-weight:bold">Confirmation de votre commande n° {{params.order_id}}</p>
|
||||
<p style="text-align:right; font-size: small;">
|
||||
<p style="text-align:right; font-size: smaller;">
|
||||
{{params.client_name}}<br/>
|
||||
{{params.client_address}}<br/>
|
||||
{{params.client_zip_ville}}<br/>
|
||||
{{params.client_pays}}<br/>
|
||||
</p>
|
||||
|
||||
<p style="text-align:left; font-size: small;">
|
||||
<p style="text-align:left; font-size: smaller;">
|
||||
|
||||
Commande n° {{params.order_id}}<br/>
|
||||
Date de commande : {{params.date_order}}<br/>
|
||||
{% if params.end_date %}
|
||||
<nav style="color:red; text-align:left"> {{params.end_date}}</nav>
|
||||
<nav style="color:red; text-align:left; font-size: smaller;"> {{params.end_date}}</nav>
|
||||
{% endif %}
|
||||
|
||||
</p>
|
||||
|
|
19
class_mgt.py
19
class_mgt.py
|
@ -46,7 +46,7 @@ def add_class(diction):
|
|||
field_list = ['external_code', 'title', 'description', 'trainer', 'institut_formation', 'distantiel', 'presentiel',
|
||||
'price', 'url','duration', 'duration_unit', 'token', 'plus_produit', 'mots_cle','domaine',
|
||||
'internal_url', 'zone_diffusion', 'metier', 'date_lieu', 'published', 'img_url', 'objectif',
|
||||
'programme', 'prerequis', 'note', 'cpf', 'certif']
|
||||
'programme', 'prerequis', 'note', 'cpf', 'certif', 'class_inscription_url']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -149,6 +149,11 @@ def add_class(diction):
|
|||
if diction['cpf']:
|
||||
mydata['cpf'] = diction['cpf']
|
||||
|
||||
if ("class_inscription_url" in diction.keys()):
|
||||
if diction['class_inscription_url']:
|
||||
mydata['class_inscription_url'] = diction['class_inscription_url']
|
||||
|
||||
|
||||
if ("certif" in diction.keys()):
|
||||
if diction['certif']:
|
||||
mydata['certif'] = diction['certif']
|
||||
|
@ -530,7 +535,7 @@ def update_class(diction):
|
|||
'presentiel','price', 'url', 'duration', 'token','plus_produit', 'mots_cle',
|
||||
'domaine', 'internal_code', 'internal_url','zone_diffusion', 'metier',
|
||||
'date_lieu', 'published', 'img_url', 'objectif', 'programme', 'prerequis', 'note',
|
||||
'cpf', 'certif']
|
||||
'cpf', 'certif', 'class_inscription_url']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -595,6 +600,9 @@ def update_class(diction):
|
|||
if ("title" in diction.keys()):
|
||||
mydata['title'] = diction['title']
|
||||
|
||||
if ("class_inscription_url" in diction.keys()):
|
||||
mydata['class_inscription_url'] = diction['class_inscription_url']
|
||||
|
||||
if ("note" in diction.keys()):
|
||||
mydata['note'] = diction['note']
|
||||
|
||||
|
@ -2226,7 +2234,8 @@ def add_class_mass(file=None, Folder=None, diction=None):
|
|||
field_list = ['external_code', 'titre', 'description', 'formateur', 'institut_formation',
|
||||
'distantiel', 'presentiel', 'prix', 'domaine', 'url','duree', 'plus_produit',
|
||||
'mots_cle', 'zone_diffusion', 'metier', 'date_lieu', 'publie', 'img_url',
|
||||
'objectif', 'programme', 'prerequis', 'formateur', 'note', 'cpf', 'certif']
|
||||
'objectif', 'programme', 'prerequis', 'formateur', 'note', 'cpf', 'certif',
|
||||
'class_inscription_url']
|
||||
|
||||
total_rows = len(df)
|
||||
|
||||
|
@ -2292,6 +2301,10 @@ def add_class_mass(file=None, Folder=None, diction=None):
|
|||
if (str(df['cpf'].values[n])):
|
||||
mydata['cpf'] = str(df['cpf'].values[n])
|
||||
|
||||
if ("class_inscription_url" in df.keys()):
|
||||
if (str(df['class_inscription_url'].values[n])):
|
||||
mydata['class_inscription_url'] = str(df['class_inscription_url'].values[n])
|
||||
|
||||
if ("certif" in df.keys()):
|
||||
if (str(df['certif'].values[n])):
|
||||
mydata['certif'] = str(df['certif'].values[n])
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
,index,mots,occurence,moyenne,id_formation,source_field
|
||||
0,0,actualite,1,0.5,POT_191206,title
|
||||
1,1,sociale,1,0.5,POT_191206,title
|
||||
0,0,sociale,1,0.5,POT_191206,title
|
||||
1,1,actualite,1,0.5,POT_191206,title
|
||||
|
|
|
|
@ -428,8 +428,7 @@ def get_payement_mode(diction):
|
|||
tmp_diction = {}
|
||||
tmp_diction['stripe_account_id'] = str(stripe_account_id)
|
||||
|
||||
print("## recherche mod de payement stripe_account_id = "+str(stripe_account_id)
|
||||
)
|
||||
#print("## recherche mod de payement stripe_account_id = "+str(stripe_account_id) )
|
||||
|
||||
localStatus, payment_cards = Stripe.get_customer_payement_cards(tmp_diction)
|
||||
val_tmp = {}
|
||||
|
@ -439,7 +438,7 @@ def get_payement_mode(diction):
|
|||
RetObject_stripe.append(val_tmp)
|
||||
#RetObject_stripe.append(JSONEncoder().encode(tmp))
|
||||
|
||||
print(" #### mode de payement via stripe = "+str(RetObject_stripe))
|
||||
#print(" #### mode de payement via stripe = "+str(RetObject_stripe))
|
||||
|
||||
RetObject = []
|
||||
coll_facture = MYSY_GV.dbname['payement_mode']
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
mots occurence moyenne id_formation source_field
|
||||
0 actualite 1 0.5 POT_191206 title
|
||||
1 sociale 1 0.5 POT_191206 title
|
||||
0 sociale 1 0.5 POT_191206 title
|
||||
1 actualite 1 0.5 POT_191206 title
|
237
email_mgt.py
237
email_mgt.py
|
@ -504,9 +504,9 @@ def SalesOrderConfirmationEmail_old(account_mail, diction):
|
|||
|
||||
|
||||
"""
|
||||
Cette fonction envoi les factures
|
||||
Cette fonction envoi les factures OLD
|
||||
"""
|
||||
def SendInvoiceEmail(account_mail, diction):
|
||||
def SendInvoiceEmail_Old(account_mail, diction):
|
||||
try:
|
||||
'''
|
||||
Verification des données obligatoires
|
||||
|
@ -1022,46 +1022,8 @@ def SalesOrderConfirmationEmail(account_mail, diction):
|
|||
toaddrs = ", ".join(receiver)
|
||||
# on rentre les renseignements pris sur le site du fournisseur
|
||||
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
msg['Subject'] = '[MySy Training]: votre compte PRO est pret'
|
||||
msg['From'] = 'contact@mysy-training.com'
|
||||
msg['To'] = str(toaddrs)
|
||||
msg['Cc'] = 'contact@mysy-training.com'
|
||||
|
||||
to = [{"email": str(account_mail)}]
|
||||
|
||||
#print(" ############# to = "+str(to))
|
||||
bcc = [{"email": "contact@mysy-training.com"}]
|
||||
|
||||
"""
|
||||
send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(template_id=22, params={"order_id": order_id,
|
||||
"date_order": date_order,
|
||||
|
||||
"total_ht": total_ht,
|
||||
"tva": tva,
|
||||
"total_ttc": total_ttc,
|
||||
"client_name": client_name,
|
||||
"client_address": client_address,
|
||||
"client_zip_ville": client_zip_ville,
|
||||
"client_pays": client_pays,
|
||||
|
||||
"packs": packs,
|
||||
"detail_packs": detail_packs,
|
||||
"qty": qty,
|
||||
"unit_price": unit_price,
|
||||
"montant":montant,
|
||||
"end_date": my_end_date,
|
||||
|
||||
}, to=to, bcc=bcc)
|
||||
|
||||
"""
|
||||
#----------
|
||||
mail_recever = "billardman01@hotmail.com,cherif.balde@yahoo.fr,cbalde@mysy-training.com"
|
||||
mail_object = " new mysy email"
|
||||
mail_message = " le message : corps du mail "
|
||||
|
||||
|
||||
mail_recever = str(toaddrs)
|
||||
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
|
@ -1103,8 +1065,9 @@ def SalesOrderConfirmationEmail(account_mail, diction):
|
|||
msg.set_content(sourceHtml, subtype='html')
|
||||
|
||||
msg['Subject'] = "[MySy Training] : Confirmation commande N°"+str(order_id)
|
||||
msg['From'] = "cbalde@mysy-training.com"
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
msg['To'] = str(mail_recever)
|
||||
msg['Cc'] = 'contact@mysy-training.com'
|
||||
|
||||
# html_mime = MIMEText(html, 'html')
|
||||
|
||||
|
@ -1508,3 +1471,193 @@ def EmailDemandeInfoClass( diction):
|
|||
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 d'envoyer l'email de notification "
|
||||
|
||||
"""
|
||||
Cette fonction envoi les factures
|
||||
"""
|
||||
def SendInvoiceEmail(account_mail, diction):
|
||||
try:
|
||||
'''
|
||||
Verification des données obligatoires
|
||||
'''
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
On controle que les champs obligatoires sont presents dans la liste
|
||||
'''
|
||||
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', ]
|
||||
|
||||
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'envoyer la facture par email"
|
||||
|
||||
|
||||
order_id = diction['order_id']
|
||||
date_order = diction['order_date']
|
||||
client_name = str(diction['invoice_nom'])
|
||||
client_address= str(diction['invoice_adr_street'])
|
||||
client_zip_ville = str(diction['invoice_adr_zip']) + " " + str(diction['invoice_adr_city'])
|
||||
client_pays = str(diction['invoice_adr_country'])
|
||||
invoice_id = str(diction['invoice_id'])
|
||||
invoice_date = str(diction['invoice_date'])
|
||||
due_date = str(diction['due_date'])
|
||||
orign_order = str(diction['order_id'])
|
||||
packs = str(diction['item_0']['code'])
|
||||
qty = str(diction['item_0']['qty'])
|
||||
unit_price = str(diction['item_0']['prix'])
|
||||
montant = str(diction['item_0']['amount'])
|
||||
total_ht = str(diction['total_ht'])
|
||||
tva = str(diction['total_tva'])
|
||||
total_ttc = str(diction['total_ttc'])
|
||||
|
||||
my_end_date = ""
|
||||
|
||||
if ("end_date" in diction.keys()):
|
||||
if diction.keys():
|
||||
my_end_date = "*Offre valable jusqu'au "+str(diction['end_date'])
|
||||
|
||||
nb_line = mycommon.tryInt(diction['nb_product'])
|
||||
|
||||
if( nb_line == 0 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - nb_line = '" + nb_line + "' : Aucun produit à facturer")
|
||||
return False, " Impossible d'envoyer l'email de confirmation"
|
||||
|
||||
#print("Facture client_name = "+str(client_name))
|
||||
#print("Facture client_address = " + str(client_address))
|
||||
#print("Facture client_zip_ville = " + str(client_zip_ville))
|
||||
#print("Facture client_pays = " + str(client_pays))
|
||||
#print("Facture order_id = " + str(order_id))
|
||||
#print("Facture date_order = " + str(date_order))
|
||||
#print("Facture nb_line = " + str(nb_line))
|
||||
#print("Facture End Date = " + str(my_end_date))
|
||||
|
||||
# Recuperation des produits (max 3 produits)
|
||||
# produit 1
|
||||
if ("item_0" in diction.keys()):
|
||||
if( diction["item_0"] ):
|
||||
packs = diction["item_0"]['code']
|
||||
qty = diction["item_0"]['qty']
|
||||
unit_price = diction["item_0"]['prix']
|
||||
montant = diction["item_0"]['amount']
|
||||
detail_packs = diction["item_0"]['pack_products']
|
||||
#print("diction['item_0']['pack_products'] = "+str(diction["item_0"]['pack_products']))
|
||||
|
||||
# produit 2
|
||||
if ("item_1" in diction.keys()):
|
||||
if (diction["item_1"]):
|
||||
packs1 = diction["item_1"]['code']
|
||||
qty1 = diction["item_0"]['qty']
|
||||
unit_price1 = diction["item_1"]['prix']
|
||||
montant1 = diction["item_1"]['amount']
|
||||
detail_packs1 = diction["item_1"]['pack_products']
|
||||
|
||||
# produit 3
|
||||
if ("item_2" in diction.keys()):
|
||||
if (diction["item_2"]):
|
||||
packs2 = diction["item_2"]['code']
|
||||
qty2 = diction["item_0"]['qty']
|
||||
unit_price2 = diction["item_2"]['prix']
|
||||
montant2 = diction["item_2"]['amount']
|
||||
detail_packs2 = diction["item_1"]['pack_products']
|
||||
|
||||
|
||||
i = 0
|
||||
while (i < nb_line):
|
||||
row = "item_" + str(i)
|
||||
#print(" product = "+ str(diction[str(row)]))
|
||||
i = i + 1
|
||||
|
||||
receiver = [str(account_mail)]
|
||||
toaddrs = ", ".join(receiver)
|
||||
|
||||
|
||||
|
||||
#print("Facture mail enoye à toaddrs : " + toaddrs)
|
||||
#print("Facture debut envoi mail de test ")
|
||||
# on rentre les renseignements pris sur le site du fournisseur
|
||||
|
||||
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
||||
tomorrow_day = tomorrow.strftime("%A")
|
||||
|
||||
print("debut envoi mail de test ")
|
||||
# on rentre les renseignements pris sur le site du fournisseur
|
||||
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
# msg = MIMEMultipart("alternative")
|
||||
msg = EmailMessage()
|
||||
|
||||
# JINJA2
|
||||
templateLoader = jinja2.FileSystemLoader(searchpath="./")
|
||||
templateEnv = jinja2.Environment(loader=templateLoader)
|
||||
TEMPLATE_FILE = "Template/MySy_Invoice_tpl.html"
|
||||
template = templateEnv.get_template(TEMPLATE_FILE)
|
||||
body = {
|
||||
"params": {"order_id": order_id,
|
||||
"date_order": date_order,
|
||||
"total_ht": total_ht,
|
||||
"tva": tva,
|
||||
"total_ttc": total_ttc,
|
||||
"client_name": client_name,
|
||||
"client_address": client_address,
|
||||
"client_zip_ville": client_zip_ville,
|
||||
"client_pays": client_pays,
|
||||
"packs": packs,
|
||||
"detail_packs": detail_packs,
|
||||
"qty": qty,
|
||||
"unit_price": unit_price,
|
||||
"montant": montant,
|
||||
"invoice_id": invoice_id,
|
||||
"invoice_date": invoice_date,
|
||||
"due_date": due_date,
|
||||
"orign_order": orign_order,
|
||||
}
|
||||
}
|
||||
sourceHtml = template.render(params=body["params"])
|
||||
|
||||
msg.set_content(sourceHtml, subtype='html')
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
msg['Cc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = "[MySy Training Technology] : Votre facture N° "+str(invoice_id)
|
||||
msg['To'] = str(toaddrs)
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé " + str(val))
|
||||
return True
|
||||
|
||||
"""
|
||||
|
||||
send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(template_id=23, params={"order_id": order_id,
|
||||
"date_order": date_order,
|
||||
|
||||
"total_ht": total_ht,
|
||||
"tva": tva,
|
||||
"total_ttc": total_ttc,
|
||||
"client_name": client_name,
|
||||
"client_address": client_address,
|
||||
"client_zip_ville": client_zip_ville,
|
||||
"client_pays": client_pays,
|
||||
"packs": packs,
|
||||
"detail_packs": detail_packs,
|
||||
"qty": qty,
|
||||
"unit_price": unit_price,
|
||||
"montant":montant,
|
||||
"invoice_id":invoice_id,
|
||||
"invoice_date":invoice_date,
|
||||
"due_date":due_date,
|
||||
"orign_order":orign_order,
|
||||
}, to=to, bcc=bcc)
|
||||
api_response = api_instance.send_transac_email(send_smtp_email)
|
||||
#print("Facture "+str(api_response))
|
||||
return True
|
||||
"""
|
||||
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
|
||||
|
|
|
@ -138,7 +138,7 @@ def get_customer_payement_cards(diction):
|
|||
type="card",
|
||||
)
|
||||
|
||||
print(" ### customer_payments = "+str(customer_payments.data))
|
||||
#print(" ### customer_payments = "+str(customer_payments.data))
|
||||
|
||||
RetObject = []
|
||||
for val in customer_payments.data :
|
||||
|
@ -291,7 +291,7 @@ def confirm_suscription(diction):
|
|||
payment_method="pm_card_visa",
|
||||
)
|
||||
|
||||
print("### confirmation_payement.data = "+str(confirmation_payement))
|
||||
#print("### confirmation_payement.data = "+str(confirmation_payement))
|
||||
return True, confirmation_payement.id, confirmation_payement.status
|
||||
|
||||
|
||||
|
@ -336,7 +336,7 @@ def create_subscription(diction):
|
|||
expand=['latest_invoice.payment_intent'],
|
||||
)
|
||||
|
||||
print(" ### subscription = "+str(subscription))
|
||||
#print(" ### subscription = "+str(subscription))
|
||||
return True, subscription.latest_invoice.payment_intent.id, subscription.latest_invoice.payment_intent.client_secret
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue