11/09/23 - 19h
parent
1c77a5aaa9
commit
1c0d157468
|
@ -1,8 +1,12 @@
|
|||
<?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="08/09/2023 - 18h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="11/09/23 - 12h30">
|
||||
<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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_order.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_order.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -66,13 +70,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00052" summary="26/07/23 - 23h">
|
||||
<created>1690405587653</created>
|
||||
<option name="number" value="00052" />
|
||||
<option name="presentableId" value="LOCAL-00052" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1690405587654</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00053" summary="27/07/23 - 23h">
|
||||
<created>1690491310678</created>
|
||||
<option name="number" value="00053" />
|
||||
|
@ -409,7 +406,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1694191147618</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="101" />
|
||||
<task id="LOCAL-00101" summary="11/09/23 - 12h30">
|
||||
<created>1694428238749</created>
|
||||
<option name="number" value="00101" />
|
||||
<option name="presentableId" value="LOCAL-00101" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1694428238750</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="102" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -424,7 +428,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="20/08/23 - 23h30" />
|
||||
<MESSAGE value="21/08/23 - 15h" />
|
||||
<MESSAGE value="21/08/23 - 21h" />
|
||||
<MESSAGE value="22/08/23 - 13h" />
|
||||
|
@ -449,6 +452,7 @@
|
|||
<MESSAGE value="06/09/2023 - 13h" />
|
||||
<MESSAGE value="07/09/2023 - 14h" />
|
||||
<MESSAGE value="08/09/2023 - 18h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="08/09/2023 - 18h30" />
|
||||
<MESSAGE value="11/09/23 - 12h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="11/09/23 - 12h30" />
|
||||
</component>
|
||||
</project>
|
1787
Log/log_file.log
1787
Log/log_file.log
File diff suppressed because it is too large
Load Diff
29
main.py
29
main.py
|
@ -4277,6 +4277,21 @@ def Get_List_Partner_Order_with_filter():
|
|||
status, retval = partner_order.Get_List_Partner_Order_with_filter(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API qui permet de recuperer le detail d'un lignes de la collection "partner_order_line"
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_Line_Of_Partner_Order_Lines/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_Line_Of_Partner_Order_Lines():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_Line_Of_Partner_Order_Lines payload = ",payload)
|
||||
status, retval = partner_order.Get_Given_Line_Of_Partner_Order_Lines(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de mise à jour d'une entete de commande client d'un partenaire
|
||||
"""
|
||||
|
@ -4365,6 +4380,20 @@ def Get_Given_Partner_Order_Lines():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API de compute d'un partner_order (calcul des totaux)
|
||||
"""
|
||||
@app.route('/myclass/api/Compute_Order_Header/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Compute_Order_Header():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Compute_Order_Header payload = ",payload)
|
||||
status, retval = partner_order.Compute_Order_Header(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de recuperation des lignes de commande (partner_order_line) en utilisant le order_header_ref_interne
|
||||
"""
|
||||
|
|
472
partner_order.py
472
partner_order.py
|
@ -1134,6 +1134,32 @@ def Update_Partner_Order_Header(diction):
|
|||
return False, " - Le champ 'ref_externe' fait plus de 255 caractères "
|
||||
data['order_header_ref_externe'] = diction['order_header_ref_externe']
|
||||
|
||||
order_header_type_reduction = ""
|
||||
if ("order_header_type_reduction" in diction.keys()):
|
||||
order_header_type_reduction = diction['order_header_type_reduction']
|
||||
if ( order_header_type_reduction not in ['fixe', 'percent']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'type de reduction ' n'est pas valide ")
|
||||
|
||||
return False, " - Le champ 'type de reduction ' n'est pas valide "
|
||||
data['order_header_type_reduction'] = diction['order_header_type_reduction']
|
||||
|
||||
order_header_type_reduction_valeur = ""
|
||||
if ("order_header_type_reduction_valeur" in diction.keys()):
|
||||
order_header_type_reduction_valeur = diction['order_header_type_reduction_valeur']
|
||||
local_status, local_retval = mycommon.IsFloat(order_header_type_reduction_valeur)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'valeur de reduction ' n'est pas valide ")
|
||||
|
||||
return False, " - Le champ 'valeur de reduction ' n'est pas valide "
|
||||
data['order_header_type_reduction_valeur'] = local_retval
|
||||
|
||||
|
||||
|
||||
|
||||
order_header_vendeur_id = ""
|
||||
if ("order_header_vendeur_id" in diction.keys()):
|
||||
order_header_vendeur_id = diction['order_header_vendeur_id']
|
||||
|
@ -1550,6 +1576,31 @@ def Update_Partner_Quotation_Header(diction):
|
|||
return False, " - Le champ 'ref_externe' fait plus de 255 caractères "
|
||||
data['order_header_ref_externe'] = diction['order_header_ref_externe']
|
||||
|
||||
order_header_type_reduction = ""
|
||||
if ("order_header_type_reduction" in diction.keys()):
|
||||
order_header_type_reduction = diction['order_header_type_reduction']
|
||||
if (order_header_type_reduction not in ['fixe', 'percent']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'type de reduction ' n'est pas valide ")
|
||||
|
||||
return False, " - Le champ 'type de reduction ' n'est pas valide "
|
||||
data['order_header_type_reduction'] = diction['order_header_type_reduction']
|
||||
|
||||
order_header_type_reduction_valeur = ""
|
||||
if ("order_header_type_reduction_valeur" in diction.keys()):
|
||||
order_header_type_reduction_valeur = diction['order_header_type_reduction_valeur']
|
||||
local_status, local_retval = mycommon.IsFloat(order_header_type_reduction_valeur)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'valeur de reduction ' n'est pas valide ")
|
||||
|
||||
return False, " - Le champ 'valeur de reduction ' n'est pas valide "
|
||||
data['order_header_type_reduction_valeur'] = local_retval
|
||||
|
||||
|
||||
|
||||
order_header_vendeur_id = ""
|
||||
if ("order_header_vendeur_id" in diction.keys()):
|
||||
order_header_vendeur_id = diction['order_header_vendeur_id']
|
||||
|
@ -1793,7 +1844,8 @@ def Add_Update_Partner_Order_Line(diction):
|
|||
field_list = ['token', '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', 'order_line_id', 'order_header_ref_interne',
|
||||
'order_header_id', 'order_line_status', 'order_line_type', 'order_line_comment']
|
||||
'order_header_id', 'order_line_status', 'order_line_type', 'order_line_comment',
|
||||
'order_line_montant_hors_taxes', 'order_line_tax_amount', 'order_line_montant_toutes_taxes']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -1890,6 +1942,24 @@ def Add_Update_Partner_Order_Line(diction):
|
|||
order_line_tax = diction['order_line_tax']
|
||||
data['order_line_tax'] = order_line_tax
|
||||
|
||||
order_line_tax_amount = ""
|
||||
if ("order_line_tax_amount" in diction.keys()):
|
||||
if diction['order_line_tax_amount']:
|
||||
order_line_tax_amount = diction['order_line_tax_amount']
|
||||
data['order_line_tax_amount'] = order_line_tax_amount
|
||||
|
||||
order_line_montant_toutes_taxes = ""
|
||||
if ("order_line_montant_toutes_taxes" in diction.keys()):
|
||||
if diction['order_line_montant_toutes_taxes']:
|
||||
order_line_montant_toutes_taxes = diction['order_line_montant_toutes_taxes']
|
||||
data['order_line_montant_toutes_taxes'] = order_line_montant_toutes_taxes
|
||||
|
||||
order_line_montant_hors_taxes = ""
|
||||
if ("order_line_montant_hors_taxes" in diction.keys()):
|
||||
if diction['order_line_montant_hors_taxes']:
|
||||
order_line_montant_hors_taxes = diction['order_line_montant_hors_taxes']
|
||||
data['order_line_montant_hors_taxes'] = order_line_montant_hors_taxes
|
||||
|
||||
|
||||
order_line_type_reduction = ""
|
||||
if ("order_line_type_reduction" in diction.keys()):
|
||||
|
@ -2464,6 +2534,44 @@ def Get_Given_Partner_Order_Lines(diction):
|
|||
user['order_header_ref_interne'] = retval['order_header_ref_interne']
|
||||
user['valide'] = retval['valide']
|
||||
user['locked'] = retval['locked']
|
||||
|
||||
if ("order_line_montant_reduction" in retval.keys()):
|
||||
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = "0"
|
||||
|
||||
if ("order_line_montant_toutes_taxes" in retval.keys()):
|
||||
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
|
||||
else:
|
||||
user['order_line_montant_toutes_taxes'] = "0"
|
||||
|
||||
if ("order_line_tax" in retval.keys()):
|
||||
user['order_line_tax'] = retval['order_line_tax']
|
||||
else:
|
||||
user['order_line_tax'] = ""
|
||||
|
||||
if ("order_line_tax_amount" in retval.keys()):
|
||||
user['order_line_tax_amount'] = retval['order_line_tax_amount']
|
||||
else:
|
||||
user['order_line_tax_amount'] = "0"
|
||||
|
||||
if ("order_line_type_reduction" in retval.keys()):
|
||||
user['order_line_type_reduction'] = retval['order_line_type_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = ""
|
||||
|
||||
if ("order_line_type_valeur" in retval.keys()):
|
||||
user['order_line_type_valeur'] = retval['order_line_type_valeur']
|
||||
else:
|
||||
user['order_line_type_valeur'] = "0"
|
||||
|
||||
|
||||
if ("order_line_montant_hors_taxes" in retval.keys()):
|
||||
user['order_line_montant_hors_taxes'] = retval['order_line_montant_hors_taxes']
|
||||
else:
|
||||
user['order_line_montant_hors_taxes'] = "0"
|
||||
|
||||
|
||||
user['date_update'] = retval['date_update']
|
||||
user['partner_owner_recid'] = retval['partner_owner_recid']
|
||||
user['order_line_type'] = retval['order_line_type']
|
||||
|
@ -2603,6 +2711,43 @@ def Get_Given_Partner_Order_Lines_From_order_ref_interne(diction):
|
|||
user['order_header_ref_interne'] = retval['order_header_ref_interne']
|
||||
user['valide'] = retval['valide']
|
||||
user['locked'] = retval['locked']
|
||||
|
||||
if( "order_line_montant_reduction" in retval.keys()):
|
||||
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = "0"
|
||||
|
||||
if ("order_line_montant_toutes_taxes" in retval.keys()):
|
||||
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
|
||||
else:
|
||||
user['order_line_montant_toutes_taxes'] = "0"
|
||||
|
||||
if( "order_line_tax" in retval.keys()):
|
||||
user['order_line_tax'] = retval['order_line_tax']
|
||||
else:
|
||||
user['order_line_tax'] = ""
|
||||
|
||||
if( "order_line_tax_amount" in retval.keys()):
|
||||
user['order_line_tax_amount'] = retval['order_line_tax_amount']
|
||||
else:
|
||||
user['order_line_tax_amount'] = "0"
|
||||
|
||||
if( "order_line_type_reduction" in retval.keys()):
|
||||
user['order_line_type_reduction'] = retval['order_line_type_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = ""
|
||||
|
||||
if( "order_line_type_valeur" in retval.keys()):
|
||||
user['order_line_type_valeur'] = retval['order_line_type_valeur']
|
||||
else:
|
||||
user['order_line_type_valeur'] = "0"
|
||||
|
||||
if ("order_line_montant_hors_taxes" in retval.keys()):
|
||||
user['order_line_montant_hors_taxes'] = retval['order_line_montant_hors_taxes']
|
||||
else:
|
||||
user['order_line_montant_hors_taxes'] = "0"
|
||||
|
||||
|
||||
user['date_update'] = retval['date_update']
|
||||
user['partner_owner_recid'] = retval['partner_owner_recid']
|
||||
user['order_line_type'] = retval['order_line_type']
|
||||
|
@ -3047,4 +3192,329 @@ def Get_List_Partner_Order_with_filter(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de recuperer la liste des commandes "
|
||||
|
||||
"""
|
||||
Cette fonction permet de recuperer une ligne de detail de commande donnée
|
||||
c'est a dire, une ligne de la collection 'partner_order_line'
|
||||
"""
|
||||
def Get_Given_Line_Of_Partner_Order_Lines(diction):
|
||||
try:
|
||||
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'order_line_id', 'order_header_ref_interne']
|
||||
|
||||
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'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'order_line_id', 'order_header_ref_interne']
|
||||
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
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['order_line_id'] = str(diction['order_line_id'])
|
||||
data_cle['order_header_ref_interne'] = str(diction['order_header_ref_interne'])
|
||||
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
|
||||
filt_order_line_id = {'_id': ObjectId(str(diction['order_line_id']))}
|
||||
filt_order_line_header_ref_interne = {'order_header_ref_interne': str(diction['order_header_ref_interne'])}
|
||||
|
||||
query = [{'$match': {'$and': [ filt_order_line_id,filt_order_line_header_ref_interne,
|
||||
{'partner_owner_recid': str(my_partner['recid'])}]}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'myclass',
|
||||
'localField': 'order_line_formation',
|
||||
'foreignField': 'internal_url',
|
||||
'pipeline': [{'$match': {'$and': [ filt_class_partner_recid]}},
|
||||
{'$project': {'title': 1, 'domaine': 1,
|
||||
'duration': 1,
|
||||
'duration_unit': 1}}],
|
||||
'as': 'myclass_collection'
|
||||
}
|
||||
}
|
||||
]
|
||||
print("#### Get_Given_Partner_Order_Lines : query pip= ", query)
|
||||
|
||||
for retval in MYSY_GV.dbname['partner_order_line'].aggregate(query):
|
||||
if ('myclass_collection' in retval.keys() and len(retval['myclass_collection']) > 0):
|
||||
user = {}
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
user['_id'] = retval['_id']
|
||||
user['order_line_formation'] = retval['order_line_formation']
|
||||
user['order_line_qty'] = retval['order_line_qty']
|
||||
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
|
||||
user['order_header_id'] = retval['order_header_id']
|
||||
user['order_header_ref_interne'] = retval['order_header_ref_interne']
|
||||
|
||||
if ("order_line_montant_reduction" in retval.keys()):
|
||||
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = "0"
|
||||
|
||||
if ("order_line_montant_toutes_taxes" in retval.keys()):
|
||||
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
|
||||
else:
|
||||
user['order_line_montant_toutes_taxes'] = "0"
|
||||
|
||||
if ("order_line_tax" in retval.keys()):
|
||||
user['order_line_tax'] = retval['order_line_tax']
|
||||
else:
|
||||
user['order_line_tax'] = ""
|
||||
|
||||
if ("order_line_tax_amount" in retval.keys()):
|
||||
user['order_line_tax_amount'] = retval['order_line_tax_amount']
|
||||
else:
|
||||
user['order_line_tax_amount'] = "0"
|
||||
|
||||
if ("order_line_type_reduction" in retval.keys()):
|
||||
user['order_line_type_reduction'] = retval['order_line_type_reduction']
|
||||
else:
|
||||
user['order_line_montant_reduction'] = ""
|
||||
|
||||
if ("order_line_type_valeur" in retval.keys()):
|
||||
user['order_line_type_valeur'] = retval['order_line_type_valeur']
|
||||
else:
|
||||
user['order_line_type_valeur'] = "0"
|
||||
|
||||
if ("order_line_montant_hors_taxes" in retval.keys()):
|
||||
user['order_line_montant_hors_taxes'] = retval['order_line_montant_hors_taxes']
|
||||
else:
|
||||
user['order_line_montant_hors_taxes'] = "0"
|
||||
|
||||
|
||||
user['valide'] = retval['valide']
|
||||
user['locked'] = retval['locked']
|
||||
user['date_update'] = retval['date_update']
|
||||
user['partner_owner_recid'] = retval['partner_owner_recid']
|
||||
user['order_line_type'] = retval['order_line_type']
|
||||
user['order_line_status'] = retval['order_line_status']
|
||||
|
||||
if( "order_line_comment" in retval.keys()):
|
||||
user['order_line_comment'] = retval['order_line_comment']
|
||||
else:
|
||||
user['order_line_comment'] = ""
|
||||
|
||||
user['title'] = retval['myclass_collection'][0]['title']
|
||||
user['domaine'] = retval['myclass_collection'][0]['domaine']
|
||||
user['duration'] = retval['myclass_collection'][0]['duration']
|
||||
user['duration_unit'] = retval['myclass_collection'][0]['duration_unit']
|
||||
|
||||
if (str(retval['myclass_collection'][0]['duration_unit']) == "heure"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " h"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "jour"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " j"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "semaine"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " s"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "mois"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " m"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "annee"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " a"
|
||||
|
||||
elif (str(retval['myclass_collection'][0]['duration_unit']) == "user_rythme"):
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " u"
|
||||
|
||||
else:
|
||||
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " ?"
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
|
||||
#print(" ### RetObject = ", RetObject)
|
||||
return True, RetObject
|
||||
|
||||
|
||||
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 recuperer les lignes de commande "
|
||||
|
||||
|
||||
""""
|
||||
Cette fonction calcul les totaux (reduction,HT, TTC, TAXES, etc) d'un commande / devis et met à jour ces info
|
||||
"""
|
||||
def Compute_Order_Header(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_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'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', '_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
|
||||
|
||||
|
||||
# Verification de la validité de l'order
|
||||
qry = {'_id':ObjectId(str(diction['_id'])), 'valide':'1', 'locked':'0', 'partner_owner_recid':str(my_partner['recid'])}
|
||||
print( " ### qry = ", qry)
|
||||
|
||||
is_Order_Existe_Count = MYSY_GV.dbname['partner_order_header'].count_documents({'_id':ObjectId(str(diction['_id'])),
|
||||
'valide':'1', 'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
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",
|
||||
|
||||
Order_header_data = MYSY_GV.dbname['partner_order_header'].find_one({'_id':ObjectId(str(diction['_id'])),
|
||||
'valide':'1', 'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
"""
|
||||
Algo :
|
||||
1 - Recuperer toutes les lignes valides, créer des sous totaux
|
||||
2 - Appliquer les eventels reductions d'entete
|
||||
"""
|
||||
|
||||
nb_line = 0
|
||||
line_sum_order_line_tax_amount = 0
|
||||
line_sum_order_line_montant_reduction = 0
|
||||
line_sum_order_line_montant_hors_taxes = 0
|
||||
line_sum_order_line_montant_hors_taxes_after_reduction = 0
|
||||
line_sum_order_line_montant_toutes_taxes = 0
|
||||
|
||||
|
||||
|
||||
for local_retval in MYSY_GV.dbname['partner_order_line'].find({'order_header_id':str(diction['_id']), 'valide':'1', 'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid']) }):
|
||||
|
||||
if( "order_line_tax_amount" in local_retval.keys()):
|
||||
line_sum_order_line_tax_amount = line_sum_order_line_tax_amount + mycommon.tryFloat(local_retval['order_line_tax_amount'])
|
||||
|
||||
if ("order_line_montant_reduction" in local_retval.keys()):
|
||||
line_sum_order_line_montant_reduction = line_sum_order_line_montant_reduction + mycommon.tryFloat(
|
||||
local_retval['order_line_montant_reduction'])
|
||||
|
||||
if ("order_line_montant_hors_taxes" in local_retval.keys()):
|
||||
line_sum_order_line_montant_hors_taxes = line_sum_order_line_montant_hors_taxes + mycommon.tryFloat(
|
||||
local_retval['order_line_montant_hors_taxes'])
|
||||
|
||||
if ("order_line_montant_toutes_taxes" in local_retval.keys()):
|
||||
line_sum_order_line_montant_toutes_taxes = line_sum_order_line_montant_toutes_taxes + mycommon.tryFloat(
|
||||
local_retval['order_line_montant_toutes_taxes'])
|
||||
|
||||
nb_line = nb_line + 1
|
||||
|
||||
line_sum_order_line_montant_hors_taxes_after_reduction = mycommon.tryFloat(line_sum_order_line_montant_hors_taxes - line_sum_order_line_montant_reduction)
|
||||
print(" ###### Apres compute des lignes : NB_LINE = ", nb_line)
|
||||
print(" ###### line_sum_order_line_tax_amount = ", line_sum_order_line_tax_amount)
|
||||
print(" ###### line_sum_order_line_montant_reduction = ", line_sum_order_line_montant_reduction)
|
||||
print(" ###### line_sum_order_line_montant_hors_taxes = ", line_sum_order_line_montant_hors_taxes)
|
||||
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 = ""
|
||||
header_reduction_type_value = ""
|
||||
if( "order_header_type_reduction" in Order_header_data.keys()):
|
||||
header_reduction_type = Order_header_data['order_header_type_reduction']
|
||||
|
||||
if ("order_header_type_reduction_valeur" in Order_header_data.keys()):
|
||||
header_reduction_type_value = Order_header_data['order_header_type_reduction_valeur']
|
||||
|
||||
print(" ### les reduction d'entete ")
|
||||
print(" ###### header_reduction_type = ", header_reduction_type)
|
||||
print(" ###### header_reduction_type_value = ", header_reduction_type_value)
|
||||
|
||||
|
||||
global_order_taxe_amount = 0
|
||||
global_order_amount_ht_before_header_reduction = line_sum_order_line_montant_hors_taxes
|
||||
global_order_amount_ht_after_header_reduction = 0
|
||||
header_reduction_type_value_total_amount = 0
|
||||
|
||||
if( str(header_reduction_type) == "fixe" ):
|
||||
header_reduction_type_value_total_amount = mycommon.tryFloat(header_reduction_type_value)
|
||||
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction - mycommon.tryFloat(header_reduction_type_value)
|
||||
|
||||
elif( str(header_reduction_type) == "percent" ):
|
||||
header_reduction_type_value_total_amount = line_sum_order_line_montant_hors_taxes_after_reduction *mycommon.tryFloat(header_reduction_type_value)/100
|
||||
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction - ((line_sum_order_line_montant_hors_taxes_after_reduction *mycommon.tryFloat(header_reduction_type_value)/100 ))
|
||||
|
||||
else:
|
||||
header_reduction_type_value_total_amount = 0
|
||||
global_order_amount_ht_before_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction
|
||||
global_order_amount_ht_after_header_reduction = line_sum_order_line_montant_hors_taxes_after_reduction
|
||||
|
||||
global_order_amount_ttc = global_order_amount_ht_after_header_reduction * 1.2
|
||||
|
||||
print(" ###### header_reduction_type_value_total_amount = ", header_reduction_type_value_total_amount)
|
||||
print(" ###### global_order_amount_ht_after_header_reduction = ", global_order_amount_ht_after_header_reduction)
|
||||
print(" ###### global_order_amount_ttc = ", global_order_amount_ttc)
|
||||
|
||||
return True, 'ok'
|
||||
|
||||
|
||||
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 recuperer les lignes de commande "
|
||||
|
|
|
@ -1238,8 +1238,6 @@ def Migration_internal_url():
|
|||
print('new_internal_url = '+new_internal_url)
|
||||
|
||||
|
||||
|
||||
|
||||
result = coll_name.update_many(
|
||||
{'_id':ObjectId(str(user['_id']))},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue