sds
parent
ba19c02b07
commit
a07699bf6f
|
@ -1,12 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="13/05/2024 - 18h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="14/05/2024 - 21h30">
|
||||
<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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_client.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_client.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_order.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_order.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -76,13 +77,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00249" summary="25/03/2024 - 18h30">
|
||||
<created>1711387309255</created>
|
||||
<option name="number" value="00249" />
|
||||
<option name="presentableId" value="LOCAL-00249" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1711387309256</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00250" summary="26/03/2024 - 21h30">
|
||||
<created>1711484853704</created>
|
||||
<option name="number" value="00250" />
|
||||
|
@ -419,7 +413,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1715618340942</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="298" />
|
||||
<task id="LOCAL-00298" summary="14/05/2024 - 21h30">
|
||||
<created>1715714868339</created>
|
||||
<option name="number" value="00298" />
|
||||
<option name="presentableId" value="LOCAL-00298" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1715714868342</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="299" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -461,7 +462,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="19/04/2024 - 22h22" />
|
||||
<MESSAGE value="20/04/2024 - 13h" />
|
||||
<MESSAGE value="20/04/2024 - 20h44" />
|
||||
<MESSAGE value="22/04/2024 - 17h30" />
|
||||
|
@ -486,6 +486,7 @@
|
|||
<MESSAGE value="ddsdfsd" />
|
||||
<MESSAGE value="12/05/2024 - 21h30" />
|
||||
<MESSAGE value="13/05/2024 - 18h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="13/05/2024 - 18h30" />
|
||||
<MESSAGE value="14/05/2024 - 21h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="14/05/2024 - 21h30" />
|
||||
</component>
|
||||
</project>
|
1385
Log/log_file.log
1385
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -4414,7 +4414,7 @@ def RenseignementClass(diction):
|
|||
'raison_sociale', 'siret', 'email_requester', 'telephone_requester',
|
||||
'nom_requester', 'prenom_requester', 'nb_person_info',
|
||||
'prenom_requester', 'nom_requester', 'telephone_requester',
|
||||
'email_requester', 'siret', 'raison_sociale', 'is_company']
|
||||
'email_requester', 'siret', 'raison_sociale', 'is_company', 'class_sales_price']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -4494,7 +4494,7 @@ def RenseignementClass(diction):
|
|||
# Verifier les champ obligatoires
|
||||
field_list_obligatoire = ['raison_sociale', 'siret',
|
||||
'email_requester', 'telephone_requester', 'nom_requester',
|
||||
'prenom_requester', 'nb_person_info', 'class_internal_url']
|
||||
'prenom_requester', 'nb_person_info', 'class_internal_url', 'class_sales_price']
|
||||
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
|
|
20
main.py
20
main.py
|
@ -5914,6 +5914,26 @@ def Convert_Quotation_to_Order():
|
|||
return jsonify(status=status, message=message, retval=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API Pour créer un devis automatique depuis une demande du siteweb
|
||||
"""
|
||||
|
||||
@app.route('/myclass/api/Create_Automatic_Quotation/', methods=['GET','POST'])
|
||||
@crossdomain(origin='*')
|
||||
def Create_Automatic_Quotation():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Create_Automatic_Quotation payload = ", str(payload))
|
||||
status, message = partner_order.Create_Automatic_Quotation(payload)
|
||||
return jsonify(status=status, message=message)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour Conversion d'un devis en commande
|
||||
"""
|
||||
|
|
|
@ -27,6 +27,9 @@ import email_mgt as email
|
|||
import ast
|
||||
import Contact as contact
|
||||
|
||||
"""
|
||||
Creation d'un client
|
||||
"""
|
||||
def Add_Partner_Client(diction):
|
||||
|
||||
try:
|
||||
|
@ -41,9 +44,8 @@ def Add_Partner_Client(diction):
|
|||
'invoice_email', 'invoice_nom', 'invoice_siret',
|
||||
'invoice_tva', 'invoice_condition_paiement_id', 'invoice_adresse', 'invoice_ville',
|
||||
'invoice_code_postal', 'invoice_pays', "client_type_id",
|
||||
'is_fournisseur', 'is_client', 'is_financeur', 'is_company', 'invoice_automatique']
|
||||
|
||||
print(" diction = ", diction)
|
||||
'is_fournisseur', 'is_client', 'is_financeur', 'is_company', 'invoice_automatique',
|
||||
]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -376,6 +378,360 @@ def Add_Partner_Client(diction):
|
|||
|
||||
|
||||
|
||||
"""
|
||||
Creation d'un prospect
|
||||
"""
|
||||
def Add_Partner_Prospect(diction):
|
||||
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "raison_sociale", "nom", "siret", "tva", "email",
|
||||
"telephone", "website", "comment", "address", "list_contact",
|
||||
'adr_adresse', 'adr_code_postal', 'adr_ville', 'adr_pays',
|
||||
'invoice_email', 'invoice_nom', 'invoice_siret',
|
||||
'invoice_tva', 'invoice_condition_paiement_id', 'invoice_adresse', 'invoice_ville',
|
||||
'invoice_code_postal', 'invoice_pays', "client_type_id",
|
||||
'is_fournisseur', 'is_client', 'is_financeur', 'is_company', 'invoice_automatique',
|
||||
]
|
||||
|
||||
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'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', "raison_sociale", "nom", "email", "telephone", ]
|
||||
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, " 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']
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_partner_token_validity("", token)
|
||||
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(token)
|
||||
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, " Vous n'etes pas autorisé à utiliser cette API "
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_partner = mycommon.get_partner_data_from_recid(partner_recid)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de récupérer les données du partenaire")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de récupérer les données du partenaire. "
|
||||
|
||||
|
||||
"""
|
||||
Verification s'il n'existe pas un cient du partenaire qui perte le meme
|
||||
nom, ou la meme adresse email
|
||||
"""
|
||||
|
||||
qry = {'nom': str(diction['nom']), 'valide': '1', 'partner_recid': str(my_partner['recid'])}
|
||||
|
||||
tmp_count = MYSY_GV.dbname['partner_client'].count_documents(qry)
|
||||
if (tmp_count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Il existe déjà un client qui porte le même nom = "+str(diction['nom']))
|
||||
|
||||
return False, " - Vous déjà un client qui porte le même nom "
|
||||
|
||||
tmp_count = MYSY_GV.dbname['partner_client'].count_documents({'email': str(diction['email']),
|
||||
'valide': '1', 'partner_recid': my_partner['recid']})
|
||||
if (tmp_count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Il existe déjà un client qui porte le même email principal = " +str(diction['email']))
|
||||
|
||||
return False, " - Vous avez déjà un client qui a le même email principal "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des données fournies en entrée
|
||||
"""
|
||||
data = {}
|
||||
data['partner_recid'] = my_partner['recid']
|
||||
data['partner_owner_recid'] = my_partner['recid']
|
||||
data['is_prospect'] = "1"
|
||||
|
||||
raison_sociale = ""
|
||||
if ("raison_sociale" in diction.keys()):
|
||||
if diction['raison_sociale']:
|
||||
raison_sociale = diction['raison_sociale']
|
||||
data['raison_sociale'] = diction['raison_sociale']
|
||||
|
||||
nom = ""
|
||||
if ("nom" in diction.keys()):
|
||||
if diction['nom']:
|
||||
nom = diction['nom']
|
||||
data['nom'] = nom
|
||||
|
||||
siret = ""
|
||||
if ("siret" in diction.keys()):
|
||||
if diction['siret']:
|
||||
siret = diction['siret']
|
||||
data['siret'] = siret
|
||||
|
||||
client_type_id = ""
|
||||
if ("client_type_id" in diction.keys()):
|
||||
if diction['client_type_id']:
|
||||
client_type_id = diction['client_type_id']
|
||||
data['client_type_id'] = client_type_id
|
||||
|
||||
is_company = "0"
|
||||
if ("is_company" in diction.keys()):
|
||||
if diction['is_company']:
|
||||
is_company = diction['is_company']
|
||||
data['is_company'] = is_company
|
||||
|
||||
invoice_automatique = ""
|
||||
if ("invoice_automatique" in diction.keys()):
|
||||
if diction['invoice_automatique']:
|
||||
invoice_automatique = diction['invoice_automatique']
|
||||
data['invoice_automatique'] = invoice_automatique
|
||||
|
||||
|
||||
is_fournisseur = ""
|
||||
if ("is_fournisseur" in diction.keys() and diction['is_fournisseur']):
|
||||
if (str(diction['is_fournisseur']) not in ['0', '1']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Est Fournisseur : La valeur " + str(
|
||||
diction['is_fournisseur']) + " n'est pas autorisée. Les valeurs admises sont : 0, 1 ")
|
||||
return False, " Est Fournisseur : La valeur " + str(
|
||||
diction['is_fournisseur']) + " n'est pas autorisée. Les valeurs admises sont : 0, 1 "
|
||||
is_fournisseur = str(diction['is_fournisseur'])
|
||||
data['is_fournisseur'] = is_fournisseur
|
||||
|
||||
is_client = ""
|
||||
if ("is_client" in diction.keys() and diction['is_client']):
|
||||
if (str(diction['is_client']) not in ['0', '1']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Est Client : La valeur " + str(
|
||||
diction['is_client']) + " n'est pas autorisée. Les valeurs admises sont : 0, 1 ")
|
||||
return False, " Est Client : La valeur " + str(
|
||||
diction['is_client']) + " n'est pas autorisée. Les valeurs admises sont : 0, 1 "
|
||||
is_client = str(diction['is_client'])
|
||||
data['is_client'] = is_client
|
||||
|
||||
is_financeur = ""
|
||||
if ("is_financeur" in diction.keys() and diction['is_financeur']):
|
||||
if (str(diction['is_financeur']) not in ['0', '1']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Est Financeur : La valeur " + str(
|
||||
diction['is_financeur']) + " n'est pas autorisée. Les valeurs admises sont : 0, 1 ")
|
||||
return False, " Est Financeur : La valeur " + str(
|
||||
diction['is_financeur']) + " n'est pas autorisée. Les valeurs admises sont : 0, 1 "
|
||||
|
||||
is_financeur = str(diction['is_financeur'])
|
||||
data['is_financeur'] = is_financeur
|
||||
|
||||
|
||||
adr_adresse = ""
|
||||
if ("adr_adresse" in diction.keys()):
|
||||
if diction['adr_adresse']:
|
||||
adr_adresse = diction['adr_adresse']
|
||||
data['adr_adresse'] = adr_adresse
|
||||
|
||||
adr_code_postal = ""
|
||||
if ("adr_code_postal" in diction.keys()):
|
||||
if diction['adr_code_postal']:
|
||||
adr_code_postal = diction['adr_code_postal']
|
||||
data['adr_code_postal'] = adr_code_postal
|
||||
|
||||
adr_ville = ""
|
||||
if ("adr_ville" in diction.keys()):
|
||||
if diction['adr_ville']:
|
||||
adr_ville = diction['adr_ville']
|
||||
data['adr_ville'] = adr_ville
|
||||
|
||||
adr_pays = ""
|
||||
if ("adr_pays" in diction.keys()):
|
||||
if diction['adr_pays']:
|
||||
adr_pays = diction['siret']
|
||||
data['adr_pays'] = adr_pays
|
||||
|
||||
tva = ""
|
||||
if ("tva" in diction.keys()):
|
||||
if diction['tva']:
|
||||
tva = diction['tva']
|
||||
data['tva'] = tva
|
||||
|
||||
email = ""
|
||||
if ("email" in diction.keys()):
|
||||
if diction['email']:
|
||||
email = diction['email']
|
||||
|
||||
if( mycommon.isEmailValide(email) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - L'adresse email "+str(email)+" n'est pas valide")
|
||||
|
||||
return False, " - L'adresse email "+str(email)+" n'est pas valide "
|
||||
data['email'] = email
|
||||
|
||||
|
||||
telephone = ""
|
||||
if ("telephone" in diction.keys()):
|
||||
if diction['telephone']:
|
||||
telephone = diction['telephone']
|
||||
data['telephone'] = telephone
|
||||
|
||||
|
||||
website = ""
|
||||
if ("website" in diction.keys()):
|
||||
if diction['website']:
|
||||
website = diction['website']
|
||||
data['website'] = website
|
||||
|
||||
comment = ""
|
||||
if ("comment" in diction.keys()):
|
||||
if diction['comment']:
|
||||
comment = diction['comment']
|
||||
data['comment'] = comment
|
||||
|
||||
invoice_email = ""
|
||||
if ("invoice_email" in diction.keys()):
|
||||
if diction['invoice_email']:
|
||||
invoice_email = diction['invoice_email']
|
||||
|
||||
if (mycommon.isEmailValide(invoice_email) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - L'adresse email de facturation '" + str(invoice_email) + "' n'est pas valide")
|
||||
|
||||
return False, " - L'adresse email de facturation '" + str(invoice_email) + "' n'est pas valide "
|
||||
data['invoice_email'] = invoice_email
|
||||
|
||||
invoice_nom = ""
|
||||
if ("invoice_nom" in diction.keys()):
|
||||
if diction['invoice_nom']:
|
||||
invoice_nom = diction['invoice_nom']
|
||||
data['invoice_nom'] = invoice_nom
|
||||
|
||||
invoice_siret = ""
|
||||
if ("invoice_siret" in diction.keys()):
|
||||
if diction['invoice_siret']:
|
||||
invoice_siret = diction['invoice_siret']
|
||||
data['invoice_siret'] = invoice_siret
|
||||
|
||||
invoice_tva = ""
|
||||
if ("invoice_tva" in diction.keys()):
|
||||
if diction['invoice_tva']:
|
||||
invoice_tva = diction['invoice_tva']
|
||||
data['invoice_tva'] = invoice_tva
|
||||
|
||||
invoice_condition_paiement_id = ""
|
||||
if ("invoice_condition_paiement_id" in diction.keys()):
|
||||
if diction['invoice_condition_paiement_id']:
|
||||
invoice_condition_paiement_id = diction['invoice_condition_paiement_id']
|
||||
data['invoice_condition_paiement_id'] = invoice_condition_paiement_id
|
||||
|
||||
invoice_adresse = ""
|
||||
if ("invoice_adresse" in diction.keys()):
|
||||
if diction['invoice_adresse']:
|
||||
invoice_adresse = diction['invoice_adresse']
|
||||
data['invoice_adresse'] = invoice_adresse
|
||||
|
||||
invoice_ville = ""
|
||||
if ("invoice_ville" in diction.keys()):
|
||||
if diction['invoice_ville']:
|
||||
invoice_ville = diction['invoice_ville']
|
||||
data['invoice_ville'] =invoice_ville
|
||||
|
||||
invoice_code_postal = ""
|
||||
if ("invoice_code_postal" in diction.keys()):
|
||||
if diction['invoice_code_postal']:
|
||||
invoice_code_postal = diction['invoice_code_postal']
|
||||
data['invoice_code_postal'] = invoice_code_postal
|
||||
|
||||
invoice_pays = ""
|
||||
if ("invoice_pays" in diction.keys()):
|
||||
if diction['invoice_pays']:
|
||||
invoice_pays = diction['invoice_pays']
|
||||
data['invoice_pays'] = invoice_pays
|
||||
|
||||
list_adress = []
|
||||
line = 0
|
||||
if ("address" in diction.keys()):
|
||||
if diction['address']:
|
||||
list_adress = ast.literal_eval(diction['address'])
|
||||
data['address'] = list_adress
|
||||
for adress_val in list_adress :
|
||||
print(" ### adress_val = ", adress_val)
|
||||
address = adress_val
|
||||
data['address'][line]['recid'] = mycommon.create_user_recid()
|
||||
line = line + 1
|
||||
|
||||
"""
|
||||
/!\ : l'adresse etant directement enregistrée sur le client, alors verification que le ligne "adresse" contient bien les champs :
|
||||
- adresse, code postal, ville, pays
|
||||
"""
|
||||
|
||||
adresse_field_list_obligatoire = ['adresse', "code_postal", "ville", "pays", ]
|
||||
for val in adresse_field_list_obligatoire:
|
||||
if val not in address.keys():
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Le champ '" + val + "' est obligatoire dans l'adresse")
|
||||
return False, " Le champ '" + val + "' est obligatoire dans l'adresse",
|
||||
|
||||
|
||||
|
||||
|
||||
list_contact = ""
|
||||
if ("list_contact" in diction.keys()):
|
||||
if diction['list_contact']:
|
||||
list_contact = diction['list_contact']
|
||||
data['list_contact'] = list_contact
|
||||
|
||||
data['valide'] = '1'
|
||||
data['locked'] = '0'
|
||||
data['date_update'] = str(datetime.now())
|
||||
data['update_by'] = str(my_partner['_id'])
|
||||
|
||||
# Creation du RecId
|
||||
data['recid'] = mycommon.create_user_recid()
|
||||
|
||||
|
||||
inserted_id = ""
|
||||
inserted_id = MYSY_GV.dbname['partner_client'].insert_one(data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
" Impossible de créer le client du partner ")
|
||||
return False, " Impossible de créer le client "
|
||||
|
||||
|
||||
return True, " Le client a été correctement créé"
|
||||
|
||||
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 d'ajouter le client "
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Mise à jour contact d'un client de partner
|
||||
"""
|
||||
|
|
213
partner_order.py
213
partner_order.py
|
@ -19,7 +19,7 @@ from pymongo import MongoClient
|
|||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime, date
|
||||
from datetime import datetime, date, timedelta
|
||||
|
||||
import E_Sign_Document
|
||||
import Inscription_mgt
|
||||
|
@ -4265,13 +4265,13 @@ def Compute_Order_Header(diction):
|
|||
nb_line = nb_line + 1
|
||||
|
||||
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_montant_reduction = ", line_sum_order_line_montant_reduction)
|
||||
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_toutes_taxes = ", line_sum_order_line_montant_toutes_taxes)
|
||||
"""
|
||||
|
||||
|
||||
|
||||
header_reduction_type = ""
|
||||
|
@ -6869,3 +6869,210 @@ def Send_Quotation_Remind_Level1(diction):
|
|||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de faire la relance du devis "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction créé automatiquement un devis
|
||||
avec l'_id du lead concerée
|
||||
"""
|
||||
def Create_Automatic_Quotation(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['partner_owner_recid', 'lead_website_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 = ['partner_owner_recid', 'lead_website_id']
|
||||
|
||||
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, " Les informations fournies sont incorrectes"
|
||||
|
||||
|
||||
|
||||
local_status, my_partner = mycommon.Get_Connected_User_Partner_Data_From_RecID(str(diction['partner_owner_recid']))
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
"""
|
||||
Verifier la validité du lead_website
|
||||
"""
|
||||
is_valide_lead_website = MYSY_GV.dbname['lead_website'].count_documents({'_id':ObjectId(str(diction['lead_website_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(diction['partner_owner_recid'])})
|
||||
|
||||
if( is_valide_lead_website != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du leads est invalide ")
|
||||
return False, " L'identifiant du leads est invalide "
|
||||
|
||||
|
||||
valide_lead_website_data = MYSY_GV.dbname['lead_website'].find_one({'_id':ObjectId(str(diction['lead_website_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(diction['partner_owner_recid'])})
|
||||
|
||||
"""
|
||||
Verifier si le client existe
|
||||
"""
|
||||
client_connu = "0"
|
||||
client_blocked = "0"
|
||||
|
||||
is_client_exist_count = MYSY_GV.dbname['partner_client'].count_documents({'partner_recid':str(valide_lead_website_data['partner_owner_recid']),
|
||||
'siret':str(valide_lead_website_data['siret'])})
|
||||
|
||||
|
||||
if( is_client_exist_count == 1 ):
|
||||
is_client_exist_data = MYSY_GV.dbname['partner_client'].find_one(
|
||||
{'partner_recid': str(valide_lead_website_data['partner_owner_recid']),
|
||||
'siret': str(valide_lead_website_data['siret'])})
|
||||
|
||||
|
||||
if( is_client_exist_data['locked'] == "1" or is_client_exist_data['valide'] == "0"):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Ce client est verrouillé, impossible de créer un devis ")
|
||||
return False, " Ce client est verrouillé, impossible de créer un devis "
|
||||
|
||||
else:
|
||||
client_connu = "1"
|
||||
|
||||
|
||||
if( str(client_connu) != "1"):
|
||||
## Le clien test inconnu, il faut créer le client
|
||||
new_client_diction = {}
|
||||
new_client_diction['token'] = my_partner['token']
|
||||
|
||||
new_client_diction['raison_sociale'] = valide_lead_website_data['raison_sociale']
|
||||
new_client_diction['nom'] = valide_lead_website_data['raison_sociale']
|
||||
new_client_diction['email'] = valide_lead_website_data['email_requester']
|
||||
new_client_diction['telephone'] = valide_lead_website_data['telephone_requester']
|
||||
new_client_diction['siret'] = valide_lead_website_data['siret']
|
||||
|
||||
local_prospect_status, local_prospect_retval = partner_client.Add_Partner_Prospect(new_client_diction)
|
||||
|
||||
if( local_prospect_status is False ):
|
||||
return local_prospect_status, local_prospect_retval
|
||||
|
||||
is_client_exist_data = MYSY_GV.dbname['partner_client'].find_one(
|
||||
{'partner_recid': str(valide_lead_website_data['partner_owner_recid']),
|
||||
'siret': str(valide_lead_website_data['siret'])})
|
||||
|
||||
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
||||
expirate_date = datetime.today() + timedelta(days=90)
|
||||
expirate_date = str(expirate_date.strftime("%d/%m/%Y"))
|
||||
|
||||
|
||||
|
||||
# Creation du devis
|
||||
new_quotation_header = {}
|
||||
new_quotation_header['token'] = my_partner['token']
|
||||
new_quotation_header['order_header_client_id'] = str(is_client_exist_data['_id'])
|
||||
new_quotation_header['order_header_date_cmd'] = todays_date
|
||||
new_quotation_header['order_header_date_expiration'] = expirate_date
|
||||
new_quotation_header['order_header_type'] = "devis"
|
||||
new_quotation_header['order_header_status'] = "0"
|
||||
new_quotation_header['order_lines'] = []
|
||||
|
||||
local_create_quotation_status, local_create_quotation_retval, local_create_quotation_ref_interne = Add_Partner_Quotation(
|
||||
new_quotation_header)
|
||||
|
||||
if (local_create_quotation_status is False):
|
||||
return local_create_quotation_status, local_create_quotation_retval
|
||||
|
||||
|
||||
quotation_id = MYSY_GV.dbname['partner_order_header'].find_one({"order_header_ref_interne":str(local_create_quotation_ref_interne),
|
||||
'partner_owner_recid':str(valide_lead_website_data['partner_owner_recid'])})
|
||||
|
||||
# Recuperation de la valeur de la TVA (taux tva)
|
||||
partner_taux_tva = 20
|
||||
|
||||
if ("invoice_taux_vat" in my_partner.keys()):
|
||||
IsInt_status, IsInt_retval = mycommon.IsInt(str(my_partner['invoice_taux_vat']))
|
||||
if (IsInt_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
my_partner['invoice_taux_vat']) + "' n'est pas un taux de TVA correcte ")
|
||||
return False, " La valeur '" + str(
|
||||
my_partner['invoice_taux_vat']) + "' n'est pas un taux de TVA correcte ",
|
||||
|
||||
partner_taux_tva = IsInt_retval
|
||||
|
||||
print(" ### COMPUTE : le taux de TVA = ", str(partner_taux_tva))
|
||||
|
||||
prix_total_ht = mycommon.tryFloat( str(valide_lead_website_data['nb_person_info'])) * mycommon.tryFloat(str(valide_lead_website_data['class_sales_price']))
|
||||
line_taxe = (prix_total_ht * partner_taux_tva)/100
|
||||
|
||||
lines_node = {}
|
||||
lines_node['token'] = my_partner['token']
|
||||
lines_node['order_line_id'] = ""
|
||||
|
||||
|
||||
lines_node['order_line_status'] = "0"
|
||||
lines_node['order_line_type'] = "devis"
|
||||
lines_node['order_header_ref_interne'] = str(local_create_quotation_ref_interne)
|
||||
lines_node['order_header_id'] = str(quotation_id['_id'])
|
||||
lines_node['order_line_formation'] = valide_lead_website_data['class_internal_url']
|
||||
lines_node['order_line_qty'] = valide_lead_website_data['nb_person_info']
|
||||
lines_node['order_line_prix_unitaire'] = valide_lead_website_data['class_sales_price']
|
||||
lines_node['order_line_tax'] = str(partner_taux_tva)
|
||||
lines_node['order_line_type_reduction'] = ""
|
||||
lines_node['order_line_type_valeur'] = ""
|
||||
lines_node['order_line_montant_reduction'] = "0"
|
||||
|
||||
lines_node['order_line_tax_amount'] = str(line_taxe)
|
||||
lines_node['order_line_montant_hors_taxes'] = str(prix_total_ht)
|
||||
lines_node['order_line_montant_toutes_taxes'] = str(prix_total_ht + line_taxe)
|
||||
|
||||
|
||||
|
||||
|
||||
local_create_quotation_line_status, local_create_quotation_line_retval = Add_Update_Partner_Order_Line(lines_node)
|
||||
|
||||
if(local_create_quotation_line_status is False ):
|
||||
return local_create_quotation_line_status, local_create_quotation_line_retval
|
||||
|
||||
comput_diction = {}
|
||||
comput_diction['token'] = my_partner['token']
|
||||
comput_diction['_id'] = str(quotation_id['_id'])
|
||||
|
||||
local_retval, local_message = Compute_Order_Header(comput_diction)
|
||||
if (local_retval is False):
|
||||
mycommon.myprint(" WARNING : Apres la confirmation, La fonction compute pour l'ordre : " + str(
|
||||
comput_diction) + " n'a pas fonctionnée, ")
|
||||
|
||||
|
||||
"""
|
||||
Mettre à jour le lead pour dire qu'il a été convertie en devis
|
||||
"""
|
||||
update_data = {}
|
||||
update_data['valide'] = "0"
|
||||
update_data['quotation_ref'] = str(local_create_quotation_ref_interne)
|
||||
|
||||
|
||||
|
||||
MYSY_GV.dbname['lead_website'].update_many({'_id':ObjectId(str(valide_lead_website_data['_id']))},
|
||||
{'$set':update_data})
|
||||
|
||||
return True, "Le devis a été crée "
|
||||
|
||||
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, "Impossible de faire la relance du devis "
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue