소스 검색

FIX Corrections diverses

olivier.massot 7 년 전
부모
커밋
0d19c6e3b0
4개의 변경된 파일26개의 추가작업 그리고 17개의 파일을 삭제
  1. 18 11
      analytique2facture.py
  2. 6 4
      ctrl2analytique.py
  3. 1 1
      gf2analytique.py
  4. 1 1
      mails_rappel_ctrl.py

+ 18 - 11
analytique2facture.py

@@ -8,7 +8,7 @@ from datetime import datetime
 import logging
 import sys
 
-from path import Path
+from path import Path  # @UnusedImport
 
 from core import logconf
 from core.pde import FacturesDb, AnalytiqueDb, CommunDb, EnTete, Ligne
@@ -41,10 +41,10 @@ commun_db = CommunDb(autocommit=False)
 Sql = SqlFormatter()
 
 current = "{:%m/%Y}".format(datetime.now())
-# mois_facturation = input("Veuillez renseigner le mois de facturation [defaut: {}] ('q' pour quitter): ".format(current))  # Format: voir avec jacky
-# if mois_facturation == 'q':
-#     sys.exit(1)
-mois_facturation = "01/2018"
+
+mois_facturation = input("Veuillez renseigner le mois de facturation [defaut: {}] ('q' pour quitter): ".format(current))  # Format: voir avec jacky
+if mois_facturation == 'q':
+    sys.exit(1)
 
 sql = """SELECT * FROM tbl_Tarification
         WHERE strStatut='A facturer'
@@ -138,10 +138,13 @@ for affaireId, interventions in a_facturer.items():
 
     # Commentaires
     entete.memObsEntete = "[Mois : {mois_facturation}]\r\n" \
-                          "[Lieu de travail : ]{affaire.strLieux}\r\n" \
-                          "[V/Cde : ] {affaire.Ref} du {affaire.dtmCommande:%d/%m/%Y}\r\n" \
+                          "[Lieu de travail : ]{strLieux}\r\n" \
+                          "[V/Cde : ] {Ref} du {dtmCommande}\r\n" \
                           "".format(mois_facturation=mois_facturation,
-                                    affaire=affaire)
+                                    strLieux=affaire.strLieux,
+                                    Ref=affaire.Ref,
+                                    dtmCommande="{:%d/%m/%Y}".format(affaire.dtmCommande) if affaire.dtmCommande else "",
+                                    )
 
     entete.memObsInterne = "N° Affaire analytique : {}".format(affaire.strLiaisonControle)
 
@@ -172,9 +175,13 @@ for affaireId, interventions in a_facturer.items():
 
         ligne.dblQte = interv.dblQuantite
 
-        unite = commun_db.first("SELECT * FROM tblUnite WHERE strUniteCourt='{}'".format(interv.strUnite))
-        ligne.bytUniteIdQuantite = unite.bytUniteId
-        ligne.bytUniteIdPrix = unite.bytUniteId
+        if interv.strUnite:
+            unite = commun_db.first("SELECT * FROM tblUnite WHERE strUniteCourt='{}'".format(interv.strUnite))
+            ligne.bytUniteIdQuantite = unite.bytUniteId
+            ligne.bytUniteIdPrix = unite.bytUniteId
+        else:
+            ligne.bytUniteIdQuantite = 0
+            ligne.bytUniteIdPrix = 0
         ligne.dblPUhtBrutDev = interv.dblPrixUnitaire
         ligne.dblPUhtNetDev = interv.dblPrixUnitaire
         ligne.dblPThtNetDev = interv.dblPrixTotal

+ 6 - 4
ctrl2analytique.py

@@ -65,7 +65,6 @@ for file in (affaires_file, intervs_file):
         logger.debug("Supprime le fichier %s", file)
         file.remove()
 
-
 sqlHelper = AccessSqlHelper
 
 # date zéro pour Access
@@ -425,7 +424,7 @@ while errors:
 
     for interv in Interv.load_csv(intervs_file):
 
-        prefix = "Intervention {}: ".format(interv.strLiaisonControle)
+        prefix = "Intervention {}: ".format(interv.strTest)
         if not interv.strEquipeId:
             errors.append(prefix + "Equipe manquante")
         if not interv.strEnginId:
@@ -442,7 +441,7 @@ while errors:
             errors.append(prefix + "Unité non renseignée")
         if not interv.dtmIntervention:
             errors.append(prefix + "Erreur : date d'intervention")
-        if not interv.dtmDureeIntervention:
+        if not interv.dtmDureeIntervention or interv.dtmDureeIntervention == date_zero:
             errors.append(prefix + "Durée d'intervention nulle")
         if not interv.strunite:
             errors.append(prefix + "Unité non renseignée")
@@ -462,12 +461,15 @@ while errors:
 
     prompt = ""
     while prompt != "v":
-        prompt = input(">> Veuillez contrôler les données, puis taper 'v' pour continuer, ou 'q' pour quitter...")
+        prompt = input(">> Veuillez contrôler les données, puis taper: \n\t'v' pour continuer et relancer le contrôle des données\n\t'f' pour forcer le traitement à se poursuivre\n\t'q' pour annuler...")
+        if prompt == "f":
+            break
         if prompt == "q":
             logger.info("# Annulation de l'import")
             sys.exit(1)
 
 
+
 # ########## MISE A JOUR DE LA BASE DE DONNEES ANALYTIQUE ##########
 
 # On charge en mémoire les affaires et les interventions

+ 1 - 1
gf2analytique.py

@@ -181,7 +181,7 @@ while errors:
             sys.exit(errors)
         else:
             try:
-                call(["start", importfile])
+                call(["start", "", importfile.abspath()], shell=True)
             except:
                 logger.error("Erreur au lancement du fichier %s", importfile)
             input("Presser une touche pour continuer...")

+ 1 - 1
mails_rappel_ctrl.py

@@ -29,7 +29,7 @@ wrkdir = ""
 # logger.warning("Mode TEST")
 # ControlesDb._path = Path(r"\\h2o\local\4-transversal\BDD\mdb_test\cg67Parc_data.mdb")
 # DEBUG = True
-# wrkdir = mk_workdir("mails_rappel_ctrl")
+# wrkdir = mk_workdir("mails_rappel_ctrl_test")
 
 ##-----------------------------------------------