15/09/2023 - 12h

master
cherif 2023-09-15 12:23:00 +02:00
parent 3ebb91a7a9
commit 60b0d7ac6f
4 changed files with 1756 additions and 100 deletions

View File

@ -1,14 +1,10 @@
<?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/09/2023 - 18h">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="14/09/2023 - 21h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.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$/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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_document_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_document_mgt.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" />
@ -73,13 +69,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00056" summary="30/07/23 - 17h">
<created>1690731459970</created>
<option name="number" value="00056" />
<option name="presentableId" value="LOCAL-00056" />
<option name="project" value="LOCAL" />
<updated>1690731459971</updated>
</task>
<task id="LOCAL-00057" summary="01/08/230- 21h">
<created>1690918242182</created>
<option name="number" value="00057" />
@ -416,7 +405,14 @@
<option name="project" value="LOCAL" />
<updated>1694620818831</updated>
</task>
<option name="localTasksCounter" value="105" />
<task id="LOCAL-00105" summary="14/09/2023 - 21h">
<created>1694717319294</created>
<option name="number" value="00105" />
<option name="presentableId" value="LOCAL-00105" />
<option name="project" value="LOCAL" />
<updated>1694717319295</updated>
</task>
<option name="localTasksCounter" value="106" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -431,7 +427,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="22/08/23 - 20h" />
<MESSAGE value="23/08/23 - 20h" />
<MESSAGE value="24/08/23 - 12h" />
<MESSAGE value="25/08/23 - 21h" />
@ -456,6 +451,7 @@
<MESSAGE value="11/09/23 - 19h" />
<MESSAGE value="12/09/2023 - 18h" />
<MESSAGE value="13/09/2023 - 18h" />
<option name="LAST_COMMIT_MESSAGE" value="13/09/2023 - 18h" />
<MESSAGE value="14/09/2023 - 21h" />
<option name="LAST_COMMIT_MESSAGE" value="14/09/2023 - 21h" />
</component>
</project>

File diff suppressed because it is too large Load Diff

44
main.py
View File

@ -4207,8 +4207,8 @@ def Add_Partner_Order():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Add_Partner_Order payload = ",payload)
status, retval = partner_order.Add_Partner_Order(payload)
return jsonify(status=status, message=retval)
status, retmessage, retval = partner_order.Add_Partner_Order(payload)
return jsonify(status=status, message=retmessage, retval=retval)
"""
@ -4220,8 +4220,8 @@ def Add_Partner_Quotation():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Add_Partner_Quotation payload = ",payload)
status, retval = partner_order.Add_Partner_Quotation(payload)
return jsonify(status=status, message=retval)
status, retmessage, retval = partner_order.Add_Partner_Quotation(payload)
return jsonify(status=status, message=retmessage, retval=retval)
@ -4331,6 +4331,38 @@ def Add_Update_Partner_Order_Line():
status, retval = partner_order.Add_Update_Partner_Order_Line(payload)
return jsonify(status=status, message=retval)
"""
API de confirmation d'un document (devis ou cmd)
"""
@app.route('/myclass/api/Confirm_Partner_Order_Header_And_Lines/', methods=['POST','GET'])
@crossdomain(origin='*')
def Confirm_Partner_Order_Header_And_Lines():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Confirm_Partner_Order_Header_And_Lines payload = ",payload)
status, retval = partner_order.Confirm_Partner_Order_Header_And_Lines(payload)
return jsonify(status=status, message=retval)
"""
API d'annulation d'un document (devis ou cmd)
"""
@app.route('/myclass/api/Annule_Partner_Order_Header_And_Lines/', methods=['POST','GET'])
@crossdomain(origin='*')
def Annule_Partner_Order_Header_And_Lines():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Annule_Partner_Order_Header_And_Lines payload = ",payload)
status, retval = partner_order.Annule_Partner_Order_Header_And_Lines(payload)
return jsonify(status=status, message=retval)
"""
API de suppression d'une commande entière, avec les lignes associée (commande client d'un partenaire), ceci en utilisant l'_id
"""
@ -4558,8 +4590,8 @@ def Convert_Quotation_to_Order():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Convert_Quotation_to_Order payload = ", str(payload))
status, message = partner_order.Convert_Quotation_to_Order(payload)
return jsonify(status=status, message=message)
status, message, retval = partner_order.Convert_Quotation_to_Order(payload)
return jsonify(status=status, message=message, retval=retval)

View File

@ -59,7 +59,9 @@ def Add_Partner_Order(diction):
'order_header_condition_paiement', 'order_header_ref_client', 'order_header_vendeur_id',
'order_header_ref_interne', 'order_header_total_ht', 'order_header_total_tax', 'order_header_total_ttc', 'order_header_status', 'order_header_type_reduction',
'order_header_type_reduction_valeur', 'order_header_montant_reduction', 'order_lines', 'order_header_type',
'order_header_location_type', 'order_header_origin']
'order_header_location_type', 'order_header_origin', 'order_header_tax', 'order_header_tax_amount',
'total_header_hors_taxe_after_header_reduction', 'total_header_hors_taxe_before_header_reduction', 'total_header_toutes_taxes',
'total_lines_hors_taxe_after_lines_reduction', 'total_lines_hors_taxe_before_lines_reduction', 'total_lines_montant_reduction']
"""
/!\ A noter que "order_lines" est tableau [] qui peut contenir les keys suivantes : 'order_line_formation', 'order_line_qty', 'order_line_prix_unitaire', 'order_line_tax', 'order_line_type_reduction', 'order_line_type_valeur', 'order_line_montant_reduction'
@ -72,7 +74,7 @@ def Add_Partner_Order(diction):
if val not in field_list:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
return False, " Les informations fournies sont incorrectes",
return False, " Les informations fournies sont incorrectes", False
"""
Verification des champs obligatoires
@ -83,7 +85,7 @@ def Add_Partner_Order(diction):
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",
return False, " Les informations fournies sont incorrectes", False
"""
Verification de l'identité et autorisation de l'entité qui
@ -96,7 +98,7 @@ def Add_Partner_Order(diction):
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
return local_status, my_partner, False
# Recuperation des champs
@ -119,7 +121,7 @@ def Add_Partner_Order(diction):
if( is_client_exist_count <= 0):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le client est invalide ")
return False, " - Le client est invalide "
return False, " - Le client est invalide ", False
data['order_header_client_id'] = diction['order_header_client_id']
@ -132,7 +134,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_description' fait plus de 500 caractères ")
return False, " - Le champ 'Description' fait plus de 500 caractères "
return False, " - Le champ 'Description' fait plus de 500 caractères ", False
data['order_header_description'] = diction['order_header_description']
order_header_comment = ""
@ -144,7 +146,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_comment' fait plus de 500 caractères ")
return False, " - Le champ 'Commentaire' fait plus de 500 caractères "
return False, " - Le champ 'Commentaire' fait plus de 500 caractères ", False
data['order_header_comment'] = diction['order_header_comment']
order_header_condition_paiement = ""
@ -156,7 +158,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_condition_paiement' fait plus de 255 caractères ")
return False, " - Le champ 'Condition de paiement' fait plus de 255 caractères "
return False, " - Le champ 'Condition de paiement' fait plus de 255 caractères ", False
data['order_header_condition_paiement'] = diction['order_header_condition_paiement']
order_header_ref_interne = ""
@ -168,7 +170,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_ref_interne' fait plus de 255 caractères ")
return False, " - Le champ 'ref_interne' fait plus de 255 caractères "
return False, " - Le champ 'ref_interne' fait plus de 255 caractères ", False
data['order_header_ref_interne'] = diction['order_header_ref_interne']
order_header_status = ""
@ -181,7 +183,7 @@ def Add_Partner_Order(diction):
MYSY_GV.PARTNER_ORDER_STATUS))
return False, " - Le champ 'Statut' est invalide. Les valeurs acceptées " + str(
MYSY_GV.PARTNER_ORDER_STATUS)
MYSY_GV.PARTNER_ORDER_STATUS), False
data['order_header_status'] = diction['order_header_status']
else:
data['order_header_status'] = "0"
@ -196,7 +198,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_origin' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_origin' fait plus de 255 caractères "
return False, " - Le champ 'order_header_origin' fait plus de 255 caractères ", False
data['order_header_origin'] = diction['order_header_origin']
order_header_ref_externe = ""
@ -208,7 +210,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_ref_externe' fait plus de 255 caractères ")
return False, " - Le champ 'ref_externe' fait plus de 255 caractères "
return False, " - Le champ 'ref_externe' fait plus de 255 caractères ", False
data['order_header_ref_externe'] = diction['order_header_ref_externe']
@ -222,7 +224,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_location_type' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_location_type' fait plus de 255 caractères "
return False, " - Le champ 'order_header_location_type' fait plus de 255 caractères ", False
data['order_header_location_type'] = diction['order_header_location_type']
@ -238,7 +240,7 @@ def Add_Partner_Order(diction):
if (is_employee_exist_count <= 0):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le vendeur est invalide ")
return False, " - Le vendeur est invalide "
return False, " - Le vendeur est invalide ", False
data['order_header_vendeur_id'] = diction['order_header_vendeur_id']
@ -251,7 +253,7 @@ def Add_Partner_Order(diction):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date order_header_date_cmd n'est pas au format 'jj/mm/aaaa' ")
return False, "La date de la commande n'est pas au format 'jj/mm/aaaa'"
return False, "La date de la commande n'est pas au format 'jj/mm/aaaa'", False
data['order_header_date_cmd'] = str(diction['order_header_date_cmd'])[0:10]
else:
@ -268,7 +270,7 @@ def Add_Partner_Order(diction):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date order_header_date_expiration n'est pas au format 'jj/mm/aaaa' ")
return False, "La date d'expiration de la commande n'est pas au format 'jj/mm/aaaa'"
return False, "La date d'expiration de la commande n'est pas au format 'jj/mm/aaaa'", False
data['order_header_date_expiration'] = str(diction['order_header_date_expiration'])[0:10]
@ -278,7 +280,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - La date d'expiration " + str(diction['order_header_date_expiration'])[0:10] +" doit etre postérieure à la date de la commande " + str(diction['order_header_date_cmd'])[0:10] + " ")
return False, " - La date d'expiration " + str(diction['order_header_date_expiration'])[0:10] +" doit etre postérieure à la date de la commande " + str(diction['order_header_date_cmd'])[0:10] + " "
return False, " - La date d'expiration " + str(diction['order_header_date_expiration'])[0:10] +" doit etre postérieure à la date de la commande " + str(diction['order_header_date_cmd'])[0:10] + " ", False
@ -292,7 +294,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_fact_adresse' fait plus de 500 caractères ")
return False, " - Le champ 'adresse de facturation' fait plus de 500 caractères "
return False, " - Le champ 'adresse de facturation' fait plus de 500 caractères ", False
data['order_header_adr_fact_adresse'] = diction['order_header_adr_fact_adresse']
order_header_adr_fact_code_postal = ""
@ -304,7 +306,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_fact_code_postal' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_fact_code_postal' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_fact_code_postal' fait plus de 255 caractères ", False
data['order_header_adr_fact_code_postal'] = diction['order_header_adr_fact_code_postal']
order_header_adr_fact_ville = ""
@ -316,7 +318,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_fact_ville' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_fact_ville' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_fact_ville' fait plus de 255 caractères ", False
data['order_header_adr_fact_ville'] = diction['order_header_adr_fact_ville']
order_header_adr_fact_pays = ""
@ -328,7 +330,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_fact_pays' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_fact_pays' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_fact_pays' fait plus de 255 caractères ", False
data['order_header_adr_fact_pays'] = diction['order_header_adr_fact_pays']
@ -343,7 +345,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_liv_adresse' fait plus de 500 caractères ")
return False, " - Le champ 'adresse d'exécution' fait plus de 500 caractères "
return False, " - Le champ 'adresse d'exécution' fait plus de 500 caractères ", False
data['order_header_adr_liv_adresse'] = diction['order_header_adr_liv_adresse']
order_header_adr_liv_code_postal = ""
@ -355,7 +357,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_liv_code_postal' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_liv_code_postal' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_liv_code_postal' fait plus de 255 caractères ", False
data['order_header_adr_liv_code_postal'] = diction['order_header_adr_liv_code_postal']
order_header_adr_liv_ville = ""
@ -367,7 +369,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_liv_ville' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_liv_ville' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_liv_ville' fait plus de 255 caractères ", False
data['order_header_adr_liv_ville'] = diction['order_header_adr_liv_ville']
order_header_adr_liv_pays = ""
@ -379,7 +381,7 @@ def Add_Partner_Order(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_liv_pays' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_liv_pays' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_liv_pays' fait plus de 255 caractères ", False
data['order_header_adr_liv_pays'] = diction['order_header_adr_liv_pays']
@ -407,7 +409,7 @@ def Add_Partner_Order(diction):
if val not in field_list:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Line de commande : Le champ '" + val + "' n'est pas autorisé")
return False, " Line de commande : Les informations fournies sont incorrectes",
return False, " Line de commande : Les informations fournies sont incorrectes", False
"""
Verification des champs obligatoires
@ -419,7 +421,7 @@ def Add_Partner_Order(diction):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Line de commande : La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Line de commande : Les informations fournies sont incorrectes",
return False, " Line de commande : Les informations fournies sont incorrectes", False
"""
@ -436,7 +438,7 @@ def Add_Partner_Order(diction):
if (retval_sequence_order is None or "current_val" not in retval_sequence_order.keys()):
mycommon.myprint(" Impossible de recuperer la sequence 'retval_sequence_order' ")
return False, "Impossible de recuperer la sequence 'retval_sequence_order'"
return False, "Impossible de recuperer la sequence 'retval_sequence_order'", False
current_seq_value = str(retval_sequence_order['current_val'])
new_sequence_value = int(mycommon.tryInt(current_seq_value)) + 1
@ -452,7 +454,7 @@ def Add_Partner_Order(diction):
if( existe_cmd_ref_interne_count > 0):
mycommon.myprint(
" Il existe déjà une commande avec la même reference interne "+str(data['order_header_ref_interne']))
return False, " Il existe déjà une commande avec la même reference interne "+str(data['order_header_ref_interne'])+" "
return False, " Il existe déjà une commande avec la même reference interne "+str(data['order_header_ref_interne'])+" ", False
data['valide'] = '1'
data['locked'] = '0'
@ -465,7 +467,7 @@ def Add_Partner_Order(diction):
if (not inserted_id):
mycommon.myprint(
" Impossible de créer l'entete de la commande ")
return False, "Impossible de créer l'entete de la commande "
return False, "Impossible de créer l'entete de la commande ", False
new_sequance_data_to_update = {'current_val': new_sequence_value}
@ -502,15 +504,15 @@ def Add_Partner_Order(diction):
if (not inserted_line_id):
mycommon.myprint(
" Impossible de créer la ligne la commande ")
return False, " Impossible de créer la ligne la commande "
return False, " Impossible de créer la ligne la commande ", False
return True, " La commande a été correctement créée"
return True, " La commande a été correctement créée", str(data['order_header_ref_interne'])
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 de créer la commande "
return False, " Impossible de créer la commande ", False
"""
@ -535,7 +537,10 @@ def Add_Partner_Quotation(diction):
'order_header_ref_interne', 'order_header_total_ht', 'order_header_total_tax',
'order_header_total_ttc', 'order_header_status', 'order_header_type_reduction',
'order_header_type_reduction_valeur', 'order_header_montant_reduction', 'order_lines',
'order_header_type', 'order_header_location_type', 'order_header_origin']
'order_header_type', 'order_header_location_type', 'order_header_tax', 'order_header_origin',
'order_header_tax_amount', 'total_header_hors_taxe_after_header_reduction',
'total_header_hors_taxe_before_header_reduction', 'total_header_toutes_taxes', 'total_lines_hors_taxe_after_lines_reduction',
'total_lines_hors_taxe_before_lines_reduction', 'total_lines_montant_reduction']
"""
/!\ A noter que "order_lines" est tableau [] qui peut contenir les keys suivantes : 'order_line_formation', 'order_line_qty', 'order_line_prix_unitaire', 'order_line_tax', 'order_line_type_reduction', 'order_line_type_valeur', 'order_line_montant_reduction'
@ -548,7 +553,7 @@ def Add_Partner_Quotation(diction):
if val not in field_list:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
return False, " Les informations fournies sont incorrectes",
return False, " Les informations fournies sont incorrectes", False
"""
Verification des champs obligatoires
@ -559,7 +564,7 @@ def Add_Partner_Quotation(diction):
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",
return False, " Les informations fournies sont incorrectes", False
"""
Verification de l'identité et autorisation de l'entité qui
@ -591,7 +596,7 @@ def Add_Partner_Quotation(diction):
if (is_client_exist_count <= 0):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le client est invalide ")
return False, " - Le client est invalide "
return False, " - Le client est invalide ", False
data['order_header_client_id'] = diction['order_header_client_id']
order_header_description = ""
@ -603,7 +608,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_description' fait plus de 500 caractères ")
return False, " - Le champ 'Description' fait plus de 500 caractères "
return False, " - Le champ 'Description' fait plus de 500 caractères ", False
data['order_header_description'] = diction['order_header_description']
order_header_status = ""
@ -616,7 +621,7 @@ def Add_Partner_Quotation(diction):
MYSY_GV.PARTNER_QUOTATION_STATUS))
return False, " - Le champ 'Statut' est invalide. Les valeurs acceptées " + str(
MYSY_GV.PARTNER_QUOTATION_STATUS)
MYSY_GV.PARTNER_QUOTATION_STATUS), False
data['order_header_status'] = diction['order_header_status']
else:
data['order_header_status'] = "0"
@ -631,7 +636,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_location_type' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_location_type' fait plus de 255 caractères "
return False, " - Le champ 'order_header_location_type' fait plus de 255 caractères ", False
data['order_header_location_type'] = diction['order_header_location_type']
@ -644,7 +649,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_comment' fait plus de 500 caractères ")
return False, " - Le champ 'Commentaire' fait plus de 500 caractères "
return False, " - Le champ 'Commentaire' fait plus de 500 caractères ", False
data['order_header_comment'] = diction['order_header_comment']
order_header_condition_paiement = ""
@ -656,7 +661,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_condition_paiement' fait plus de 255 caractères ")
return False, " - Le champ 'Condition de paiement' fait plus de 255 caractères "
return False, " - Le champ 'Condition de paiement' fait plus de 255 caractères ", False
data['order_header_condition_paiement'] = diction['order_header_condition_paiement']
order_header_ref_interne = ""
@ -668,7 +673,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_ref_interne' fait plus de 255 caractères ")
return False, " - Le champ 'ref_interne' fait plus de 255 caractères "
return False, " - Le champ 'ref_interne' fait plus de 255 caractères ", False
data['order_header_ref_interne'] = diction['order_header_ref_interne']
order_header_ref_externe = ""
@ -680,7 +685,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_ref_externe' fait plus de 255 caractères ")
return False, " - Le champ 'ref_externe' fait plus de 255 caractères "
return False, " - Le champ 'ref_externe' fait plus de 255 caractères ", False
data['order_header_ref_externe'] = diction['order_header_ref_externe']
order_header_origin = ""
@ -692,7 +697,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_origin' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_origin' fait plus de 255 caractères "
return False, " - Le champ 'order_header_origin' fait plus de 255 caractères ", False
data['order_header_origin'] = diction['order_header_origin']
@ -709,7 +714,7 @@ def Add_Partner_Quotation(diction):
if (is_employee_exist_count <= 0):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le vendeur est invalide ")
return False, " - Le vendeur est invalide "
return False, " - Le vendeur est invalide ", False
data['order_header_vendeur_id'] = diction['order_header_vendeur_id']
@ -722,7 +727,7 @@ def Add_Partner_Quotation(diction):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date order_header_date_cmd n'est pas au format 'jj/mm/aaaa' ")
return False, "La date de la commande n'est pas au format 'jj/mm/aaaa'"
return False, "La date de la commande n'est pas au format 'jj/mm/aaaa'", False
data['order_header_date_cmd'] = str(diction['order_header_date_cmd'])[0:10]
else:
@ -738,7 +743,7 @@ def Add_Partner_Quotation(diction):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date order_header_date_expiration n'est pas au format 'jj/mm/aaaa' ")
return False, "La date d'expiration de la commande n'est pas au format 'jj/mm/aaaa'"
return False, "La date d'expiration de la commande n'est pas au format 'jj/mm/aaaa'", False
data['order_header_date_expiration'] = str(diction['order_header_date_expiration'])[0:10]
@ -753,7 +758,7 @@ def Add_Partner_Quotation(diction):
return False, " - La date d'expiration " + str(diction['order_header_date_expiration'])[
0:10] + " doit etre postérieure à la date de la commande " + str(
diction['order_header_date_cmd'])[0:10] + " "
diction['order_header_date_cmd'])[0:10] + " ", False
## Recuperation de l'adresse de facturation
order_header_adr_fact_adresse = ""
@ -765,7 +770,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_fact_adresse' fait plus de 500 caractères ")
return False, " - Le champ 'adresse de facturation' fait plus de 500 caractères "
return False, " - Le champ 'adresse de facturation' fait plus de 500 caractères ", False
data['order_header_adr_fact_adresse'] = diction['order_header_adr_fact_adresse']
order_header_adr_fact_code_postal = ""
@ -777,7 +782,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_fact_code_postal' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_fact_code_postal' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_fact_code_postal' fait plus de 255 caractères ", False
data['order_header_adr_fact_code_postal'] = diction['order_header_adr_fact_code_postal']
order_header_adr_fact_ville = ""
@ -789,7 +794,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_fact_ville' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_fact_ville' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_fact_ville' fait plus de 255 caractères ", False
data['order_header_adr_fact_ville'] = diction['order_header_adr_fact_ville']
order_header_adr_fact_pays = ""
@ -801,7 +806,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_fact_pays' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_fact_pays' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_fact_pays' fait plus de 255 caractères ", False
data['order_header_adr_fact_pays'] = diction['order_header_adr_fact_pays']
## Recuperation de l'adresse d'exécution de la formation
@ -814,7 +819,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_liv_adresse' fait plus de 500 caractères ")
return False, " - Le champ 'adresse d'exécution' fait plus de 500 caractères "
return False, " - Le champ 'adresse d'exécution' fait plus de 500 caractères ", False
data['order_header_adr_liv_adresse'] = diction['order_header_adr_liv_adresse']
order_header_adr_liv_code_postal = ""
@ -826,7 +831,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_liv_code_postal' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_liv_code_postal' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_liv_code_postal' fait plus de 255 caractères ", False
data['order_header_adr_liv_code_postal'] = diction['order_header_adr_liv_code_postal']
order_header_adr_liv_ville = ""
@ -838,7 +843,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_liv_ville' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_liv_ville' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_liv_ville' fait plus de 255 caractères ", False
data['order_header_adr_liv_ville'] = diction['order_header_adr_liv_ville']
order_header_adr_liv_pays = ""
@ -850,7 +855,7 @@ def Add_Partner_Quotation(diction):
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_adr_liv_pays' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_adr_liv_pays' fait plus de 255 caractères "
return False, " - Le champ 'order_header_adr_liv_pays' fait plus de 255 caractères ", False
data['order_header_adr_liv_pays'] = diction['order_header_adr_liv_pays']
"""
@ -877,7 +882,7 @@ def Add_Partner_Quotation(diction):
if val not in field_list:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Line de commande : Le champ '" + val + "' n'est pas autorisé")
return False, " Line de commande : Les informations fournies sont incorrectes",
return False, " Line de commande : Les informations fournies sont incorrectes", False
"""
Verification des champs obligatoires
@ -889,7 +894,7 @@ def Add_Partner_Quotation(diction):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Line de commande : La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Line de commande : Les informations fournies sont incorrectes",
return False, " Line de commande : Les informations fournies sont incorrectes", False
"""
@ -906,7 +911,7 @@ def Add_Partner_Quotation(diction):
if (retval_sequence_order is None or "current_val" not in retval_sequence_order.keys()):
mycommon.myprint(" Impossible de recuperer la sequence 'retval_sequence_order' ")
return False, "Impossible de recuperer la sequence 'retval_sequence_order'"
return False, "Impossible de recuperer la sequence 'retval_sequence_order'", False
current_seq_value = str(retval_sequence_order['current_val'])
new_sequence_value = int(mycommon.tryInt(current_seq_value)) + 1
@ -923,7 +928,7 @@ def Add_Partner_Quotation(diction):
mycommon.myprint(
" Il existe déjà une commande avec la même reference interne " + str(data['order_header_ref_interne']))
return False, " Il existe déjà une commande avec la même reference interne " + str(
data['order_header_ref_interne']) + " "
data['order_header_ref_interne']) + " ", False
data['valide'] = '1'
data['locked'] = '0'
@ -935,7 +940,7 @@ def Add_Partner_Quotation(diction):
if (not inserted_id):
mycommon.myprint(
" Impossible de créer l'entete de la commande ")
return False, "Impossible de créer l'entete de la commande "
return False, "Impossible de créer l'entete de la commande ", False
new_sequance_data_to_update = {'current_val': new_sequence_value}
ret_val2 = MYSY_GV.dbname['mysy_sequence'].find_one_and_update(
@ -970,14 +975,14 @@ def Add_Partner_Quotation(diction):
if (not inserted_line_id):
mycommon.myprint(
" Impossible de créer la ligne la commande ")
return False, " Impossible de créer la ligne la commande "
return False, " Impossible de créer la ligne la commande ", False
return True, " La commande a été correctement créée"
return True, " La commande a été correctement créée", str(data['order_header_ref_interne'])
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 de créer la commande "
return False, " Impossible de créer la commande ", False
"""
@ -2122,9 +2127,304 @@ def Add_Update_Partner_Order_Line(diction):
"""
Fonction qui permet de confirmer un document, passer du statut brouillon, au statut confirmé,
pour devis et pr commande.
Seules order au statut : Brouillon ou En cours, sont confirmables.
/!\ : Apres la confirmation, on procede au calcul des totaux (compute Order)
"""
def Confirm_Partner_Order_Header_And_Lines(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'order_header_id', ]
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é")
return False, " Les informations fournies sont incorrectes",
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'order_header_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",
"""
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']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
order_header_id = ""
if ("order_header_id" in diction.keys()):
if diction['order_header_id']:
order_header_id = diction['order_header_id']
my_order_data_count = MYSY_GV.dbname['partner_order_header'].count_documents(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'_id': ObjectId(str(order_header_id))})
if (my_order_data_count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - L'identifiant de la commande est invalide ")
return False, " L'identifiant de la commande est invalide",
"""
Recuperation et stockage des données de l'entete avant mise à jour
"""
my_order_data_previous_information = MYSY_GV.dbname['partner_order_header'].find_one(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'_id': ObjectId(str(order_header_id))})
if( str(my_order_data_previous_information['order_header_status']) != "0" and str(my_order_data_previous_information['order_header_status']) != "1"):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Le document doit être au statut 'en cours' ou 'brouillon' pour avant d'être confirmé ")
return False, " Le document doit être au statut 'en cours' ou 'brouillon' pour avant d'être confirmé ",
# Si la l'order est un devis, on verifie s'il n'a pas expiré
mytoday = datetime.today().strftime("%d/%m/%Y")
if ( str(my_order_data_previous_information['order_header_date_expiration']) == "devis" and "order_header_date_expiration" in my_order_data_previous_information.keys() and len(
str(my_order_data_previous_information['order_header_date_expiration']).strip()) > 0):
if (datetime.strptime(str(my_order_data_previous_information['order_header_date_expiration']).strip(),
'%d/%m/%Y') < datetime.strptime(str(mytoday), '%d/%m/%Y')):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Le devis a expiré ")
return False, " Le devis a expiré", False
"""
/!\ : A present que tous les controles sont ok, on va proceder à la creation dans les table.
"""
### 1 - Mise à jour de l'entete
# Recuperation des champs
data = {}
data['date_update'] = str(datetime.now())
data['order_header_status'] = "1"
print(" ### Update_partner_order data = ", data)
inserted_data = MYSY_GV.dbname['partner_order_header'].find_one_and_update(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'_id': ObjectId(str(order_header_id))},
{"$set": data},
return_document=ReturnDocument.AFTER,
upsert=False,
)
if (inserted_data is None):
mycommon.myprint(
" Impossible de mettre à jour l'entete de commande ")
return False, "Impossible de mettre à jour l'entete de commande "
"""
Mise à jour des lignes (partner_order_line) dont les status sont à 0 (brouillon)
"""
local_qry = {'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'order_header_id': str(order_header_id)
}
# print(" #### COMMANDE local_qry = ", local_qry)
inserted_data_line = MYSY_GV.dbname['partner_order_line'].update_many(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'order_header_id': str(order_header_id),
'order_line_status':'0'
},
{
"$set": {"order_line_status": "1",
'date_update': str(data['date_update'])}
})
"""print("raw:", inserted_data_line.raw_result)
print("acknowledged:", inserted_data_line.acknowledged)
print("matched_count:", inserted_data_line.matched_count)"""
comput_diction = {}
comput_diction['token'] = diction['token']
comput_diction['_id'] = diction['order_header_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 fonction, ")
return True, " Le document a été correctement mise à jour"
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 de confirmer le document "
"""
Fonction qui annulle un order. Seules order au statut : Brouillon ou En cours, sont annulables.
"""
def Annule_Partner_Order_Header_And_Lines(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'order_header_id', ]
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é")
return False, " Les informations fournies sont incorrectes",
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'order_header_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",
"""
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']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
order_header_id = ""
if ("order_header_id" in diction.keys()):
if diction['order_header_id']:
order_header_id = diction['order_header_id']
my_order_data_count = MYSY_GV.dbname['partner_order_header'].count_documents(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'_id': ObjectId(str(order_header_id))})
if (my_order_data_count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - L'identifiant de la commande est invalide ")
return False, " L'identifiant de la commande est invalide",
"""
Recuperation et stockage des données de l'entete avant mise à jour
"""
my_order_data_previous_information = MYSY_GV.dbname['partner_order_header'].find_one(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'_id': ObjectId(str(order_header_id))})
if( str(my_order_data_previous_information['order_header_status']) != "0" and str(my_order_data_previous_information['order_header_status']) != "1"):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Le document doit être au statut 'en cours' ou 'brouillon' pour avant d'être annulé ")
return False, " Le document doit être au statut 'en cours' ou 'brouillon' pour avant d'être annulé ",
"""
/!\ : A present que tous les controles sont ok, on va proceder à la creation dans les table.
"""
### 1 - Mise à jour de l'entete
# Recuperation des champs
data = {}
data['date_update'] = str(datetime.now())
data['order_header_status'] = "-1"
print(" ### Update_partner_order data = ", data)
inserted_data = MYSY_GV.dbname['partner_order_header'].find_one_and_update(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'_id': ObjectId(str(order_header_id))},
{"$set": data},
return_document=ReturnDocument.AFTER,
upsert=False,
)
if (inserted_data is None):
mycommon.myprint(
" Impossible de mettre à jour l'entete de commande ")
return False, "Impossible de mettre à jour l'entete de commande "
"""
Mise à jour des lignes (partner_order_line) dont les status sont à 0 (brouillon)
"""
local_qry = {'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'order_header_id': str(order_header_id)
}
# print(" #### COMMANDE local_qry = ", local_qry)
inserted_data_line = MYSY_GV.dbname['partner_order_line'].update_many(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'order_header_id': str(order_header_id),
'order_line_status':'0'
},
{
"$set": {"order_line_status": "-1",
'date_update': str(data['date_update'])}
})
"""print("raw:", inserted_data_line.raw_result)
print("acknowledged:", inserted_data_line.acknowledged)
print("matched_count:", inserted_data_line.matched_count)"""
return True, " Le document a été correctement annulé"
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'annuler le document "
"""
Fonction de suppression d'une commande client (entete et ligne) si son statut le permet en prenant le '_id'
un devis est supprimable à tout moment, mais une commande FACTURE ou TRAITE n'est pas supprimable
2 => Traité (prêt à être facturée)
3 => Facturé (la facture est traitée dans un autre document).
"""
def Delete_Partner_Order_Header_And_Lines(diction):
try:
@ -2175,9 +2475,7 @@ def Delete_Partner_Order_Header_And_Lines(diction):
# Verifier que la commande existe et qu'elle est supprimable.
Pour les ligne, on fait pareil, on ne peut modifier que celles qui sont modifiable.
Conditions pour modifier entete :
1 - statut est : annulé, devis, cmd, MAIS PAS FACTURE
Pour un debut pas de facturation partielle. c'est tout ou rien.
"""
my_order_data_count = MYSY_GV.dbname['partner_order_header'].count_documents(
{'partner_owner_recid': str(my_partner['recid']),
@ -2189,6 +2487,47 @@ def Delete_Partner_Order_Header_And_Lines(diction):
str(inspect.stack()[0][3]) + " - L'identifiant de la commande est invalide ")
return False, " L'identifiant de la commande est invalide",
# Verifier que la commande / devis est supprimable :
my_order_data = MYSY_GV.dbname['partner_order_header'].find_one(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'_id': ObjectId(str(order_header_id))})
if( my_order_data['order_header_type'] == "commande" and my_order_data['order_header_status'] == "2"):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Cette commande a été traitée, impossible de la supprimer")
return False, " Cette commande a été traitée, impossible de la supprimer",
if (my_order_data['order_header_type'] == "commande" and my_order_data[
'order_header_status'] == "3"):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Cette commande a été facturée, impossible de la supprimer")
return False, " Cette commande a été facturée, impossible de la supprimer",
# Verifier qu'il n'y pas des lignes (partner_order_line) traitée ou facturé... (cas des facturations partielles à venir)
qry_line_count_cancel = {'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'order_header_id': str(order_header_id),
'order_header_ref_interne':str(my_order_data['order_header_ref_interne']),
'order_line_status':{'$in':['2', '3']}}
print(" #### qry_line_count_cancel = ", qry_line_count_cancel)
my_order_line_not_cancel_data_count = MYSY_GV.dbname['partner_order_line'].count_documents(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0',
'order_header_id': str(order_header_id),
'order_header_ref_interne':str(my_order_data['order_header_ref_interne']),
'order_line_status':{'$in':['2', '3']}})
if( my_order_line_not_cancel_data_count > 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Cette commande contient des lignes traitées ou facturées. Impossible de supprimer le document ")
return False, " Cette commande contient des lignes traitées ou facturées. Impossible de supprimer le document ",
# Recuperation des champs
data = {}
data['partner_owner_recid'] = my_partner['recid']
@ -3020,6 +3359,7 @@ def Get_List_Partner_Order_no_filter(diction):
find_qry = {'$and': [{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0'}, {}, ]}
new_myquery_find_order = [{'$match': find_qry},
{ '$sort': {'_id': -1}},
{"$addFields": {"partner_order_header_Id": {"$toString": "$_id"}}},
{'$lookup':
{
@ -4161,6 +4501,14 @@ def Send_Partner_Order_By_Email(diction):
"""
Conversion un devis en commande.
Cette fonction prends uniquement un devis, le duplique avec en mettant le type = commande
condition de conversion :
- Commande type = devis
- status devis = En cours => valeur 1
- Devis pas expiré
"""
def Convert_Quotation_to_Order(diction):
try:
@ -4170,7 +4518,7 @@ def Convert_Quotation_to_Order(diction):
if val not in field_list:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, "Les informations fournies sont incorrectes"
return False, "Les informations fournies sont incorrectes", False
"""
Verification de la liste des champs obligatoires
@ -4181,7 +4529,7 @@ def Convert_Quotation_to_Order(diction):
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 "
return False, " Les informations fournies sont incorrectes ", False
query_get_data = {}
mytoken = ""
@ -4191,9 +4539,9 @@ def Convert_Quotation_to_Order(diction):
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
return local_status, my_partner, False
# Verification de la validité de l'order
# Verification de la validité du devis à convertir
qry = {'_id': ObjectId(str(diction['order_id'])), 'valide': '1', 'locked': '0','order_header_type':'devis',
'partner_owner_recid': str(my_partner['recid'])}
print(" ### qry = ", qry)
@ -4206,7 +4554,7 @@ def Convert_Quotation_to_Order(diction):
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",
return False, " La commande n'est pas valide", False
Quotation_header_data_tmp = MYSY_GV.dbname['partner_order_header'].find_one(
{'_id': ObjectId(str(diction['order_id'])),
@ -4216,6 +4564,20 @@ def Convert_Quotation_to_Order(diction):
my_partner['recid'])},
)
if( Quotation_header_data_tmp['order_header_status'] != '1'):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Le statut du devis n'est pas 'en cours'")
return False, " Le statut du devis n'est pas 'en cours'", False
mytoday = datetime.today().strftime("%d/%m/%Y")
if( "order_header_date_expiration" in Quotation_header_data_tmp.keys() and len(str(Quotation_header_data_tmp['order_header_date_expiration']).strip()) > 0):
if (datetime.strptime(str(Quotation_header_data_tmp['order_header_date_expiration']).strip(), '%d/%m/%Y') < datetime.strptime(str(mytoday), '%d/%m/%Y') ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Le devis a expiré ")
return False, " Le devis a expiré", False
Quotation_header_data = MYSY_GV.dbname['partner_order_header'].find_one({'_id': ObjectId(str(diction['order_id'])),
'valide': '1', 'locked': '0',
@ -4232,16 +4594,18 @@ def Convert_Quotation_to_Order(diction):
New_Order_Header['order_header_type'] = "commande"
New_Order_Header['token'] = mytoken
local_status, local_retval = Add_Partner_Order(New_Order_Header)
local_status, local_message, local_retval = Add_Partner_Order(New_Order_Header)
if( local_status is False ):
return local_status, local_retval
return local_status, local_message, False
new_created_order = MYSY_GV.dbname['partner_order_header'].find_one({'order_header_origin':str(Quotation_header_data_tmp['order_header_ref_interne'])})
print(" La nouvelle Entete a été créer le num_order = ", new_created_order['order_header_ref_interne'])
new_created_order = MYSY_GV.dbname['partner_order_header'].find_one({'order_header_ref_interne':str(local_retval)})
print(" ### La nouvelle Entete a été créer le num_order = ", new_created_order['order_header_ref_interne'])
# Traitement des ligne
cpt_line = 0
for Quotation_line_data in MYSY_GV.dbname['partner_order_line'].find({'order_header_id': str(diction['order_id']),
'valide': '1', 'locked': '0',
'order_line_type':'devis',
@ -4260,11 +4624,15 @@ def Convert_Quotation_to_Order(diction):
New_Order_Line['order_line_status'] = "0"
local_add_line_status, local_add_line_retval = Add_Update_Partner_Order_Line(New_Order_Line)
print(" Ligne = ", cpt_line)
cpt_line = cpt_line + 1
return True, " Le devis a été correctement convertit en commande "
mycommon.myprint(
str(inspect.stack()[0][3]) + " Le devis "+str(Quotation_header_data_tmp['order_header_ref_interne'])+" a été correctement convertie en commande avec le numero : "+ new_created_order['order_header_ref_interne'])
return True, " Le devis a été correctement convertit en commande. Ref. Commande est : "+str(str(new_created_order['order_header_ref_interne'])), str(new_created_order['order_header_ref_interne'])
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 convertir le devis en commande"
return False, "Impossible de convertir le devis en commande", False