]> gitweb.pimeys.fr Git - scripts-20-100.git/blobdiff - bde/credits_duplicates.py
[bde/credits_duplicates] On affiche le montant total gagné si dévalidation
[scripts-20-100.git] / bde / credits_duplicates.py
index e9185d3b742d412c805003ea0e8d061182065c4c..a96815ee5afae2cd5b430b00422be9da34cbd269 100755 (executable)
@@ -124,10 +124,11 @@ def interactive(blocks, cur, args):
     ou d'afficher une liste de toutes celles à dévalider.
     """
     ids_to_devalidate = []
+    total = 0
     for b in blocks:
         lb = [int(i) for i in b.split(",")]
         l = get_transactions(cur, b)
-        formatted = pretty_print.sql_pretty_print(l, keys=["id", "date", "type", "emetteur", "destinataire", "quantite", "montant", "description", "valide", "cantinvalidate"])
+        formatted = pretty_print.sql_pretty_print(l, keys=["id", "date", "type", "emetteur", "destinataire", "quantite", "montant", "description", "valide", "cantinvalidate", "prenom", "nom"])
         if not args.noless:
             p = subprocess.Popen(["less"], stdin=subprocess.PIPE)
             p.communicate(formatted.encode("utf-8"))
@@ -145,8 +146,11 @@ def interactive(blocks, cur, args):
         elif ans.lower() in ["s"]:
             lb.remove(idkeep)
             ids_to_devalidate.extend(lb)
+            total += l[0]["montant"] * (len(l) - 1)
     if ids_to_devalidate:
-        print "\nIDs de transactions à dévalider :\n" + ",".join([str(i) for i in ids_to_devalidate])
+        print "\nIDs de transactions à dévalider (%s) :" % len(ids_to_devalidate)
+        print ",".join([str(i) for i in ids_to_devalidate])
+        print "Montant total : %s" % (total,)
 
 if __name__ == "__main__":
     parser = argparse.ArgumentParser(description="Liste les crédits semblables trop proches dans le temps et propose de les dévalider tous sauf 1.")