23/08/22 - 14h30
parent
eca3bda910
commit
0a6ef30dd5
|
@ -123,4 +123,9 @@ IMG_FORMAT=['jpg', 'jpeg', 'png', 'jpe']
|
|||
'''
|
||||
Sendinblue clea API
|
||||
'''
|
||||
SENDINBLUE_API_KEY = "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"
|
||||
SENDINBLUE_API_KEY = "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"
|
||||
|
||||
'''
|
||||
Taux de TVA
|
||||
'''
|
||||
TVA_TAUX = 0.2
|
|
@ -17,6 +17,9 @@ from pymongo import ReturnDocument
|
|||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import email_mgt as email
|
||||
from dateutil import tz
|
||||
import pytz
|
||||
|
||||
|
||||
class JSONEncoder(json.JSONEncoder):
|
||||
def default(self, o):
|
||||
|
@ -174,8 +177,8 @@ def add_payement_mode(diction):
|
|||
coll_name = MYSY_GV.dbname['payement_mode']
|
||||
new_data = {}
|
||||
new_data['valide'] = "1"
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['client_recid'] = user_recid
|
||||
now = datetime.now()
|
||||
new_data['date_update'] = str(now)
|
||||
|
||||
# initialisation pr nettoyer l'existant (faire comme un delete)
|
||||
new_data['nom_carte'] = ""
|
||||
|
@ -358,7 +361,7 @@ def createOrder(diction):
|
|||
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 = ['token', 'nb_product', 'periodicite', 'prix_ttc', 'prix_ht']
|
||||
field_list_obligatoire = ['token', 'nb_product', 'periodicite']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -402,14 +405,6 @@ def createOrder(diction):
|
|||
if diction['periodicite']:
|
||||
new_data['periodicite'] = diction['periodicite']
|
||||
|
||||
if ("prix_ttc" in diction.keys()):
|
||||
if diction['prix_ttc']:
|
||||
new_data['prix_ttc'] = diction['prix_ttc']
|
||||
|
||||
if ("prix_ht" in diction.keys()):
|
||||
if diction['prix_ht']:
|
||||
new_data['prix_ht'] = diction['prix_ht']
|
||||
|
||||
|
||||
# Recuperation des données client
|
||||
new_data['client_recid'] = user_recid
|
||||
|
@ -500,23 +495,43 @@ def createOrder(diction):
|
|||
|
||||
new_data['nb_product'] = str(nb_line)
|
||||
i = 0
|
||||
total_ht = 0
|
||||
while (i < nb_line):
|
||||
print("PRODUIT N° " + str((i + 1)) + " : " )
|
||||
line_dict = json.loads(diction[str(i)])
|
||||
print(" line = "+str(line_dict)+" -- le type est : "+str(type(line_dict)))
|
||||
print(" code = "+str( line_dict['code'] ))
|
||||
print(" prix = " + str(line_dict['prix']))
|
||||
print(" qty = " + str(line_dict['qty']))
|
||||
|
||||
montant_line = mycommon.tryFloat(str(line_dict['prix'])) * mycommon.tryInt(str(line_dict['qty']))
|
||||
print(" montant_line = " + str(montant_line))
|
||||
|
||||
total_ht = total_ht + montant_line
|
||||
|
||||
new_data_item = {}
|
||||
new_data_item['code'] = line_dict['code']
|
||||
new_data_item['prix'] = line_dict['prix']
|
||||
new_data_item['qty'] = line_dict['qty']
|
||||
new_data_item['amount'] = str(montant_line)
|
||||
row = "item_"+str(i)
|
||||
new_data[str(row)] = new_data_item
|
||||
|
||||
i = i + 1
|
||||
|
||||
new_data['total_ht'] = total_ht
|
||||
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']))
|
||||
|
||||
print(" new_data['total_ht'] = "+str(new_data['total_ht']) + " -- new_data['total_tva'] "
|
||||
+str(new_data['total_tva'])+ " -- new_data['total_ttc'] = "+ str(new_data['total_ttc']))
|
||||
|
||||
new_data['valide'] = "1"
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
now = datetime.now()
|
||||
|
||||
new_data['date_update'] = str(now)
|
||||
new_data['order_date'] = str(now.strftime("%d/%m/%Y, %H:%M:%S"))
|
||||
|
||||
new_data['order_id'] = "MySy_00"+str(mycommon.create_order_id())
|
||||
|
||||
print(" la line à facturer est ::::: "+str(new_data))
|
||||
|
|
40
email_mgt.py
40
email_mgt.py
|
@ -10,7 +10,8 @@ import inspect
|
|||
import sys, os
|
||||
import prj_common as mycommon
|
||||
import GlobalVariable as MYSY_GV
|
||||
|
||||
from dateutil import tz
|
||||
import pytz
|
||||
import sib_api_v3_sdk
|
||||
from sib_api_v3_sdk.rest import ApiException
|
||||
|
||||
|
@ -373,23 +374,25 @@ def SalesOrderConfirmationEmail(account_mail, diction):
|
|||
On controle que les champs obligatoires sont presents dans la liste
|
||||
'''
|
||||
field_list_obligatoire = ['invoice_nom', 'invoice_adr_city', 'invoice_adr_country', 'invoice_adr_street',
|
||||
'invoice_adr_zip', 'periodicite', 'prix_ht', 'prix_ttc', 'order_id',
|
||||
'date_update', 'nb_product']
|
||||
'invoice_adr_zip', 'periodicite', 'total_ht', 'total_tva', 'total_ttc',
|
||||
'order_id', 'date_update', 'nb_product', 'order_date']
|
||||
|
||||
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 l'email de confirmation"
|
||||
|
||||
total_ht = diction['prix_ht']
|
||||
tva = "20%%ch"
|
||||
total_ttc = diction['prix_ttc']
|
||||
total_ht = diction['total_ht']
|
||||
tva = diction['total_tva']
|
||||
total_ttc = diction['total_ttc']
|
||||
client_name = diction['invoice_nom']
|
||||
client_address = diction['invoice_adr_street']
|
||||
client_zip_ville = diction['invoice_adr_zip']+" "+diction['invoice_adr_city']
|
||||
client_pays = diction['invoice_adr_country']
|
||||
order_id = diction['order_id']
|
||||
date_order = diction['date_update']
|
||||
date_order = diction['order_date']
|
||||
|
||||
|
||||
nb_line = mycommon.tryInt(diction['nb_product'])
|
||||
|
||||
if( nb_line == 0 ):
|
||||
|
@ -409,25 +412,26 @@ def SalesOrderConfirmationEmail(account_mail, diction):
|
|||
if ("item_0" in diction.keys()):
|
||||
if( diction["item_0"] ):
|
||||
packs = diction["item_0"]['code']
|
||||
qty = "1"
|
||||
qty = diction["item_0"]['qty']
|
||||
unit_price = diction["item_0"]['prix']
|
||||
montant = diction["item_0"]['prix']
|
||||
montant = diction["item_0"]['amount']
|
||||
detail_packs = " detail_lin1 \n detail_lin2 \n detail_lin3"
|
||||
|
||||
# produit 2
|
||||
if ("item_1" in diction.keys()):
|
||||
if (diction["item_1"]):
|
||||
packs1 = diction["item_1"]['code']
|
||||
qty1 = "1"
|
||||
qty1 = diction["item_0"]['qty']
|
||||
unit_price1 = diction["item_1"]['prix']
|
||||
montant1 = diction["item_1"]['prix']
|
||||
montant1 = diction["item_1"]['amount']
|
||||
|
||||
# produit 3
|
||||
if ("item_2" in diction.keys()):
|
||||
if (diction["item_2"]):
|
||||
packs2 = diction["item_2"]['code']
|
||||
qty2 = "1"
|
||||
qty2 = diction["item_0"]['qty']
|
||||
unit_price2 = diction["item_2"]['prix']
|
||||
montant2 = diction["item_2"]['prix']
|
||||
montant2 = diction["item_2"]['amount']
|
||||
|
||||
|
||||
i = 0
|
||||
|
@ -458,9 +462,7 @@ def SalesOrderConfirmationEmail(account_mail, diction):
|
|||
|
||||
send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(template_id=22, params={"order_id": order_id,
|
||||
"date_order": date_order,
|
||||
"packs": packs,
|
||||
"qty": qty,
|
||||
"unit_price": unit_price,
|
||||
|
||||
"total_ht": total_ht,
|
||||
"tva": tva,
|
||||
"total_ttc": total_ttc,
|
||||
|
@ -469,6 +471,12 @@ def SalesOrderConfirmationEmail(account_mail, diction):
|
|||
"client_zip_ville": client_zip_ville,
|
||||
"client_pays": client_pays,
|
||||
|
||||
"packs": packs,
|
||||
"detail_packs": detail_packs,
|
||||
"qty": qty,
|
||||
"unit_price": unit_price,
|
||||
"montant":montant,
|
||||
|
||||
}, to=to, bcc=bcc)
|
||||
api_response = api_instance.send_transac_email(send_smtp_email)
|
||||
print(api_response)
|
||||
|
|
Loading…
Reference in New Issue