From 305d96eb45370d6a66736c0195cda3737952f935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ch=C3=A9rifBALDE?= Date: Sun, 4 Sep 2022 16:26:54 +0200 Subject: [PATCH] 04/09/22 - 16h --- GlobalVariable.py | 17 +++++++++++++++-- class_mgt.py | 4 +--- ela_factures_mgt.py | 32 +++++++++++++++++++++++++++++--- prj_common.py | 2 +- wrapper.py | 9 ++++----- 5 files changed, 50 insertions(+), 14 deletions(-) diff --git a/GlobalVariable.py b/GlobalVariable.py index 0ee2e58..ec361b3 100644 --- a/GlobalVariable.py +++ b/GlobalVariable.py @@ -149,7 +149,8 @@ TVA_TAUX = 0.2 """ Connexion SFTP """ -MYSY_FTP_HOST = "192.168.1.21" +#MYSY_FTP_HOST = "192.168.1.21" +MYSY_FTP_HOST = "88.170.110.220" MYSY_FTP_LOGIN = "mysysftpuser" MYSY_FTP_PWD = "JvMysedrBsDMy01!+" @@ -159,8 +160,20 @@ Repertoire de depot des factures #INVOICE_DIRECTORY = "/var/www/html/sftp_iexercice/mysy_invoices" INVOICE_DIRECTORY = "./Invoices/" +""" +""" + """ Repertoire racine du ftp ou sont stocké les factures """ INVOICE_FTP_DIRECTORY = "https://sftp.iexercice.com/mysy_invoices/" -INVOICE_FTP_LOCAL_STORAGE_DIRECTORY = "/var/www/html/sftp_iexercice/mysy_invoices/" + + +if (MYSY_ENV == "PROD"): + INVOICE_FTP_LOCAL_STORAGE_DIRECTORY = "/var/www/html/sftp_iexercice/mysy_invoices/" + + +elif (MYSY_ENV == "DEV"): + INVOICE_FTP_LOCAL_STORAGE_DIRECTORY = "/var/www/html/sftp_iexercice/mysy_invoices_dev/" + + diff --git a/class_mgt.py b/class_mgt.py index 28c9589..926d47a 100644 --- a/class_mgt.py +++ b/class_mgt.py @@ -1963,12 +1963,10 @@ def get_class_by_metier(diction): RetObject = [] - - for retVal in coll_name.find({'valide': '1', 'locked': '0', 'metier': str(my_metier), 'published':'1'}, {"_id": 0, "indexed": 0, "indexed_desc": 0, "indexed_obj": 0, "indexed_title": 0, "valide": 0, "locked": 0, "partner_owner_recid": 0, } - ).sort([("price", pymongo.ASCENDING), ("date_update", pymongo.DESCENDING), ]): + ).sort([("display_rank", pymongo.DESCENDING), ("price", pymongo.ASCENDING), ("date_update", pymongo.DESCENDING), ]): #print(" retval " + str(retVal)) diff --git a/ela_factures_mgt.py b/ela_factures_mgt.py index ba766d7..3cd406e 100644 --- a/ela_factures_mgt.py +++ b/ela_factures_mgt.py @@ -25,6 +25,8 @@ import jinja2 import ftplib import pysftp from flask import send_file +from dateutil.relativedelta import relativedelta + class JSONEncoder(json.JSONEncoder): def default(self, o): @@ -91,7 +93,7 @@ def get_invoice_by_customer(diction): 'order_id':1, 'invoice_id':1, 'due_date':1, 'invoice_date':1, } )\ - .sort([("date_facture", pymongo.ASCENDING), ("num_facture", pymongo.DESCENDING), ]): + .sort([("invoice_date", pymongo.DESCENDING), ("invoice_id", pymongo.DESCENDING), ]): user = retVal if ("_id" in user.keys()): user['class_id'] = user.pop('_id') @@ -647,9 +649,11 @@ def CreateInvoice(diction): #print(" ######## last_invoice_id = "+str(last_invoice_id)) last_invoice_id = last_invoice_id + 1 - Order_Invoice = "MySy_0000"+str(last_invoice_id) - diction['invoice_id']= str(Order_Invoice) now = datetime.now() + prefix = "FACT_"+str(now.year)[-2:]+str(now.month)+str("000") + Order_Invoice = str(prefix)+str(last_invoice_id) + diction['invoice_id']= str(Order_Invoice) + diction['due_date'] = str(now.strftime("%d/%m/%Y")) diction['invoice_date'] = str(now.strftime("%d/%m/%Y")) diction['printed'] = "0" @@ -667,6 +671,28 @@ def CreateInvoice(diction): #email.SalesOrderConfirmationEmail(str(new_data['invoice_email']), new_data) + """ + Mise à jour de la commande avec le prochaine date de facturation """ + next_invoice_date = "" + if( str(diction['periodicite']).lower() == "mensuel" ): + next_invoice_date = datetime.today().date() + relativedelta(months=+1) + + if (str(diction['periodicite']).lower() == "annuel"): + next_invoice_date = datetime.today().date() + relativedelta(years=+1) + + #print(" ####### prochaine facturation de la commande : "+str(diction['order_id'])+" LE : "+str(next_invoice_date)) + + coll_orders = MYSY_GV.dbname['sales_order'] + ret_val_order = coll_orders.find_one_and_update( + {'order_id': str(diction['order_id']) }, {"$set": {'next_invoice_date': str(next_invoice_date)}}, + upsert=False, + return_document=ReturnDocument.AFTER + ) + + if (ret_val_order['_id'] is False): + mycommon.myprint( + " Impression de mettre à jour la date de la prochaine facturation de la commande : ° " + str(diction['order_id']) + " ") + return True, except Exception as e: diff --git a/prj_common.py b/prj_common.py index ff7533e..82b9cf6 100644 --- a/prj_common.py +++ b/prj_common.py @@ -1552,7 +1552,7 @@ def Get_Suggested_Word(): insertObject = [] coll_name = MYSY_GV.dbname['search_suggestion_words'] - for x in coll_name.find({}, {'_id':0}).sort([("mot", pymongo.ASCENDING), ]): + for x in coll_name.find({}, {'_id':0}).sort([("display_rank", pymongo.DESCENDING), ("mot", pymongo.ASCENDING), ]): nb_result = nb_result + 1 val_tmp = {} val_tmp['id'] = str(nb_result) diff --git a/wrapper.py b/wrapper.py index 586bf54..086ce9e 100644 --- a/wrapper.py +++ b/wrapper.py @@ -189,13 +189,12 @@ def get_all_class(diction): val_tmp = len(tab_training_inzone) insertObject = [] - for x in coll_name.find({ "$or": [ {'valide':'1', 'locked':'0', 'isalaune':'1', 'published':'1'}, { 'coeur': 1, 'published':'1' } ] }, {"_id": 0, "indexed": 0, "indexed_desc": 0, "indexed_obj": 0, "indexed_title": 0, "valide": 0, "locked": 0, "partner_owner_recid": 0, }).\ limit(nb_formation_a_jouter).\ sort( - [ ("price", pymongo.ASCENDING), ("date_update", pymongo.DESCENDING) ]): + [("display_rank", pymongo.DESCENDING), ("price", pymongo.ASCENDING), ("date_update", pymongo.DESCENDING) ]): @@ -309,7 +308,7 @@ def get_training_in_user_zone(diction): "valide": 0, "locked": 0, "partner_owner_recid": 0, }).\ limit(MYSY_GV.MAINPAGE_QUERY_LIMIT_ROW).\ sort( - [ ("price", pymongo.ASCENDING), ("date_update", pymongo.DESCENDING),]): + [ ("display_rank", pymongo.DESCENDING), ("price", pymongo.ASCENDING), ("date_update", pymongo.DESCENDING),]): @@ -522,7 +521,7 @@ def recherche_text_simple(diction): for x in coll_name.find({"external_code": {"$in": final_message2}, 'published':'1'}, {"_id": 0, "indexed": 0, "indexed_desc": 0, "indexed_obj": 0, "indexed_title": 0, "valide": 0, "locked": 0, "partner_owner_recid": 0, }).\ - sort([("price", pymongo.ASCENDING), ("date_update", pymongo.DESCENDING), ]): + sort([("display_rank", pymongo.DESCENDING), ("price", pymongo.ASCENDING), ("date_update", pymongo.DESCENDING), ]): nb_result = nb_result +1 my_recid = {} @@ -596,7 +595,7 @@ def recherche_text_simple(diction): for x in coll_name.find({"external_code":{"$in":tab_training}, 'published':'1'}, {"_id": 0, "indexed": 0, "indexed_desc": 0, "indexed_obj": 0, "indexed_title": 0, "valide": 0, - "locked": 0, "partner_owner_recid": 0, }).sort([("price", pymongo.ASCENDING), ("date_update", pymongo.DESCENDING), ]): + "locked": 0, "partner_owner_recid": 0, }).sort([("display_rank", pymongo.DESCENDING), ("price", pymongo.ASCENDING), ("date_update", pymongo.DESCENDING), ]): nb_result = nb_result + 1 my_recid = {}