parent
ed09529c68
commit
180de3910d
|
|
@ -4,13 +4,15 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="09/05/2025 - 20h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="10/05/2026 - 12h30">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Dashbord_queries/factures_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/factures_tbd_qries.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$/Relance_client_facture.py" beforeDir="false" afterPath="$PROJECT_DIR$/Relance_client_facture.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/invoice_paiement_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/invoice_paiement_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.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_invoice.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_invoice.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
@ -454,7 +456,7 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1747251650255</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="577" />
|
||||
<option name="localTasksCounter" value="578" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
|
@ -496,7 +498,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="20/03/2026 - 20h" />
|
||||
<MESSAGE value="23/03/2026 - 20h" />
|
||||
<MESSAGE value="25/03/2026 - 20h" />
|
||||
<MESSAGE value="26/03/2026 - 12h" />
|
||||
|
|
@ -521,6 +522,7 @@
|
|||
<MESSAGE value="07/05/2026 - 17h" />
|
||||
<MESSAGE value="08/05/2026 - 17h" />
|
||||
<MESSAGE value="09/05/2025 - 20h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="09/05/2025 - 20h30" />
|
||||
<MESSAGE value="10/05/2026 - 12h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="10/05/2026 - 12h30" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -583,7 +583,7 @@ def Get_Qery_List_Factures_Data_By_Client_Periode(diction):
|
|||
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])},
|
||||
{"valide": '1'},filt_client_id,
|
||||
{"valide": '1', 'invoice_header_type':{'$ne':'brouillon'}},filt_client_id,
|
||||
|
||||
{
|
||||
'mysy_invoice_date': {'$gte': filt_periode_start_date_ISODATE,
|
||||
|
|
@ -782,7 +782,7 @@ def Get_Qery_List_Factures_Data_By_Client_V2(diction):
|
|||
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])},
|
||||
{"valide": '1'},filt_client_id,
|
||||
{"valide": '1', 'invoice_header_type':{'$ne':'brouillon'}},filt_client_id,
|
||||
|
||||
{
|
||||
'mysy_invoice_date': {'$gte': filt_periode_start_date_ISODATE,
|
||||
|
|
@ -2051,7 +2051,7 @@ def Get_Qery_List_Facture_Previsionnelle_Data_By_Periode_save(diction):
|
|||
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])},
|
||||
{"valide": '1'},filt_client_id,
|
||||
{"valide": '1', 'invoice_header_type':{'$ne':'brouillon'}},filt_client_id,
|
||||
|
||||
{
|
||||
'mysy_invoice_date': {'$gte': filt_periode_start_date_ISODATE,
|
||||
|
|
@ -2281,7 +2281,7 @@ def Get_Qery_List_Facture_Previsionnelle_Data_By_Periode(diction):
|
|||
|
||||
#print(" local_first_day_ISODATE = ", local_first_day_ISODATE)
|
||||
|
||||
qery_match = {'$and': [{"valide": '1', 'partner_owner_recid': str(my_partner['recid'])},
|
||||
qery_match = {'$and': [{"valide": '1','invoice_header_type':{'$ne':'brouillon'}, 'partner_owner_recid': str(my_partner['recid'])},
|
||||
|
||||
{
|
||||
'mysy_session_start_date': {'$lte': local_first_day_ISODATE},
|
||||
|
|
@ -2543,7 +2543,7 @@ def Get_Qery_List_Factures_For_List_Class(diction):
|
|||
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])},
|
||||
{"valide": '1'},
|
||||
{"valide": '1', 'invoice_header_type':{'$ne':'brouillon'}},
|
||||
filt_mysy_invoice_date, ]}
|
||||
|
||||
pipe_qry = ([
|
||||
|
|
@ -2883,7 +2883,7 @@ def Get_Qery_List_Factures_For_List_Inscrit(diction):
|
|||
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])},
|
||||
{"valide": '1'},
|
||||
{"valide": '1', 'invoice_header_type':{'$ne':'brouillon'}},
|
||||
filt_mysy_invoice_date, filt_gle_client_facture, filter_invoice_ref]}
|
||||
|
||||
pipe_qry = ([
|
||||
|
|
|
|||
9412
Log/log_file.log
9412
Log/log_file.log
File diff suppressed because one or more lines are too long
|
|
@ -179,32 +179,33 @@ def Add_Invoice_Paiement(diction):
|
|||
if( local_list_paiement_status is False ):
|
||||
return local_list_paiement_status, local_list_paiement_retval
|
||||
|
||||
#print(" Les payement = ", local_list_paiement_retval)
|
||||
|
||||
#print(" local_total_payed = ", local_total_payed)
|
||||
|
||||
list_payment = ast.literal_eval(local_list_paiement_retval[0])
|
||||
|
||||
print(" Les payement = ", local_list_paiement_retval)
|
||||
print(" Les payement = ", local_total_payed)
|
||||
|
||||
total_payed_amount = "0"
|
||||
if( "total_payed" in list_payment.keys() ):
|
||||
total_payed_amount = list_payment['total_payed']
|
||||
total_relicat = total_invoice_amount_float
|
||||
|
||||
local_status, local_retval = mycommon.IsFloat(total_payed_amount)
|
||||
if( local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le total payé n'est pas convertible en Float ")
|
||||
return False, " Le total payé n'est pas convertible en Float "
|
||||
if(len(local_list_paiement_retval) > 0 ):
|
||||
list_payment = ast.literal_eval(local_list_paiement_retval[0])
|
||||
|
||||
total_payed_amount_float = local_retval
|
||||
if( "total_payed" in list_payment.keys() ):
|
||||
total_payed_amount = list_payment['total_payed']
|
||||
|
||||
total_relicat = total_invoice_amount_float - total_payed_amount_float
|
||||
local_status, local_retval = mycommon.IsFloat(total_payed_amount)
|
||||
if( local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le total payé n'est pas convertible en Float ")
|
||||
return False, " Le total payé n'est pas convertible en Float "
|
||||
|
||||
total_payed_amount_float = local_retval
|
||||
|
||||
total_relicat = total_invoice_amount_float - total_payed_amount_float
|
||||
|
||||
|
||||
if( total_relicat < 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le montant du "+str(total_relicat)+" est supérieur au montant payé "+str(total_payed_amount_float))
|
||||
#return False, " Le montant du "+str(total_relicat)+" est supérieur au montant payé "+str(total_payed_amount_float)
|
||||
if( total_relicat < 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le montant du "+str(total_relicat)+" est supérieur au montant payé "+str(total_payed_amount_float))
|
||||
#return False, " Le montant du "+str(total_relicat)+" est supérieur au montant payé "+str(total_payed_amount_float)
|
||||
|
||||
|
||||
"""
|
||||
|
|
@ -831,6 +832,7 @@ def Get_Invoice_Liste_Payement_And_Total_Amount(diction):
|
|||
val_tmp = 0
|
||||
payed_amount = 0
|
||||
|
||||
print(" ### get paieùet,tt = ", qery_match)
|
||||
|
||||
for retval in MYSY_GV.dbname['invoice_paiement'].find(qery_match).sort([("_id", pymongo.DESCENDING), ]):
|
||||
user = retval
|
||||
|
|
|
|||
15
main.py
15
main.py
|
|
@ -5308,6 +5308,21 @@ def unarchive_partner_client():
|
|||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer les données diverses d'un client comme :
|
||||
- le CA des 12 derniers année
|
||||
- nb factures ouvertes, et
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Parner_Divers_Invoice_Data_12/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Parner_Divers_Invoice_Data_12():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Parner_Divers_Invoice_Data_12 : payload = ",payload)
|
||||
localStatus, message = partner_client.Get_Parner_Divers_Invoice_Data_12(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API qui permet de modifier un contact donnée (nested list) d'un client de partenaire
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import ela_index_bdd_classes as eibdd
|
|||
import email_mgt as email
|
||||
import ast
|
||||
import Contact as contact
|
||||
from datetime import datetime, timezone, date, time
|
||||
|
||||
"""
|
||||
Creation d'un client
|
||||
|
|
@ -138,6 +139,16 @@ def Add_Partner_Client(diction):
|
|||
3]) + " L'identifiant du client facturé est invalide ")
|
||||
return False, " L'identifiant du client facturé est invalide "
|
||||
|
||||
if( "responsable_compte_id" in diction.keys() and diction['responsable_compte_id']):
|
||||
is_valide_resp_compte = MYSY_GV.dbname['ressource_humaine'].count_documents({'_id':ObjectId(str(diction['responsable_compte_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_recid':str(my_partner['recid'])})
|
||||
if( is_valide_resp_compte != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " Le responsable du compte est invalide ")
|
||||
return False, " Le responsable du compte est invalide "
|
||||
|
||||
"""
|
||||
Recuperation des données fournies en entrée
|
||||
"""
|
||||
|
|
@ -167,6 +178,14 @@ def Add_Partner_Client(diction):
|
|||
else:
|
||||
data['archive'] = "0"
|
||||
|
||||
|
||||
if ("responsable_compte_id" in diction.keys()):
|
||||
data['responsable_compte_id'] = str(diction['responsable_compte_id'])
|
||||
else:
|
||||
data['responsable_compte_id'] = ""
|
||||
|
||||
|
||||
|
||||
if ("client_facturation_id" in diction.keys()):
|
||||
data['client_facturation_id'] = str(diction['client_facturation_id'])
|
||||
else:
|
||||
|
|
@ -743,6 +762,16 @@ def Add_Partner_Prospect(diction):
|
|||
|
||||
return False, " - Vous avez déjà un client qui a le même email principal "
|
||||
|
||||
if ("responsable_compte_id" in diction.keys() and diction['responsable_compte_id']):
|
||||
is_valide_resp_compte = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(diction['responsable_compte_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])})
|
||||
if (is_valide_resp_compte != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " Le responsable du compte est invalide ")
|
||||
return False, " Le responsable du compte est invalide "
|
||||
|
||||
|
||||
"""
|
||||
|
|
@ -786,6 +815,13 @@ def Add_Partner_Prospect(diction):
|
|||
is_company = diction['is_company']
|
||||
data['is_company'] = is_company
|
||||
|
||||
if ("responsable_compte_id" in diction.keys()):
|
||||
data['responsable_compte_id'] = str(diction['responsable_compte_id'])
|
||||
else:
|
||||
data['responsable_compte_id'] = ""
|
||||
|
||||
|
||||
|
||||
invoice_automatique = ""
|
||||
if ("invoice_automatique" in diction.keys()):
|
||||
if diction['invoice_automatique']:
|
||||
|
|
@ -1227,6 +1263,20 @@ def Update_Partner_Client(diction):
|
|||
3]) + " L'identifiant du client facturé est invalide ")
|
||||
return False, " L'identifiant du client facturé est invalide "
|
||||
|
||||
if ("responsable_compte_id" in diction.keys() and diction['responsable_compte_id']):
|
||||
|
||||
|
||||
is_valide_resp_compte = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(diction['responsable_compte_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])})
|
||||
if (is_valide_resp_compte != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " Le responsable du compte est invalide ")
|
||||
return False, " Le responsable du compte est invalide "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des données fournies en entrée
|
||||
"""
|
||||
|
|
@ -1260,6 +1310,11 @@ def Update_Partner_Client(diction):
|
|||
if ("archive" in diction.keys()):
|
||||
data_update['archive'] = diction['archive']
|
||||
|
||||
|
||||
if ("responsable_compte_id" in diction.keys()):
|
||||
data_update['responsable_compte_id'] = diction['responsable_compte_id']
|
||||
|
||||
|
||||
if ("client_facturation_id" in diction.keys()):
|
||||
data_update['client_facturation_id'] = diction['client_facturation_id']
|
||||
|
||||
|
|
@ -1655,6 +1710,30 @@ def Get_Partner_List_Partner_Client(diction):
|
|||
else:
|
||||
user['client_facturation_raison_sociale'] = ""
|
||||
|
||||
|
||||
responsable_compte_nom = ""
|
||||
responsable_compte_prenom = ""
|
||||
|
||||
if ("responsable_compte_id" in user.keys() and user['responsable_compte_id']):
|
||||
resp_compte_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
{'_id': ObjectId(str(user['responsable_compte_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])}, {'nom':1, 'prenom':1})
|
||||
|
||||
if( resp_compte_data and 'nom' in resp_compte_data.keys() ):
|
||||
responsable_compte_nom = resp_compte_data['nom']
|
||||
|
||||
if (resp_compte_data and 'prenom' in resp_compte_data.keys()):
|
||||
responsable_compte_prenom = resp_compte_data['prenom']
|
||||
|
||||
if( not resp_compte_data or '_id' not in resp_compte_data.keys() ):
|
||||
user['responsable_compte_id'] = ""
|
||||
|
||||
user['responsable_compte_nom_prenom'] = responsable_compte_nom+" "+responsable_compte_prenom
|
||||
|
||||
|
||||
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
|
@ -1859,6 +1938,27 @@ def Get_Partner_List_Partner_Client_with_filter_Like(diction):
|
|||
else:
|
||||
user['client_facturation_raison_sociale'] = ""
|
||||
|
||||
responsable_compte_nom = ""
|
||||
responsable_compte_prenom = ""
|
||||
|
||||
if ("responsable_compte_id" in user.keys() and user['responsable_compte_id']):
|
||||
resp_compte_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
{'_id': ObjectId(str(user['responsable_compte_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])}, {'nom': 1, 'prenom': 1})
|
||||
|
||||
if (resp_compte_data and 'nom' in resp_compte_data.keys()):
|
||||
responsable_compte_nom = resp_compte_data['nom']
|
||||
|
||||
if (resp_compte_data and 'prenom' in resp_compte_data.keys()):
|
||||
responsable_compte_prenom = resp_compte_data['prenom']
|
||||
|
||||
if (not resp_compte_data or '_id' not in resp_compte_data.keys()):
|
||||
user['responsable_compte_id'] = ""
|
||||
|
||||
user['responsable_compte_nom_prenom'] = responsable_compte_nom + " " + responsable_compte_prenom
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
|
@ -2010,6 +2110,27 @@ def Get_Given_Partner_Client(diction):
|
|||
else:
|
||||
user['client_facturation_raison_sociale'] = ""
|
||||
|
||||
responsable_compte_nom = ""
|
||||
responsable_compte_prenom = ""
|
||||
|
||||
if ("responsable_compte_id" in user.keys() and user['responsable_compte_id']):
|
||||
resp_compte_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
{'_id': ObjectId(str(user['responsable_compte_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])}, {'nom': 1, 'prenom': 1})
|
||||
|
||||
if (resp_compte_data and 'nom' in resp_compte_data.keys()):
|
||||
responsable_compte_nom = resp_compte_data['nom']
|
||||
|
||||
if (resp_compte_data and 'prenom' in resp_compte_data.keys()):
|
||||
responsable_compte_prenom = resp_compte_data['prenom']
|
||||
|
||||
if (not resp_compte_data or '_id' not in resp_compte_data.keys()):
|
||||
user['responsable_compte_id'] = ""
|
||||
|
||||
user['responsable_compte_nom_prenom'] = responsable_compte_nom + " " + responsable_compte_prenom
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
#print(" ### RetObject = ", RetObject)
|
||||
|
|
@ -2158,6 +2279,27 @@ def Get_Given_Partner_Client_From_Id(diction):
|
|||
else:
|
||||
user['client_facturation_raison_sociale'] = ""
|
||||
|
||||
responsable_compte_nom = ""
|
||||
responsable_compte_prenom = ""
|
||||
|
||||
if ("responsable_compte_id" in user.keys() and user['responsable_compte_id']):
|
||||
resp_compte_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
{'_id': ObjectId(str(user['responsable_compte_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])}, {'nom': 1, 'prenom': 1})
|
||||
|
||||
if (resp_compte_data and 'nom' in resp_compte_data.keys()):
|
||||
responsable_compte_nom = resp_compte_data['nom']
|
||||
|
||||
if (resp_compte_data and 'prenom' in resp_compte_data.keys()):
|
||||
responsable_compte_prenom = resp_compte_data['prenom']
|
||||
|
||||
if (not resp_compte_data or '_id' not in resp_compte_data.keys()):
|
||||
user['responsable_compte_id'] = ""
|
||||
|
||||
user['responsable_compte_nom_prenom'] = responsable_compte_nom + " " + responsable_compte_prenom
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
|
@ -4467,3 +4609,254 @@ def unarchive_partner_client(diction):
|
|||
|
||||
return False, " Impossible d'archiver les clients "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de recuperer quelques infos diverse sur un client :
|
||||
|
||||
1 - Le CA sur les 12 derniers mois
|
||||
2 - le nombre de facture ouverte
|
||||
3 - Le echu / en retard
|
||||
4 - Le CA en attente
|
||||
"""
|
||||
def Get_Parner_Divers_Invoice_Data_12(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'periode_start_date', 'periode_end_date', 'filter_value', 'filter_client_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 = ['token', ]
|
||||
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 la liste des arguments ")
|
||||
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
|
||||
|
||||
"""
|
||||
Definir le filter sur les 12 derniers mois, en mettant du 1er du mois
|
||||
"""
|
||||
today = date.today()
|
||||
|
||||
year = today.year
|
||||
month = today.month - 12
|
||||
|
||||
if month <= 0:
|
||||
month += 12
|
||||
year -= 1
|
||||
|
||||
date_debut_12_mois = date(year, month, 1)
|
||||
date_fin_12_mois = date.today()
|
||||
|
||||
filt_client_id = {}
|
||||
if ("filter_client_id" in diction.keys() and diction['filter_client_id']):
|
||||
filt_client_id = {'order_header_client_id': str(diction['filter_client_id'])}
|
||||
|
||||
|
||||
filt_periode_start_date = ""
|
||||
if ("periode_start_date" in diction.keys() and diction['periode_start_date']):
|
||||
filt_periode_start_date = str(diction['periode_start_date'])[0:10]
|
||||
local_status = mycommon.CheckisDate(filt_periode_start_date)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le filtre : 'date de debut' n'est pas au format jj/mm/aaaa.")
|
||||
return False, " Le filtre : 'date de debut' n'est pas au format jj/mm/aaaa."
|
||||
|
||||
filt_periode_end_date = ""
|
||||
if ("periode_end_date" in diction.keys() and diction['periode_end_date']):
|
||||
filt_periode_end_date = str(diction['periode_end_date'])[0:10]
|
||||
local_status = mycommon.CheckisDate(filt_periode_end_date)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le filtre : 'date de fin' n'est pas au format jj/mm/aaaa.")
|
||||
return False, " Le filtre : 'date de fin' n'est pas au format jj/mm/aaaa."
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Si la valeur de 'filter_value' est m0 ou m1, on va aller recuperer les date du mois correspondant.
|
||||
On ecrase les valeur de filt_session_start_date et filt_session_end_date
|
||||
"""
|
||||
|
||||
filt_periode_start_date_ISODATE = datetime.combine(date_debut_12_mois, time.min)
|
||||
filt_periode_end_date_ISODATE = datetime.combine(date_fin_12_mois, time.max)
|
||||
|
||||
|
||||
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])},
|
||||
{"valide": '1', 'invoice_header_type':{'$ne':'brouillon'}},filt_client_id,
|
||||
|
||||
{
|
||||
'mysy_invoice_date': {'$gte': filt_periode_start_date_ISODATE,
|
||||
'$lte': filt_periode_end_date_ISODATE}}, ]}
|
||||
|
||||
pipe_qry = ([
|
||||
{"$addFields": {
|
||||
"mysy_invoice_date": {
|
||||
'$dateFromString': {
|
||||
'dateString': '$invoice_date',
|
||||
'format': "%d/%m/%Y"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
{'$match': qery_match},
|
||||
|
||||
{'$project': {'reste_to_paye': 1, '_id': 1, 'invoice_date': 1,
|
||||
'invoice_header_ref_interne': 1, 'total_header_toutes_taxes':1, 'invoice_header_type':1,
|
||||
'invoice_date_echeance':1}},
|
||||
|
||||
|
||||
])
|
||||
|
||||
print(" ### Get_Qery_List_Factures_Data ici pipe_qry = ", pipe_qry)
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
total_montant_en_retard = 0
|
||||
total_montant_a_payer = 0
|
||||
total_montant_CA_TTC = 0
|
||||
total_nb_facture = 0
|
||||
|
||||
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
||||
todays_date_ISO_Date = datetime.strptime(str(todays_date).strip(), '%d/%m/%Y')
|
||||
"""
|
||||
On recupere les données, on les format dans le 'range_date_month' et on retourne"""
|
||||
for New_retVal in MYSY_GV.dbname['partner_invoice_header'].aggregate(pipe_qry):
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
"""
|
||||
Recuperation du montant des facture echue (donc en retard)
|
||||
"""
|
||||
if( "total_header_toutes_taxes" in New_retVal.keys() ):
|
||||
total_montant_CA_TTC = total_montant_CA_TTC + mycommon.tryFloat(str(New_retVal['total_header_toutes_taxes']))
|
||||
|
||||
|
||||
if ( 'invoice_date_echeance' in New_retVal.keys() and mycommon.CheckisDate(New_retVal['invoice_date_echeance'])):
|
||||
|
||||
mysy_invoice_du_date_ISO_Date = datetime.strptime(str(New_retVal['invoice_date_echeance']),
|
||||
"%d/%m/%Y")
|
||||
|
||||
# print(" CMP = "+str(todays_date_ISO_Date)+" VS "+str(mysy_invoice_du_date_ISO_Date) )
|
||||
|
||||
|
||||
|
||||
if (todays_date_ISO_Date > mysy_invoice_du_date_ISO_Date and "reste_to_paye" in New_retVal.keys() and mycommon.tryFloat( str(New_retVal['reste_to_paye'])) > 0):
|
||||
total_montant_en_retard = total_montant_en_retard + mycommon.tryFloat(str(New_retVal['reste_to_paye']))
|
||||
|
||||
else:
|
||||
total_montant_a_payer = total_montant_a_payer + mycommon.tryFloat(str(New_retVal['reste_to_paye']))
|
||||
else:
|
||||
total_montant_a_payer = total_montant_a_payer + mycommon.tryFloat(str(New_retVal['reste_to_paye']))
|
||||
|
||||
"""print(" ## total_montant_CA_TTC = ", total_montant_CA_TTC)
|
||||
print(" ## total_montant_a_payer = ", total_montant_a_payer)
|
||||
print(" ## total_montant_en_retard = ", total_montant_en_retard)"""
|
||||
|
||||
|
||||
|
||||
total_nb_facture = val_tmp
|
||||
total_paye = total_montant_CA_TTC - (total_montant_a_payer + total_montant_en_retard)
|
||||
|
||||
taux_encaissement = 0
|
||||
if( total_montant_CA_TTC != 0):
|
||||
taux_encaissement = round((total_paye / total_montant_CA_TTC) * 100, 0)
|
||||
|
||||
total_montant_attente_paiement = total_montant_a_payer + total_montant_en_retard
|
||||
|
||||
node_data = {}
|
||||
node_data['total_montant_en_retard'] = str(total_montant_en_retard)
|
||||
node_data['total_montant_a_payer'] = str(total_montant_a_payer)
|
||||
node_data['total_montant_deja_paye'] = str(total_paye)
|
||||
node_data['total_montant_attente_payement'] = str(total_montant_attente_paiement)
|
||||
node_data['total_montant_CA_TTC'] = str(total_montant_CA_TTC)
|
||||
node_data['total_nb_facture'] = str(total_nb_facture)
|
||||
node_data['taux_encaissement'] = str(taux_encaissement)
|
||||
node_data['total_paye'] = str(total_paye)
|
||||
|
||||
"""
|
||||
On va aller chercher les 3 dernière activité
|
||||
"""
|
||||
qry_activite_3 = [
|
||||
{
|
||||
"$match": {
|
||||
"partner_recid": str(my_partner["recid"]),
|
||||
"related_collection": "partner_client",
|
||||
"related_collection_id": str(diction["filter_client_id"]),
|
||||
"valide": "1",
|
||||
"locked": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"mysy_deadline_date": {
|
||||
"$dateFromString": {
|
||||
"dateString": "$deadline",
|
||||
"format": "%d/%m/%Y %H:%M",
|
||||
"onError": None,
|
||||
"onNull": None
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$sort": {
|
||||
"mysy_deadline_date": -1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$limit": 3
|
||||
},
|
||||
{"$project": {'description': 1, 'deadline': 1, 'type': 1}
|
||||
}
|
||||
]
|
||||
|
||||
print(" ## qry_activite_3 = ", qry_activite_3)
|
||||
tmp = []
|
||||
for last_activite in MYSY_GV.dbname['activite'].aggregate(qry_activite_3):
|
||||
tmp.append(last_activite)
|
||||
|
||||
node_data['tab_activite'] = tmp
|
||||
|
||||
print(" ## node_data = ", node_data)
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(node_data))
|
||||
|
||||
|
||||
|
||||
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 récupérer les données diverses du client"
|
||||
|
||||
|
|
|
|||
|
|
@ -7580,6 +7580,7 @@ def Confirm_Partner_Invoice_Header_And_Lines(diction):
|
|||
str(inspect.stack()[0][3]) + " - L'identifiant de la facture est invalide ")
|
||||
return False, " L'identifiant de la facture est invalide",
|
||||
|
||||
|
||||
"""
|
||||
Verifier qu'il y a des ligne pour cette facture
|
||||
"""
|
||||
|
|
@ -7646,6 +7647,7 @@ def Confirm_Partner_Invoice_Header_And_Lines(diction):
|
|||
data['invoice_header_ref_interne'] = invoice_ref_interne
|
||||
data['invoice_header_type'] = "facture"
|
||||
data['invoice_date'] = invoice_date_time
|
||||
data['reste_to_paye'] = str(my_order_data_previous_information['total_header_toutes_taxes'])
|
||||
data['status'] = "1"
|
||||
data['update_date'] = now
|
||||
data['update_by'] = str(my_partner['_id'])
|
||||
|
|
|
|||
|
|
@ -1102,6 +1102,7 @@ def flatten_data(y):
|
|||
|
||||
def test_web_service2(diction):
|
||||
try:
|
||||
|
||||
print(" #### ENVIRONNEMENT = "+str(MYSY_GV.MYSY_ENV)+" ")
|
||||
if( diction ):
|
||||
print(" ### diction dans la fonction = ", diction)
|
||||
|
|
|
|||
Loading…
Reference in New Issue