parent
1c0cd34690
commit
7caee47abf
|
|
@ -4,10 +4,15 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="27/06/26 - 18h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="27/06/26 - 18hs">
|
||||
<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$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ela_user_account.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_user_account.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_client.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_client.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.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" />
|
||||
|
|
@ -46,17 +51,17 @@
|
|||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Python.main.executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "master__Elyos__FI",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"last_opened_file_path": "C:/Users/Cherif/Documents/myclass.com/Siteweb/Elyos_Ftion_Initiale/Ela_back/Back_Office_FI",
|
||||
"settings.editor.selected.configurable": "preferences.lookFeel"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"Python.main.executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "master__Elyos__FI",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"last_opened_file_path": "C:/Users/Cherif/Documents/myclass.com/Siteweb/Elyos_Ftion_Initiale/Ela_back/Back_Office_FI",
|
||||
"settings.editor.selected.configurable": "preferences.lookFeel"
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="C:\Users\Cherif\Documents\myclass.com\Siteweb\Elyos_Ftion_Initiale\Ela_back\Back_Office_FI" />
|
||||
|
|
@ -451,7 +456,7 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1747251650255</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="602" />
|
||||
<option name="localTasksCounter" value="603" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
|
@ -493,7 +498,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="10/05/2026 - 12h30" />
|
||||
<MESSAGE value="11/05/2026 -22h" />
|
||||
<MESSAGE value="qsd" />
|
||||
<MESSAGE value="13/05/26 - 17h" />
|
||||
|
|
@ -518,6 +522,7 @@
|
|||
<MESSAGE value="21/06/26 - 22h" />
|
||||
<MESSAGE value="26/06/26 - 18h" />
|
||||
<MESSAGE value="27/06/26 - 18h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="27/06/26 - 18h" />
|
||||
<MESSAGE value="27/06/26 - 18hs" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="27/06/26 - 18hs" />
|
||||
</component>
|
||||
</project>
|
||||
6598
Log/log_file.log
6598
Log/log_file.log
File diff suppressed because one or more lines are too long
|
|
@ -1224,6 +1224,9 @@ def GetSessionFormation(diction):
|
|||
user['site_formation_id'] = site_formation_id
|
||||
user['site_formation_code'] = site_formation_code
|
||||
|
||||
if( "session_status" not in user.keys() or user['session_status'] not in [ '-1', '1']):
|
||||
user['session_status'] = "1"
|
||||
|
||||
"""
|
||||
Regarder si cette inscription a des inscriptions (validées) d'entreprise
|
||||
"""
|
||||
|
|
@ -2084,6 +2087,8 @@ def GetAllValideSessionPartner_List_Without_Scope_Action(diction):
|
|||
else:
|
||||
val['mode_animation'] = "0"
|
||||
|
||||
if ("session_status" not in val.keys() or val['session_status'] not in ['-1', '1']):
|
||||
val['session_status'] = "1"
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(val))
|
||||
|
||||
|
|
@ -2541,6 +2546,8 @@ def GetAllValideSessionPartner_List(diction):
|
|||
val['is_session_alert'] = ""
|
||||
val['session_alert_message'] = ""
|
||||
|
||||
if ("session_status" not in val.keys() or val['session_status'] not in ['-1', '1']):
|
||||
val['session_status'] = "1"
|
||||
RetObject.append(mycommon.JSONEncoder().encode(val))
|
||||
|
||||
return True, RetObject
|
||||
|
|
@ -2561,7 +2568,7 @@ def GetAllValideSessionPartner_List_filter_like(diction):
|
|||
|
||||
field_list = ['token','class_title', 'code_session', 'class_external_code',
|
||||
'session_start_date', 'session_end_date',
|
||||
'class_internal_url', 'archive', 'type_session', 'class_id']
|
||||
'class_internal_url', 'archive', 'type_session', 'class_id', 'session_etape', 'client_name']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
|
|
@ -2608,9 +2615,11 @@ def GetAllValideSessionPartner_List_filter_like(diction):
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
filt_class_id = {}
|
||||
if ("class_id" in diction.keys() and diction['class_id']):
|
||||
if( str(diction['class_id']) not in tab_class_id ):
|
||||
if (str(diction['class_id']) not in tab_class_id):
|
||||
tab_class_id.append(str(diction['class_id']))
|
||||
|
||||
|
||||
|
|
@ -2671,6 +2680,42 @@ def GetAllValideSessionPartner_List_filter_like(diction):
|
|||
if ("type_session" in diction.keys()):
|
||||
filt_type_session = {'type_session': str(diction['type_session']).strip()}
|
||||
|
||||
filt_session_etape = {}
|
||||
if ("session_etape" in diction.keys() and diction['session_etape']):
|
||||
filt_session_etape = {'session_etape': str(diction['session_etape']).strip()}
|
||||
|
||||
|
||||
"""
|
||||
Filter sur le client donner d'ordre
|
||||
"""
|
||||
filt_session_inscription_client_rattachement_id = {}
|
||||
if ("client_name" in diction.keys() and diction['client_name']):
|
||||
tab_session_id_from_inscription = []
|
||||
|
||||
qry_gle = {"$or": [
|
||||
{'raison_sociale': {'$regex': mycommon.regex_replace_cartere(str(diction['client_name']))}, 'partner_owner_recid':str(my_partner['recid']), 'valide':'1', 'locked':'0'},
|
||||
{'nom': {'$regex': mycommon.regex_replace_cartere(str(diction['client_name']))}, 'partner_owner_recid':str(my_partner['recid']), 'valide':'1', 'locked':'0'},
|
||||
{'email': {'$regex': mycommon.regex_replace_cartere(str(diction['client_name']))}, 'partner_owner_recid':str(my_partner['recid']), 'valide':'1', 'locked':'0'},
|
||||
{'telephone': {'$regex': mycommon.regex_replace_cartere(str(diction['client_name']))}, 'partner_owner_recid':str(my_partner['recid']), 'valide':'1', 'locked':'0'},
|
||||
]}
|
||||
|
||||
tab_client_id = []
|
||||
for tmp in MYSY_GV.dbname['partner_client'].find(qry_gle, {'_id':1}):
|
||||
tab_client_id.append(str(tmp['_id']))
|
||||
|
||||
|
||||
print(" ### tab_client_id = ", tab_client_id)
|
||||
|
||||
for tmp in MYSY_GV.dbname['inscription'].find({'client_rattachement_id':{'$in':tab_client_id}, 'partner_owner_recid':str(my_partner['recid']), 'valide':'1', },
|
||||
{'_id':1, 'session_id':1}):
|
||||
if( 'session_id' in tmp.keys() and tmp['session_id']):
|
||||
tab_session_id_from_inscription.append(ObjectId(str(tmp['session_id'])))
|
||||
|
||||
if( len(tab_session_id_from_inscription) > 0 ):
|
||||
filt_session_inscription_client_rattachement_id = {'_id':{'$in':tab_session_id_from_inscription}}
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Filtre sur les formation si mis sur l'utilisateur
|
||||
"""
|
||||
|
|
@ -2690,7 +2735,7 @@ def GetAllValideSessionPartner_List_filter_like(diction):
|
|||
|
||||
|
||||
query2 = [{'$match':{ '$and' : [ filt_code_session,{'partner_owner_recid':str(my_partner['recid'])}, filt_scope_class_id, filt_scope_session_id,
|
||||
filt_archive, filt_type_session, filt_class_title_v2] }},
|
||||
filt_archive, filt_type_session, filt_class_title_v2, filt_session_etape, filt_session_inscription_client_rattachement_id] }},
|
||||
{'$sort': {'_id': -1}},
|
||||
{'$lookup':
|
||||
{
|
||||
|
|
@ -2727,8 +2772,6 @@ def GetAllValideSessionPartner_List_filter_like(diction):
|
|||
|
||||
]
|
||||
|
||||
#print("#### GetAllValideSessionPartner_List_filter_likequery = ", query)
|
||||
|
||||
print("#### GetAllValideSessionPartner_List_filter_likequery22 = ", query2)
|
||||
RetObject = []
|
||||
cpt = 0
|
||||
|
|
@ -2937,6 +2980,9 @@ def GetAllValideSessionPartner_List_filter_like(diction):
|
|||
|
||||
val['taux_remplissage'] = str(taux_remplissage)
|
||||
|
||||
if ("session_status" not in val.keys() or val['session_status'] not in ['-1', '1']):
|
||||
val['session_status'] = "1"
|
||||
|
||||
if( retVal["type_session"] == "0"):
|
||||
"""
|
||||
29/05/2024 : On va aller recuperer le nombre de personnes inscrites sur des devis non envoyés et non validés.
|
||||
|
|
@ -3352,6 +3398,8 @@ def GetAllValideSessionPartner_List_no_filter(diction):
|
|||
2)
|
||||
|
||||
val['taux_remplissage'] = str(taux_remplissage)
|
||||
if ("session_status" not in val.keys() or val['session_status'] not in ['-1', '1']):
|
||||
val['session_status'] = "1"
|
||||
|
||||
if( retVal["type_session"] == "0"):
|
||||
|
||||
|
|
@ -3417,6 +3465,9 @@ def GetAllValideSessionPartner_List_no_filter(diction):
|
|||
val['is_session_alert'] = ""
|
||||
val['session_alert_message'] = ""
|
||||
|
||||
if ("session_status" not in val.keys() or val['session_status'] not in ['-1', '1']):
|
||||
val['session_status'] = "1"
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(val))
|
||||
|
||||
return True, RetObject
|
||||
|
|
|
|||
|
|
@ -1066,6 +1066,7 @@ def Reset_user_pwd_by_token(diction):
|
|||
return False, " Impossible de mettre à jour le mot de passe"
|
||||
|
||||
|
||||
|
||||
mydata['update_date'] = str(datetime.now())
|
||||
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
|
@ -1129,9 +1130,15 @@ def Reset_user_pwd_by_token(diction):
|
|||
mydata['pwd'] = new_pwd
|
||||
mydata['tmp_token_pwd'] = ""
|
||||
|
||||
print(" ### tmp_retval = ", tmp_retval[0])
|
||||
|
||||
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
#print(" le recid PARTENAIRE = " + user_recid + " mydata = " + str(mydata))
|
||||
print(" le email PARTENAIRE = " + user_email + " mydata = " + str(mydata))
|
||||
|
||||
print(" QRYY = ", {'email': user_email, 'locked': '0', 'active': '1'})
|
||||
|
||||
ret_val = coll_name.find_one_and_update({'email': user_email, 'locked': '0', 'active': '1'},
|
||||
{"$set": mydata},
|
||||
upsert=False,
|
||||
|
|
@ -1854,16 +1861,16 @@ def InitUserPasswd(diction):
|
|||
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
#print(" #### myquery partenaire ="+str(myquery))
|
||||
print(" #### myquery partenaire ="+str(myquery))
|
||||
|
||||
tmp = coll_name.count_documents(myquery)
|
||||
if (tmp <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Aucun résultat trouvé pour le compte pro " + str(myquery))
|
||||
return True, "La demande de réinitialisation a été prise en compte."
|
||||
|
||||
retVal = coll_name.find(myquery, {"_id": 0, "valide": 0,})
|
||||
retVal = coll_name.find(myquery, { "valide": 0,})
|
||||
|
||||
#print(" ### retVal 001 = ", str(retVal[0]))
|
||||
print(" ### retVal 001 = ", str(retVal[0]))
|
||||
|
||||
"""
|
||||
Dans le cas exclusif du compte pro,
|
||||
|
|
@ -1882,7 +1889,7 @@ def InitUserPasswd(diction):
|
|||
#print(" ### str(retVal[0]['recid']) = ", str(retVal[0]['recid']))
|
||||
|
||||
ret_val = coll_name.find_one_and_update(
|
||||
{'recid': str(retVal[0]['recid']), },
|
||||
{'_id': ObjectId(str(retVal[0]['_id'])), },
|
||||
{"$set": new_token},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
|
|
|
|||
45
main.py
45
main.py
|
|
@ -16113,6 +16113,51 @@ def JMJ_Repise_Factures_Update_Inscription_Status():
|
|||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Test reprise facture CFH
|
||||
"""
|
||||
@app.route('/myclass/api/CFH_Repise_Factures/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def CFH_Repise_Factures():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### CFH_Repise_Factures : payload = ",payload)
|
||||
localStatus, message= tools_cherif.CFH_Repise_Factures(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Test reprise facture CFH update inscription invoice status
|
||||
"""
|
||||
@app.route('/myclass/api/CFH_Repise_Factures_Update_Inscription_Status/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def CFH_Repise_Factures_Update_Inscription_Status():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### CFH_Repise_Factures_Update_Inscription_Status : payload = ",payload)
|
||||
localStatus, message= tools_cherif.CFH_Repise_Factures_Update_Inscription_Status(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Test reprise facture CFH paiement
|
||||
"""
|
||||
@app.route('/myclass/api/CFH_Repise_Paiement_Facture/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def CFH_Repise_Paiement_Facture():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### CFH_Repise_Paiement_Facture : payload = ",payload)
|
||||
localStatus, message= tools_cherif.CFH_Repise_Paiement_Facture(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour mettre à jour la liste des documents par défaut d'une formation
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -4845,9 +4845,10 @@ def Get_Parner_Divers_Invoice_Data_12(diction):
|
|||
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:
|
||||
elif ('reste_to_paye' in New_retVal.keys()):
|
||||
total_montant_a_payer = total_montant_a_payer + mycommon.tryFloat(str(New_retVal['reste_to_paye']))
|
||||
else:
|
||||
|
||||
elif ('reste_to_paye' in New_retVal.keys()):
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -485,6 +485,23 @@ def get_user_recid_from_token(token = ""):
|
|||
return False
|
||||
|
||||
|
||||
def get_user_partnaire_id_from_token(token = ""):
|
||||
try :
|
||||
if len(str(token)) <= 0 :
|
||||
myprint(" Le token est vide")
|
||||
return False
|
||||
|
||||
coll_token = MYSY_GV.dbname['partner_token']
|
||||
tmp_val = coll_token.find({'token': str(token), 'valide': '1'})
|
||||
user_recid = tmp_val[0]['partner_account_id']
|
||||
return user_recid
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False
|
||||
|
||||
|
||||
"""
|
||||
22/12/2024 :
|
||||
Cette fonction retourne l'_id depuis (user_account) en partant du token
|
||||
|
|
|
|||
|
|
@ -2522,3 +2522,914 @@ def Correcte_Type_session_For_Old_Session(diction):
|
|||
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 faire la mise à jour"
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
CFHorizon reprise factures
|
||||
"""
|
||||
def CFH_Repise_Factures(diction):
|
||||
try:
|
||||
saved_file = "./temp_direct/template_facture_CFH_exemple_fichier_DEV.csv"
|
||||
#saved_file = "./temp_direct/facture_exemple_fichier_v3_prod.csv"
|
||||
#saved_file = "./temp_direct/facture_exemple_fichier_v3_rec.csv"
|
||||
#saved_file = "./temp_direct/facture_exemple_fichier_v3_dev.csv"
|
||||
#saved_file = "./temp_direct/facture_exemple_fichier_v2_prod.csv"
|
||||
|
||||
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';', encoding_errors='ignore',
|
||||
skipinitialspace=True)
|
||||
df = df.fillna('')
|
||||
df = df.applymap(lambda x: x.strip() if isinstance(x, str) else x)
|
||||
|
||||
total_rows = len(df)
|
||||
x = range(0, total_rows)
|
||||
field_list = [ 'email_client', 'date_echeance', 'date_emission', 'montant_ht',
|
||||
'montant_ttc', 'num_facture', 'note', 'code_session',
|
||||
'tax_amount', 'tax_taux', 'annotation', 'facture_initiale', 'type',
|
||||
'email_client_facture']
|
||||
|
||||
list_client_ko = []
|
||||
list_code_session_ko = []
|
||||
list_client_facture_ko = []
|
||||
|
||||
|
||||
list_code_session_kooo = []
|
||||
list_client_kooo = []
|
||||
list_client_facture_kooo = []
|
||||
|
||||
for n in x:
|
||||
client_mail = str(df['email_client'].values[n]).strip()
|
||||
client_mail_facture = str(df['email_client_facture'].values[n]).strip()
|
||||
session_formation = str(df['code_session'].values[n]).strip()
|
||||
|
||||
if( client_mail != "" and session_formation != ""):
|
||||
# Verifier si le client existe
|
||||
is_client_exist = MYSY_GV.dbname['partner_client'].count_documents({"email":client_mail, 'partner_owner_recid':diction['partner_owner_recid']})
|
||||
|
||||
if(is_client_exist <= 0 ):
|
||||
if( client_mail not in list_client_ko ):
|
||||
list_client_ko.append( str(client_mail))
|
||||
|
||||
elif ( is_client_exist > 1 ):
|
||||
print(" Client email : " + str(client_mail) + " == ", is_client_exist)
|
||||
|
||||
else:
|
||||
list_client_kooo.append(str(client_mail))
|
||||
|
||||
# Verifier si le client facturer existe
|
||||
is_client_facture_exist = MYSY_GV.dbname['partner_client'].count_documents(
|
||||
{"email": client_mail_facture, 'partner_owner_recid': diction['partner_owner_recid']})
|
||||
|
||||
if (is_client_facture_exist <= 0):
|
||||
if (client_mail_facture not in list_client_facture_ko):
|
||||
list_client_facture_ko.append(str(client_mail_facture))
|
||||
|
||||
elif (is_client_facture_exist > 1):
|
||||
print(" Client email Facturer: " + str(client_mail_facture) + " == ", is_client_facture_exist)
|
||||
|
||||
else:
|
||||
list_client_facture_kooo.append(str(client_mail_facture))
|
||||
|
||||
|
||||
# Verifier si la session existe
|
||||
is_session_exist = MYSY_GV.dbname['session_formation'].count_documents({"code_session": session_formation, 'partner_owner_recid':diction['partner_owner_recid']})
|
||||
|
||||
if (is_session_exist <= 0):
|
||||
if (client_mail not in list_code_session_ko):
|
||||
list_code_session_ko.append(str(session_formation))
|
||||
|
||||
elif (is_session_exist > 1):
|
||||
print(" Le code session : " + str(session_formation) + " == ", is_session_exist)
|
||||
|
||||
else:
|
||||
list_code_session_kooo.append(str(session_formation))
|
||||
|
||||
|
||||
|
||||
print(" NB client KO = ", len(list_client_ko))
|
||||
print(" List client KO = ", list_client_ko)
|
||||
|
||||
print(" NB client FACTURE KO = ", len(list_client_facture_ko))
|
||||
print(" List client FACTURE KO = ", list_client_facture_ko)
|
||||
|
||||
print(" NB code session KO = ", len(list_code_session_ko))
|
||||
print(" List code session KO = ", list_code_session_ko)
|
||||
tab_facture_traite = []
|
||||
|
||||
for n in x:
|
||||
client_mail = str(df['email_client'].values[n]).strip()
|
||||
client_mail_facture = str(df['email_client_facture'].values[n]).strip()
|
||||
|
||||
session_formation = str(df['code_session'].values[n]).strip()
|
||||
num_facture = str(df['num_facture'].values[n]).strip()
|
||||
|
||||
|
||||
if(client_mail in list_client_kooo and session_formation in list_code_session_kooo
|
||||
and client_mail_facture in list_client_facture_kooo):
|
||||
node_facture_traiter = {}
|
||||
node_facture_traiter['num_facture'] = str(num_facture)
|
||||
node_facture_traiter['session_formation'] = str(session_formation)
|
||||
node_facture_traiter['client_mail'] = str(client_mail)
|
||||
node_facture_traiter['client_mail_facture'] = str(client_mail_facture)
|
||||
|
||||
tab_facture_traite.append(node_facture_traiter)
|
||||
|
||||
print(" ### tab_facture_traite = ", str(tab_facture_traite))
|
||||
print(" ### TOTAL NB FACTURE = ", str(len(tab_facture_traite)))
|
||||
|
||||
|
||||
cpt_facture_imported = 0
|
||||
for n in x:
|
||||
client_mail = str(df['email_client'].values[n]).strip()
|
||||
client_mail_facture = str(df['email_client_facture'].values[n]).strip()
|
||||
session_formation = str(df['code_session'].values[n]).strip()
|
||||
|
||||
if(client_mail in list_client_kooo and session_formation in list_code_session_kooo
|
||||
and client_mail_facture in list_client_facture_kooo):
|
||||
|
||||
date_echeance = str(df['date_echeance'].values[n]).strip()
|
||||
date_emission = str(df['date_emission'].values[n]).strip()
|
||||
montant_ht = str(df['montant_ht'].values[n]).strip()
|
||||
montant_ttc = str(df['montant_ttc'].values[n]).strip()
|
||||
num_facture = str(df['num_facture'].values[n]).strip()
|
||||
code_session = str(df['code_session'].values[n]).strip()
|
||||
|
||||
tax_amount = str(df['tax_amount'].values[n]).strip()
|
||||
tax_taux = str(df['tax_taux'].values[n]).strip()
|
||||
annotation = str(df['annotation'].values[n]).strip()
|
||||
facture_initiale = str(df['facture_initiale'].values[n]).strip()
|
||||
type = str(df['type'].values[n]).strip()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
client_data = MYSY_GV.dbname['partner_client'].find_one({"email": client_mail})
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one({"code_session": session_formation})
|
||||
client_facture_data = MYSY_GV.dbname['partner_client'].find_one({"email": client_mail_facture})
|
||||
|
||||
class_data = MYSY_GV.dbname['myclass'].find_one({"partner_owner_recid":diction['partner_owner_recid'],
|
||||
'_id':ObjectId(str(session_data['class_id']))})
|
||||
|
||||
|
||||
print(" QRY INSCRI DATA = ", {"partner_owner_recid":diction['partner_owner_recid'],
|
||||
'email':client_mail, 'session_id':str(session_data['_id'])
|
||||
})
|
||||
inscrit_data = MYSY_GV.dbname['inscription'].find_one({"partner_owner_recid":diction['partner_owner_recid'],
|
||||
'email':client_mail, 'session_id':str(session_data['_id'])
|
||||
})
|
||||
|
||||
print(" ## traitement FACTURE 011 = ", num_facture)
|
||||
print(" client_data = ", client_data)
|
||||
print(" session_data = ", session_data)
|
||||
print(" class_data = ", class_data)
|
||||
print(" client_facture_data = ", client_facture_data)
|
||||
print(" inscrit_data = ", inscrit_data)
|
||||
|
||||
if( client_data and session_data and class_data and client_facture_data ) :
|
||||
|
||||
## Creer les factures de reprise
|
||||
partner_invoice_header_data = {}
|
||||
|
||||
list_partner_invoice_header_champ = ['order_header_client_id', 'order_header_ref_interne',
|
||||
'order_header_email_client', 'order_header_origin',
|
||||
'order_header_ref_client', 'order_header_vendeur_id',
|
||||
'order_header_date_cmd', 'order_header_date_expiration',
|
||||
'order_header_adr_fact_adresse', 'order_header_adr_fact_code_postal',
|
||||
'order_header_adr_fact_ville', 'order_header_adr_fact_pays',
|
||||
'order_header_adr_liv_adresse', 'order_header_adr_liv_code_postal',
|
||||
'order_header_adr_liv_ville', 'order_header_adr_liv_pays', 'valide',
|
||||
'locked', 'date_update',
|
||||
'order_header_montant_reduction', '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', 'invoice_header_ref_interne',
|
||||
'invoice_header_type', 'invoice_date', 'update_by']
|
||||
|
||||
# PreRemplir les champs
|
||||
for val in list_partner_invoice_header_champ:
|
||||
partner_invoice_header_data[str(val)] = ""
|
||||
|
||||
|
||||
partner_invoice_header_data['order_header_client_id'] = str(client_facture_data['_id'])
|
||||
partner_invoice_header_data['invoice_date_echeance'] = str(date_echeance)
|
||||
partner_invoice_header_data['order_header_condition_paiement_code'] = ""
|
||||
partner_invoice_header_data['order_header_condition_paiement_description'] = ""
|
||||
|
||||
partner_invoice_header_data['order_header_ref_interne'] = str(code_session)
|
||||
partner_invoice_header_data['order_header_email_client'] = str(client_mail_facture)
|
||||
partner_invoice_header_data['order_header_origin'] = "REPRISE"
|
||||
partner_invoice_header_data['order_header_adr_fact_adresse'] = str(client_facture_data['invoice_adresse'])
|
||||
partner_invoice_header_data['order_header_adr_fact_ville'] = str(client_facture_data['invoice_ville'])
|
||||
partner_invoice_header_data['order_header_adr_fact_code_postal'] = str(client_facture_data['invoice_code_postal'])
|
||||
partner_invoice_header_data['order_header_adr_fact_pays'] = str(client_facture_data['invoice_pays'])
|
||||
order_header_montant_reduction = "0"
|
||||
partner_invoice_header_data['order_header_montant_reduction'] = "0"
|
||||
partner_invoice_header_data['total_header_hors_taxe_before_header_reduction'] = str(montant_ht)
|
||||
partner_invoice_header_data['order_header_tax'] = str(tax_taux)
|
||||
partner_invoice_header_data['order_header_tax_amount'] = str(tax_amount)
|
||||
partner_invoice_header_data['total_header_toutes_taxes'] = str(montant_ttc)
|
||||
partner_invoice_header_data['reste_to_paye'] = str(montant_ttc)
|
||||
partner_invoice_header_data['invoice_header_type'] = str(type)
|
||||
partner_invoice_header_data['invoice_header_ref_interne'] = str(num_facture)
|
||||
partner_invoice_header_data['credit_note_ref'] = ""
|
||||
partner_invoice_header_data['invoice_date'] = str(date_emission)
|
||||
partner_invoice_header_data['update_by'] = "SYSTEM"
|
||||
partner_invoice_header_data['annotation'] = str(annotation)
|
||||
partner_invoice_header_data['invoice_header_origin'] = str(facture_initiale)
|
||||
partner_invoice_header_data['valide'] = "1"
|
||||
partner_invoice_header_data['locked'] = "0"
|
||||
partner_invoice_header_data['partner_owner_recid'] = str(diction['partner_owner_recid'])
|
||||
partner_invoice_header_data['update_date'] = str(datetime.now())
|
||||
|
||||
print(" ## traitement FACTURE 022 = ", partner_invoice_header_data['invoice_header_ref_interne'])
|
||||
|
||||
print(" #### partner_invoice_header_data = ", partner_invoice_header_data)
|
||||
inserted_invoice_id = MYSY_GV.dbname['partner_invoice_header'].insert_one(partner_invoice_header_data).inserted_id
|
||||
if (not inserted_invoice_id):
|
||||
mycommon.myprint(" Facture : Impossible de créer l'entête de la facture ")
|
||||
return False, " Facture : Impossible de créer l'entête de la facture "
|
||||
|
||||
partner_invoice_line_data = {}
|
||||
list_partner_invoice_line_champ = ['order_line_formation', 'order_line_qty', 'order_line_prix_unitaire',
|
||||
'order_line_tax', 'order_line_tax_amount',
|
||||
'order_line_montant_toutes_taxes',
|
||||
'order_line_montant_hors_taxes', 'order_line_type_reduction',
|
||||
'order_line_type_valeur', 'order_line_montant_reduction',
|
||||
'order_header_ref_interne',
|
||||
'order_line_comment', 'order_header_id', 'valide', 'locked',
|
||||
'date_update', 'partner_owner_recid', 'invoice_header_ref_interne',
|
||||
'invoice_line_type',
|
||||
'invoice_date', 'invoice_header_id', 'order_line_class_id']
|
||||
|
||||
# PreRemplir les champs
|
||||
for val in list_partner_invoice_line_champ:
|
||||
partner_invoice_line_data[str(val)] = ""
|
||||
|
||||
partner_invoice_line_data['order_line_formation'] = class_data['internal_url']
|
||||
partner_invoice_line_data['order_line_class_id'] = str(class_data['_id'])
|
||||
|
||||
partner_invoice_line_data['order_line_qty'] = str("1")
|
||||
partner_invoice_line_data['order_line_prix_unitaire'] = str(montant_ht)
|
||||
partner_invoice_line_data['order_line_montant_hors_taxes'] = str(montant_ht)
|
||||
#partner_invoice_line_data['order_line_comment'] = str(inscrit_data['nom']).upper() +" "+str(inscrit_data['prenom']).capitalize()
|
||||
partner_invoice_line_data['order_line_comment'] = ""
|
||||
partner_invoice_line_data['invoice_header_id'] = str(inserted_invoice_id)
|
||||
partner_invoice_line_data['invoice_line_type'] = "facture"
|
||||
partner_invoice_line_data['invoice_header_ref_interne'] = partner_invoice_header_data['invoice_header_ref_interne']
|
||||
partner_invoice_line_data['update_by'] = ""
|
||||
partner_invoice_line_data['valide'] = "1"
|
||||
partner_invoice_line_data['locked'] = "0"
|
||||
partner_invoice_line_data['partner_owner_recid'] = str(diction['partner_owner_recid'])
|
||||
|
||||
print(" #### partner_invoice_line_data = ", partner_invoice_line_data)
|
||||
inserted_invoice_id = MYSY_GV.dbname['partner_invoice_line'].insert_one(
|
||||
partner_invoice_line_data).inserted_id
|
||||
if (not inserted_invoice_id):
|
||||
mycommon.myprint(" Facture : Impossible de créer les lignes de la facture " + str(
|
||||
partner_invoice_header_data['invoice_header_ref_interne']))
|
||||
return False, " Facture : Impossible de créer les lignes de la facture " + str(
|
||||
partner_invoice_header_data['invoice_header_ref_interne']), False
|
||||
|
||||
|
||||
cpt_facture_imported = cpt_facture_imported + 1
|
||||
|
||||
print(" ### TOTAL NB FACTURE IMPORTEDDDD = ", str(cpt_facture_imported))
|
||||
|
||||
return True, "reprise factures ok"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de faire la reprise de factures JMJ"
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
CFH reprise factures pr upadete session (mettre 'invoiced' à 1)
|
||||
"""
|
||||
def CFH_Repise_Factures_Update_Inscription_Status(diction):
|
||||
try:
|
||||
|
||||
saved_file = "./temp_direct/template_facture_CFH_exemple_fichier_DEV.csv"
|
||||
#saved_file = "./temp_direct/facture_exemple_fichier_v2_prod.csv"
|
||||
|
||||
|
||||
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';', encoding_errors='ignore',
|
||||
skipinitialspace=True)
|
||||
df = df.fillna('')
|
||||
df = df.applymap(lambda x: x.strip() if isinstance(x, str) else x)
|
||||
|
||||
total_rows = len(df)
|
||||
x = range(0, total_rows)
|
||||
field_list = ['email_client', 'date_echeance', 'date_emission', 'montant_ht',
|
||||
'montant_ttc', 'num_facture', 'note', 'code_session',
|
||||
'tax_amount', 'tax_taux', 'annotation', 'facture_initiale', 'type']
|
||||
|
||||
list_client_ko = []
|
||||
list_code_session_ko = []
|
||||
|
||||
list_code_session_kooo = []
|
||||
list_client_kooo = []
|
||||
|
||||
for n in x:
|
||||
client_mail = str(df['email_client'].values[n]).strip()
|
||||
session_formation = str(df['code_session'].values[n]).strip()
|
||||
if( client_mail != "" and session_formation != ""):
|
||||
# Verifier si le client existe
|
||||
is_client_exist = MYSY_GV.dbname['partner_client'].count_documents({"email":client_mail, 'partner_owner_recid':diction['partner_owner_recid']})
|
||||
|
||||
if(is_client_exist <= 0 ):
|
||||
if( client_mail not in list_client_ko ):
|
||||
list_client_ko.append( str(client_mail))
|
||||
|
||||
elif ( is_client_exist > 1 ):
|
||||
print(" Client email : " + str(client_mail) + " == ", is_client_exist)
|
||||
|
||||
else:
|
||||
list_client_kooo.append(str(client_mail))
|
||||
|
||||
# Verifier si la session existe
|
||||
is_session_exist = MYSY_GV.dbname['session_formation'].count_documents({"code_session": session_formation, 'partner_owner_recid':diction['partner_owner_recid']})
|
||||
|
||||
if (is_session_exist <= 0):
|
||||
if (client_mail not in list_code_session_ko):
|
||||
list_code_session_ko.append(str(session_formation))
|
||||
|
||||
elif (is_session_exist > 1):
|
||||
print(" Le code session : " + str(session_formation) + " == ", is_session_exist)
|
||||
|
||||
else:
|
||||
list_code_session_kooo.append(str(session_formation))
|
||||
|
||||
|
||||
|
||||
print(" NB client KO = ", len(list_client_ko))
|
||||
print(" List client KO = ", list_client_ko)
|
||||
|
||||
print(" NB code session KO = ", len(list_code_session_ko))
|
||||
print(" List code session KO = ", list_code_session_ko)
|
||||
tab_facture_traite = []
|
||||
|
||||
for n in x:
|
||||
client_mail = str(df['email_client'].values[n]).strip()
|
||||
session_formation = str(df['code_session'].values[n]).strip()
|
||||
num_facture = str(df['num_facture'].values[n]).strip()
|
||||
|
||||
|
||||
if(client_mail in list_client_kooo and session_formation in list_code_session_kooo ):
|
||||
node_facture_traiter = {}
|
||||
node_facture_traiter['num_facture'] = str(num_facture)
|
||||
node_facture_traiter['session_formation'] = str(session_formation)
|
||||
node_facture_traiter['client_mail'] = str(client_mail)
|
||||
tab_facture_traite.append(node_facture_traiter)
|
||||
|
||||
print(" ### tab_facture_traite = ", str(tab_facture_traite))
|
||||
print(" ### TOTAL NB FACTURE = ", str(len(tab_facture_traite)))
|
||||
|
||||
|
||||
cpt_facture_imported = 0
|
||||
for n in x:
|
||||
client_mail = str(df['email_client'].values[n]).strip()
|
||||
session_formation = str(df['code_session'].values[n]).strip()
|
||||
|
||||
if(client_mail in list_client_kooo and session_formation in list_code_session_kooo ):
|
||||
|
||||
date_echeance = str(df['date_echeance'].values[n]).strip()
|
||||
date_emission = str(df['date_emission'].values[n]).strip()
|
||||
montant_ht = str(df['montant_ht'].values[n]).strip()
|
||||
montant_ttc = str(df['montant_ttc'].values[n]).strip()
|
||||
num_facture = str(df['num_facture'].values[n]).strip()
|
||||
code_session = str(df['code_session'].values[n]).strip()
|
||||
|
||||
tax_amount = str(df['tax_amount'].values[n]).strip()
|
||||
tax_taux = str(df['tax_taux'].values[n]).strip()
|
||||
annotation = str(df['annotation'].values[n]).strip()
|
||||
facture_initiale = str(df['facture_initiale'].values[n]).strip()
|
||||
type = str(df['type'].values[n]).strip()
|
||||
|
||||
|
||||
|
||||
client_data = MYSY_GV.dbname['partner_client'].find_one({"email": client_mail})
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one({"code_session": session_formation})
|
||||
|
||||
class_data = MYSY_GV.dbname['myclass'].find_one({"partner_owner_recid":diction['partner_owner_recid'],
|
||||
'_id':ObjectId(str(session_data['class_id']))})
|
||||
|
||||
|
||||
print(" ## code sesson : ", session_formation)
|
||||
print(" ### QRY ", {"partner_owner_recid":diction['partner_owner_recid'],
|
||||
'session_id':str(session_data['_id'])})
|
||||
|
||||
for inscription_data in MYSY_GV.dbname['inscription'].find({"partner_owner_recid":diction['partner_owner_recid'],
|
||||
'session_id':str(session_data['_id'])}):
|
||||
|
||||
|
||||
print(" ### inscription line to update = ", str(inscription_data['_id']), ", ", str(inscription_data['email']), " Code session :", session_formation)
|
||||
|
||||
ret_val2 = MYSY_GV.dbname['inscription'].find_one_and_update(
|
||||
{'_id':ObjectId(str(inscription_data['_id']))},
|
||||
{"$set": {'invoiced':'1', 'invoiced_ref':str(num_facture)}},
|
||||
return_document=ReturnDocument.AFTER,
|
||||
upsert=False,
|
||||
)
|
||||
if( ret_val2 ):
|
||||
cpt_facture_imported = cpt_facture_imported + 1
|
||||
print(" ### UPDATE : OKKK ")
|
||||
|
||||
print(" ### TOTAL INSCRIPTION LINE TO UPDATE = ", str(cpt_facture_imported))
|
||||
|
||||
return True, "inscript line to update ok"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de faire la reprise de factures JMJ"
|
||||
|
||||
|
||||
|
||||
"""
|
||||
internal pour paiement
|
||||
"""
|
||||
def Internal_Get_Invoice_Liste_Payement_And_Total_Amount(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['partner_owner_recid', 'invoice_id', 'client_info', 'client_id', 'invoice_ref']
|
||||
|
||||
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", False
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['partner_owner_recid', ]
|
||||
|
||||
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", False
|
||||
|
||||
"""
|
||||
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']
|
||||
|
||||
my_partner = {}
|
||||
my_partner['recid'] = diction['partner_owner_recid']
|
||||
|
||||
|
||||
|
||||
# Verifier que la facture existe et est valide
|
||||
if( "invoice_id" in diction.keys() and diction['invoice_id']):
|
||||
is_existe_invoice = MYSY_GV.dbname['partner_invoice_header'].count_documents({'_id':ObjectId(str(diction['invoice_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
|
||||
if( is_existe_invoice != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la facture est invalide ")
|
||||
return False, " L'identifiant de la facture est invalide ", False
|
||||
|
||||
"""
|
||||
Filtre général sur le client (raison_sociale, nom, email, telephone
|
||||
"""
|
||||
filt_gle_client = {}
|
||||
tab_client_id = []
|
||||
if ("client_info" in diction.keys() and diction['client_info']):
|
||||
|
||||
local_myquery_gle = {
|
||||
"partner_owner_recid": str(my_partner['recid']),
|
||||
"valide": "1",
|
||||
"locked": "0",
|
||||
"$or": [
|
||||
{'raison_sociale': {'$regex': mycommon.regex_replace_cartere(str(diction['client_info'])),
|
||||
"$options": "i"}},
|
||||
{'nom': {'$regex': mycommon.regex_replace_cartere(str(diction['client_info'])),
|
||||
"$options": "i"}},
|
||||
{'email': {'$regex': mycommon.regex_replace_cartere(str(diction['client_info'])),
|
||||
"$options": "i"}},
|
||||
{'telephone': {'$regex': mycommon.regex_replace_cartere(str(diction['client_info'])),
|
||||
"$options": "i"}},
|
||||
]
|
||||
}
|
||||
|
||||
for tmp in MYSY_GV.dbname['partner_client'].find(local_myquery_gle):
|
||||
tab_client_id.append(str(tmp['_id']))
|
||||
|
||||
if ("client_id" in diction.keys() and diction['client_id']):
|
||||
if (diction['client_id'] not in tab_client_id):
|
||||
tab_client_id.append(str(diction['client_id']))
|
||||
|
||||
filt_gle_client = {'client_id': {'$in': tab_client_id}}
|
||||
|
||||
filter_invoice_id = {}
|
||||
if ("invoice_id" in diction.keys() and diction['invoice_id']):
|
||||
filter_invoice_id = {'invoice_id': str(diction['invoice_id'])}
|
||||
|
||||
filter_invoice_ref = {}
|
||||
if ("invoice_ref" in diction.keys() and diction['invoice_ref']):
|
||||
filter_invoice_ref = {'invoice_ref': str(diction['invoice_ref'])}
|
||||
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid']), 'valide': '1',
|
||||
'locked': '0'},
|
||||
filter_invoice_id, filter_invoice_ref, filt_gle_client]}
|
||||
|
||||
RetObject = []
|
||||
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
|
||||
user['id'] = str(val_tmp)
|
||||
|
||||
local_status, local_retval = mycommon.IsFloat(str(retval['paiement_amount']))
|
||||
if(local_status is False ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible d'évaluer les paiements effectués ")
|
||||
return False, " Impossible d'évaluer les paiements effectués "
|
||||
|
||||
payed_amount = payed_amount + local_retval
|
||||
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
return True, RetObject, str(payed_amount)
|
||||
|
||||
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écuperer les paiements de la facture ", False
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
fonction interne de paiement
|
||||
"""
|
||||
def Internal_Add_Invoice_Paiement(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['partner_owner_recid', 'invoice_id', 'paiement_amount', 'paiement_mode', 'paiement_ref',
|
||||
'paiement_date', 'commentaire', 'client_id', 'invoice_ref']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['partner_owner_recid', 'invoice_id', 'paiement_amount', 'paiement_mode',
|
||||
'paiement_date', ]
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans 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']
|
||||
|
||||
my_partner = {}
|
||||
my_partner['recid'] = diction['partner_owner_recid']
|
||||
|
||||
"""
|
||||
Verifier que la date de paiement est au format jj/mm/aaaa
|
||||
"""
|
||||
local_status = mycommon.CheckisDate(str(diction['paiement_date'])[0:10])
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de paiement n'est pas au format jj/mm/aaaa ")
|
||||
|
||||
return False, " La date de paiement n'est pas au format jj/mm/aaaa "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que le payement est bien un float
|
||||
"""
|
||||
local_status, local_retval = mycommon.IsFloat(str(diction['paiement_amount']))
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le montant payé n'est convertible en Float ")
|
||||
return False, " Le montant payé n'est convertible en Float "
|
||||
|
||||
|
||||
|
||||
|
||||
# Verifier que la facture existe et est valide
|
||||
is_existe_invoice = MYSY_GV.dbname['partner_invoice_header'].count_documents({'_id':ObjectId(str(diction['invoice_id'])),
|
||||
'valide':'1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
|
||||
if( is_existe_invoice != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la facture est invalide ")
|
||||
return False, " L'identifiant de la facture est invalide "
|
||||
|
||||
|
||||
"""
|
||||
Recuperer les données de facture et traiter le relicat à à payer
|
||||
"""
|
||||
is_existe_invoice_data = MYSY_GV.dbname['partner_invoice_header'].find_one(
|
||||
{'_id': ObjectId(str(diction['invoice_id'])),
|
||||
'valide': '1', 'locked':'0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
invoice_paiement_status = "0"
|
||||
if("invoice_paiement_status" in is_existe_invoice_data and is_existe_invoice_data['invoice_paiement_status']):
|
||||
invoice_paiement_status = is_existe_invoice_data['invoice_paiement_status']
|
||||
|
||||
if( invoice_paiement_status not in MYSY_GV.INVOICE_PAIEMENT_STATUS ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible d'analyser le statut de paiement de la facture ")
|
||||
return False, " Impossible d'analyser le statut de paiement de la facture "
|
||||
|
||||
if( invoice_paiement_status == "2" ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La facture a déjà été payée ")
|
||||
return False, " La facture a déjà été payée "
|
||||
|
||||
total_invoice_amount = "0"
|
||||
if( "total_header_toutes_taxes" in is_existe_invoice_data.keys() ):
|
||||
total_invoice_amount = is_existe_invoice_data['total_header_toutes_taxes']
|
||||
|
||||
#print(" ### 00 total_invoice_amount = ", total_invoice_amount)
|
||||
|
||||
local_status, local_retval = mycommon.IsFloat(total_invoice_amount)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'total_header_toutes_taxes' n'est convertible en Float ")
|
||||
return False, " Le champ 'total_header_toutes_taxes' n'est convertible en Float "
|
||||
|
||||
total_invoice_amount_float = local_retval
|
||||
|
||||
#print(" ### 00 local_retval (is float) = ", local_retval)
|
||||
|
||||
"""
|
||||
Récuprer les paiement déjà effectué
|
||||
"""
|
||||
local_diction = {"partner_owner_recid": str(diction['partner_owner_recid']), "invoice_id": str(diction['invoice_id'])}
|
||||
local_list_paiement_status, local_list_paiement_retval, local_total_payed = Internal_Get_Invoice_Liste_Payement_And_Total_Amount(local_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(" Les payement = ", local_total_payed)
|
||||
|
||||
total_payed_amount = "0"
|
||||
total_relicat = total_invoice_amount_float
|
||||
|
||||
if(len(local_list_paiement_retval) > 0 ):
|
||||
list_payment = ast.literal_eval(local_list_paiement_retval[0])
|
||||
|
||||
if( "total_payed" in list_payment.keys() ):
|
||||
total_payed_amount = list_payment['total_payed']
|
||||
|
||||
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)
|
||||
|
||||
|
||||
"""
|
||||
Tout est ok, alors on enregistre le paiement
|
||||
"""
|
||||
|
||||
|
||||
new_data = diction
|
||||
|
||||
|
||||
# Initialisation des champs non envoyés à vide
|
||||
for val in field_list:
|
||||
if val not in diction.keys():
|
||||
new_data[str(val)] = ""
|
||||
|
||||
new_data['paiement_date'] = str(diction['paiement_date'])[0:10]
|
||||
|
||||
new_data['valide'] = "1"
|
||||
new_data['locked'] = "0"
|
||||
|
||||
new_data['update_date'] = str(datetime.now())
|
||||
new_data['update_by'] = "Reprise"
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
new_data['client_id'] = str(is_existe_invoice_data['order_header_client_id'])
|
||||
new_data['invoice_ref'] = str(is_existe_invoice_data['invoice_header_ref_interne'])
|
||||
|
||||
inserted_id = MYSY_GV.dbname['invoice_paiement'].insert_one(new_data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
" Impossible de créer le paiement (2) ")
|
||||
return False, "Impossible de créer le paiement (2) "
|
||||
|
||||
|
||||
"""
|
||||
Mettre à jour la facture pour dire si elle est completement payée ou pas
|
||||
"""
|
||||
|
||||
payed_amount = 0
|
||||
for retval in MYSY_GV.dbname['invoice_paiement'].find({'invoice_id': str(diction['invoice_id']),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'}):
|
||||
|
||||
local_status, local_retval = mycommon.IsFloat(str(retval['paiement_amount']))
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible d'évaluer les paiements effectués ")
|
||||
return False, " Impossible d'évaluer les paiements effectués "
|
||||
|
||||
payed_amount = payed_amount + local_retval
|
||||
|
||||
remain_to_paye = round(total_invoice_amount_float - payed_amount,2)
|
||||
|
||||
|
||||
update_data = {}
|
||||
update_data['update_date'] = str(datetime.now())
|
||||
update_data['update_by'] = "reprise"
|
||||
update_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
|
||||
if( total_relicat == 0):
|
||||
update_data['invoice_paiement_status'] = "2"
|
||||
update_data['reste_to_paye'] = str(remain_to_paye)
|
||||
else:
|
||||
update_data['invoice_paiement_status'] = "1"
|
||||
update_data['reste_to_paye'] = str(remain_to_paye)
|
||||
|
||||
result = MYSY_GV.dbname['partner_invoice_header'].find_one_and_update(
|
||||
{'_id':ObjectId(str(diction['invoice_id'])),
|
||||
'valide':'1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid':str(my_partner['recid'])},
|
||||
{"$set": update_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
||||
|
||||
return True, " Le paiement a été correctement crée "
|
||||
|
||||
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 le paiement "
|
||||
|
||||
|
||||
"""
|
||||
CFH reprise des reglement de facture
|
||||
"""
|
||||
def CFH_Repise_Paiement_Facture(diction):
|
||||
try:
|
||||
|
||||
saved_file = "./temp_direct/template_paiement_facture_CFH_exemple_fichier_DEV.csv"
|
||||
#saved_file = "./temp_direct/facture_exemple_fichier_v2_prod.csv"
|
||||
|
||||
|
||||
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';', encoding_errors='ignore',
|
||||
skipinitialspace=True)
|
||||
df = df.fillna('')
|
||||
df = df.applymap(lambda x: x.strip() if isinstance(x, str) else x)
|
||||
|
||||
total_rows = len(df)
|
||||
x = range(0, total_rows)
|
||||
field_list = ['date_paiement', 'facture', 'montant', 'mode_paiement',
|
||||
'ref_paiement',]
|
||||
|
||||
list_facture_ok = []
|
||||
|
||||
error = 0
|
||||
for n in x:
|
||||
date_paiement = str(df['date_paiement'].values[n]).strip()
|
||||
facture = str(df['facture'].values[n]).strip()
|
||||
montant = str(df['montant'].values[n]).strip()
|
||||
mode_paiement = str(df['mode_paiement'].values[n]).strip()
|
||||
ref_paiement = str(df['ref_paiement'].values[n]).strip()
|
||||
|
||||
print(" QRY invoice = ", {'invoice_header_ref_interne':str(facture),
|
||||
'partner_owner_recid':str(diction['partner_owner_recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
|
||||
is_valide_facture = MYSY_GV.dbname['partner_invoice_header'].count_documents({'invoice_header_ref_interne':str(facture),
|
||||
'partner_owner_recid':str(diction['partner_owner_recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
|
||||
invoice_ok = 1
|
||||
if( is_valide_facture != 1 ):
|
||||
print(" ## Le numero de facture : "+str(facture)+" est invalide ")
|
||||
error = error +1
|
||||
invoice_ok = -1
|
||||
|
||||
local_status = mycommon.CheckisDate(str(date_paiement))
|
||||
if (local_status is False):
|
||||
print( " La date de facture "+str(date_paiement)+" n'est pas au format jj/mm/aaaa ")
|
||||
error = error + 1
|
||||
invoice_ok = -1
|
||||
|
||||
local_status, local_retval = mycommon.IsFloat(montant)
|
||||
if (local_status is False):
|
||||
print(" Le montant " +str(montant) + " est invalide")
|
||||
error = error + 1
|
||||
invoice_ok = -1
|
||||
|
||||
if( invoice_ok == 1):
|
||||
list_facture_ok.append(str(facture))
|
||||
|
||||
|
||||
|
||||
|
||||
for n in x:
|
||||
date_paiement = str(df['date_paiement'].values[n]).strip()
|
||||
facture = str(df['facture'].values[n]).strip()
|
||||
montant = str(df['montant'].values[n]).strip()
|
||||
mode_paiement = str(df['mode_paiement'].values[n]).strip()
|
||||
ref_paiement = str(df['ref_paiement'].values[n]).strip()
|
||||
|
||||
if( facture in list_facture_ok ):
|
||||
print(" OK pour traiter la facture : "+str(facture))
|
||||
|
||||
invoice_data = MYSY_GV.dbname['partner_invoice_header'].find_one(
|
||||
{'invoice_header_ref_interne': str(facture),
|
||||
'partner_owner_recid': str(diction['partner_owner_recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
local_diction = {}
|
||||
local_diction['partner_owner_recid'] = diction['partner_owner_recid']
|
||||
local_diction['invoice_id'] = str(invoice_data['_id'])
|
||||
local_diction['paiement_amount'] = montant
|
||||
local_diction['paiement_mode'] = mode_paiement
|
||||
local_diction['paiement_date'] = date_paiement
|
||||
local_diction['paiement_ref'] = ref_paiement
|
||||
|
||||
|
||||
|
||||
local_status, local_retval = Internal_Add_Invoice_Paiement(local_diction)
|
||||
if( local_status is False):
|
||||
print(" ERRR Internal_Add_Invoice_Paiement = ", str(local_retval))
|
||||
|
||||
|
||||
return True, "Import Paiement ok"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de faire la reprise des paiements"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue